Commit e2303e9b authored by hugues.jerome's avatar hugues.jerome Committed by yoogx

* Refactor example

	- add two loopback test for native and leon
	- exchange a character instead of an int to avoid endianess issues


git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-ada@700 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent f3beca5c
...@@ -23,8 +23,11 @@ SCENARIO_FILES= ...@@ -23,8 +23,11 @@ SCENARIO_FILES=
CHECKABLE_SCENARIO_FILES= CHECKABLE_SCENARIO_FILES=
if HAS_GNATMAKE_FOR_LEON if HAS_GNATMAKE_FOR_LEON
SCENARIO_FILES+= $(srcdir)/scenario_spw.aadl \ SCENARIO_FILES+= $(srcdir)/scenario_spw.aadl \
$(srcdir)/scenario.aadl $(srcdir)/scenario_uart.aadl $(srcdir)/scenario.aadl $(srcdir)/scenario_uart.aadl \
$(srcdir)/scenario_uart_2.aadl \
$(srcdir)/scenario_no_cnx_leon.aadl \
$(srcdir)/scenario_no_cnx_native.aadl
endif endif
# Note: we may not package $(srcdir)/scenario_uart_2.aadl because some # Note: we may not package $(srcdir)/scenario_uart_2.aadl because some
......
...@@ -76,7 +76,6 @@ package body GRUART is ...@@ -76,7 +76,6 @@ package body GRUART is
Nodes (J).UART_Device_Receive Nodes (J).UART_Device_Receive
:= Uart.Core.UART_Device'Value := Uart.Core.UART_Device'Value
(To_String (Name_Table (J).Location) (3 .. 3)); (To_String (Name_Table (J).Location) (3 .. 3));
end loop; end loop;
Uart.HLInterface.Open (Port => Nodes (My_Node).UART_Port_Send, Uart.HLInterface.Open (Port => Nodes (My_Node).UART_Port_Send,
...@@ -106,6 +105,7 @@ package body GRUART is ...@@ -106,6 +105,7 @@ package body GRUART is
SEL : AS_Message_Length_Stream; SEL : AS_Message_Length_Stream;
SEA : AS_Full_Stream; SEA : AS_Full_Stream;
SEO : Ada.Streams.Stream_Element_Offset; SEO : Ada.Streams.Stream_Element_Offset;
Packet_Size : Ada.Streams.Stream_Element_Offset;
Data_Received_Index : Ada.Streams.Stream_Element_Offset; Data_Received_Index : Ada.Streams.Stream_Element_Offset;
begin begin
...@@ -120,13 +120,13 @@ package body GRUART is ...@@ -120,13 +120,13 @@ package body GRUART is
Uart.HLInterface.Read (Nodes (My_Node).UART_Port_Receive, SEL, SEO); Uart.HLInterface.Read (Nodes (My_Node).UART_Port_Receive, SEL, SEO);
SEO := Ada.Streams.Stream_Element_Offset Packet_Size := Ada.Streams.Stream_Element_Offset
(To_Length (To_PO_HI_Message_Length_Stream (SEL))); (To_Length (To_PO_HI_Message_Length_Stream (SEL)));
SEA (1 .. Message_Length_Size) := SEL; SEA (1 .. Message_Length_Size) := SEL;
Data_Received_Index := Message_Length_Size + 1; Data_Received_Index := Message_Length_Size + 1;
while Data_Received_Index < SEO loop while Data_Received_Index < Packet_Size loop
-- We must loop to make sure we receive all data -- We must loop to make sure we receive all data
Uart.HLInterface.Read (Nodes (My_Node).UART_Port_Receive, Uart.HLInterface.Read (Nodes (My_Node).UART_Port_Receive,
......
pragma Warnings (Off); pragma Warnings (Off);
with Interfaces; with Interfaces;
with Ada.Exceptions;
with Ada.Unchecked_Conversion; with Ada.Unchecked_Conversion;
with Ada.Streams; with Ada.Streams;
with GNAT.Serial_Communications; with GNAT.Serial_Communications;
...@@ -9,7 +10,6 @@ with PolyORB_HI.Output; ...@@ -9,7 +10,6 @@ with PolyORB_HI.Output;
with PolyORB_HI.Messages; with PolyORB_HI.Messages;
with PolyORB_HI_Generated.Transport; with PolyORB_HI_Generated.Transport;
with Ada.Exceptions;
-- This package provides support for the Native_UART device driver as -- This package provides support for the Native_UART device driver as
-- defined in the Native_UART AADLv2 model. -- defined in the Native_UART AADLv2 model.
...@@ -21,7 +21,6 @@ package body Native_UART is ...@@ -21,7 +21,6 @@ package body Native_UART is
-- generated for Transport. -- generated for Transport.
use Interfaces; use Interfaces;
use Ada.Exceptions;
use PolyORB_HI.Messages; use PolyORB_HI.Messages;
use PolyORB_HI.Utils; use PolyORB_HI.Utils;
use PolyORB_HI.Output; use PolyORB_HI.Output;
...@@ -65,18 +64,18 @@ package body Native_UART is ...@@ -65,18 +64,18 @@ package body Native_UART is
begin begin
GNAT.Serial_Communications.Open GNAT.Serial_Communications.Open
(Port => Nodes (My_Node).UART_Port_Send, (Port => Nodes (My_Node).UART_Port_Send,
Name => "/dev/ttyS3"); Name => "/dev/ttyS0");
exception exception
when others => when others =>
Put_Line ("ttyS4"); Put_Line ("ttyS0");
end; end;
begin begin
GNAT.Serial_Communications.Open GNAT.Serial_Communications.Open
(Port => Nodes (My_Node).UART_Port_Receive, (Port => Nodes (My_Node).UART_Port_Receive,
Name => "/dev/ttyS0"); Name => "/dev/ttyUSB1");
exception exception
when others => when others =>
Put_Line ("error tty"); Put_Line ("ttyUSB1");
end; end;
GNAT.Serial_Communications.Set GNAT.Serial_Communications.Set
...@@ -86,8 +85,7 @@ package body Native_UART is ...@@ -86,8 +85,7 @@ package body Native_UART is
GNAT.Serial_Communications.Set GNAT.Serial_Communications.Set
(Port => Nodes (My_Node).UART_Port_Receive, (Port => Nodes (My_Node).UART_Port_Receive,
Rate => GNAT.Serial_Communications.B19200, Rate => GNAT.Serial_Communications.B19200,
Block => True, Block => True);
Timeout => 15.0);
Put_Line (Normal, "Initialization of UART subsystem" Put_Line (Normal, "Initialization of UART subsystem"
& " is complete"); & " is complete");
...@@ -107,6 +105,7 @@ package body Native_UART is ...@@ -107,6 +105,7 @@ package body Native_UART is
SEL : AS_Message_Length_Stream; SEL : AS_Message_Length_Stream;
SEA : AS_Full_Stream; SEA : AS_Full_Stream;
SEO : Ada.Streams.Stream_Element_Offset; SEO : Ada.Streams.Stream_Element_Offset;
Packet_Size : Ada.Streams.Stream_Element_Offset;
Data_Received_Index : Ada.Streams.Stream_Element_Offset; Data_Received_Index : Ada.Streams.Stream_Element_Offset;
begin begin
...@@ -122,12 +121,13 @@ package body Native_UART is ...@@ -122,12 +121,13 @@ package body Native_UART is
GNAT.Serial_Communications.Read GNAT.Serial_Communications.Read
(Nodes (My_Node).UART_Port_Receive, SEL, SEO); (Nodes (My_Node).UART_Port_Receive, SEL, SEO);
SEO := Ada.Streams.Stream_Element_Offset (10); Packet_Size := Ada.Streams.Stream_Element_Offset
(To_Length (To_PO_HI_Message_Length_Stream (SEL)));
SEA (1 .. Message_Length_Size) := SEL; SEA (1 .. Message_Length_Size) := SEL;
Data_Received_Index := Message_Length_Size + 1; Data_Received_Index := Message_Length_Size + 1;
while Data_Received_Index < 10 loop while Data_Received_Index < Packet_Size loop
-- We must loop to make sure we receive all data -- We must loop to make sure we receive all data
GNAT.Serial_Communications.Read GNAT.Serial_Communications.Read
...@@ -150,20 +150,21 @@ package body Native_UART is ...@@ -150,20 +150,21 @@ package body Native_UART is
-- Deliver to the peer handler -- Deliver to the peer handler
PolyORB_HI_Generated.Transport.Deliver begin
(PolyORB_HI_Generated.Deployment.Node_2_Ping_Me_K, PolyORB_HI_Generated.Transport.Deliver
To_PO_HI_Full_Stream (SEA) (Corresponding_Entity
(1 .. Stream_Element_Offset (SEO) + 1)); (Integer_8 (SEA (Message_Length_Size + 1))),
To_PO_HI_Full_Stream (SEA)
(1 .. Stream_Element_Offset (SEO)));
exception
when E : others =>
Put_Line (Ada.Exceptions.Exception_Information (E));
Put_Line ("arghl");
end;
else else
Put_Line ("Got error"); Put_Line ("Got error");
end if; end if;
end loop Main_Loop; end loop Main_Loop;
exception
when E : others =>
Put_Line (Exception_Name (E));
Put_Line (Exception_Message (E));
Put_Line ("arghl");
end Receive; end Receive;
---------- ----------
......
...@@ -4,7 +4,7 @@ package body Ping is ...@@ -4,7 +4,7 @@ package body Ping is
use PolyORB_HI.Output; use PolyORB_HI.Output;
Var : Simple_Type := 0; Var : constant Simple_Type := 'a';
----------------- -----------------
-- Do_Ping_Spg -- -- Do_Ping_Spg --
...@@ -14,7 +14,6 @@ package body Ping is ...@@ -14,7 +14,6 @@ package body Ping is
begin begin
Data_Source := Var; Data_Source := Var;
Put_Line (Normal, "Sending ORDER: " & Simple_Type'Image (Var)); Put_Line (Normal, "Sending ORDER: " & Simple_Type'Image (Var));
Var := Var + 1;
end Do_Ping_Spg; end Do_Ping_Spg;
end Ping; end Ping;
-- This is a scenario file describing the devide driver integration demo
-- $Id: scenario_local.aadl 6713 2009-06-20 20:58:28Z lanarre $
system delayed_connections
properties
Ocarina_Config::AADL_Files => ("grspw.aadl", "gr_cpci_x4cv.aadl",
"generic_bus.aadl", "native_uart.aadl", "generic_native.aadl",
"gruart.aadl", "software.aadl", "system_demo.aadl");
Ocarina_Config::Generator => polyorb_hi_ada;
Ocarina_Config::Needed_Property_Sets =>
(value (Ocarina_Config::Data_Model),
value (Ocarina_Config::Deployment));
Ocarina_Config::AADL_Version => AADLv2;
Ocarina_Config::Root_System_Name => "the_demo.no_cnx_leon";
end delayed_connections;
system implementation delayed_connections.Impl
end delayed_connections.Impl;
-- This is a scenario file describing the devide driver integration demo
-- $Id: scenario_local.aadl 6713 2009-06-20 20:58:28Z lanarre $
system delayed_connections
properties
Ocarina_Config::AADL_Files => ("grspw.aadl", "gr_cpci_x4cv.aadl",
"generic_bus.aadl", "native_uart.aadl", "generic_native.aadl",
"gruart.aadl", "software.aadl", "system_demo.aadl");
Ocarina_Config::Generator => polyorb_hi_ada;
Ocarina_Config::Needed_Property_Sets =>
(value (Ocarina_Config::Data_Model),
value (Ocarina_Config::Deployment));
Ocarina_Config::AADL_Version => AADLv2;
Ocarina_Config::Root_System_Name => "the_demo.no_cnx_native";
end delayed_connections;
system implementation delayed_connections.Impl
end delayed_connections.Impl;
...@@ -15,7 +15,7 @@ public ...@@ -15,7 +15,7 @@ public
data Simple_Type data Simple_Type
properties properties
Data_Model::Data_Representation => integer; Data_Model::Data_Representation => character;
end Simple_Type; end Simple_Type;
----------------- -----------------
...@@ -55,6 +55,7 @@ Mycall : { ...@@ -55,6 +55,7 @@ Mycall : {
connections connections
parameter P_Spg.Data_Source -> Data_Source; parameter P_Spg.Data_Source -> Data_Source;
properties properties
Source_Stack_Size => 512 KByte;
Dispatch_Protocol => Periodic; Dispatch_Protocol => Periodic;
Period => 10 sec; Period => 10 sec;
Priority => 2; Priority => 2;
......
...@@ -21,6 +21,17 @@ public ...@@ -21,6 +21,17 @@ public
-- PROCESSES -- -- PROCESSES --
--------------- ---------------
process Process_Zero
end Process_Zero;
process implementation Process_Zero.Impl
subcomponents
Pinger : thread Software::Pinger.Impl;
Ping_Me : thread Software::Pingee.Impl;
connections
port Pinger.Data_Source -> Ping_Me.Data_Sink;
end Process_Zero.Impl;
process Process_Simple process Process_Simple
features features
Out_Port : out event data port Software::Simple_Type; Out_Port : out event data port Software::Simple_Type;
...@@ -165,7 +176,6 @@ public ...@@ -165,7 +176,6 @@ public
-- Note: this setting assumes one RASTA board, with UART DSU #1 -- Note: this setting assumes one RASTA board, with UART DSU #1
-- connected to UART DSU #2. -- connected to UART DSU #2.
-- --
--
-- It shows operation of the GRUART driver. -- It shows operation of the GRUART driver.
subcomponents subcomponents
...@@ -205,9 +215,8 @@ public ...@@ -205,9 +215,8 @@ public
system implementation The_Demo.UART_2 system implementation The_Demo.UART_2
-- Note: this setting assumes one RASTA board, with UART DSU #1 -- Note: this setting assumes one RASTA board and a Native
-- connected to UART DSU #2. -- platform, with UART DSU #1 connected to Native platform UART.
--
-- --
-- It shows operation of the GRUART driver. -- It shows operation of the GRUART driver.
...@@ -267,4 +276,50 @@ public ...@@ -267,4 +276,50 @@ public
end The_Demo.UART_2; end The_Demo.UART_2;
---------------------------------------------------------------------------
system implementation The_Demo.No_Cnx_LEON
-- Note: this setting assumes one node, without particular
-- hardware, to test internal communication.
subcomponents
-- Node #1 hardware components
Processor_1 : processor GR_CPCI_X4CV::LEON2.impl;
Memory_1 : memory GR_CPCI_X4CV::Memory_Segment.impl;
-- Node #1 software components
Node_1 : process Process_Zero.Impl;
properties
Actual_Processor_Binding => (reference (Processor_1)) applies to Node_1;
end The_Demo.No_Cnx_LEON;
system implementation The_Demo.No_Cnx_Native
-- Note: this setting assumes one node, without particular
-- hardware, to test internal communication.
subcomponents
-- Node #1 hardware components
Processor_1 : processor Generic_Native::Generic_Processor.impl;
-- Node #1 software components
Node_1 : process Process_Zero.Impl;
properties
Actual_Processor_Binding => (reference (Processor_1)) applies to Node_1;
end The_Demo.No_Cnx_Native;
end System_Demo; end System_Demo;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment