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=
CHECKABLE_SCENARIO_FILES=
if HAS_GNATMAKE_FOR_LEON
SCENARIO_FILES+= $(srcdir)/scenario_spw.aadl \
$(srcdir)/scenario.aadl $(srcdir)/scenario_uart.aadl
SCENARIO_FILES+= $(srcdir)/scenario_spw.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
# Note: we may not package $(srcdir)/scenario_uart_2.aadl because some
......
......@@ -76,7 +76,6 @@ package body GRUART is
Nodes (J).UART_Device_Receive
:= Uart.Core.UART_Device'Value
(To_String (Name_Table (J).Location) (3 .. 3));
end loop;
Uart.HLInterface.Open (Port => Nodes (My_Node).UART_Port_Send,
......@@ -106,6 +105,7 @@ package body GRUART is
SEL : AS_Message_Length_Stream;
SEA : AS_Full_Stream;
SEO : Ada.Streams.Stream_Element_Offset;
Packet_Size : Ada.Streams.Stream_Element_Offset;
Data_Received_Index : Ada.Streams.Stream_Element_Offset;
begin
......@@ -120,13 +120,13 @@ package body GRUART is
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)));
SEA (1 .. Message_Length_Size) := SEL;
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
Uart.HLInterface.Read (Nodes (My_Node).UART_Port_Receive,
......
pragma Warnings (Off);
with Interfaces;
with Ada.Exceptions;
with Ada.Unchecked_Conversion;
with Ada.Streams;
with GNAT.Serial_Communications;
......@@ -9,7 +10,6 @@ with PolyORB_HI.Output;
with PolyORB_HI.Messages;
with PolyORB_HI_Generated.Transport;
with Ada.Exceptions;
-- This package provides support for the Native_UART device driver as
-- defined in the Native_UART AADLv2 model.
......@@ -21,7 +21,6 @@ package body Native_UART is
-- generated for Transport.
use Interfaces;
use Ada.Exceptions;
use PolyORB_HI.Messages;
use PolyORB_HI.Utils;
use PolyORB_HI.Output;
......@@ -65,18 +64,18 @@ package body Native_UART is
begin
GNAT.Serial_Communications.Open
(Port => Nodes (My_Node).UART_Port_Send,
Name => "/dev/ttyS3");
Name => "/dev/ttyS0");
exception
when others =>
Put_Line ("ttyS4");
Put_Line ("ttyS0");
end;
begin
GNAT.Serial_Communications.Open
(Port => Nodes (My_Node).UART_Port_Receive,
Name => "/dev/ttyS0");
Name => "/dev/ttyUSB1");
exception
when others =>
Put_Line ("error tty");
Put_Line ("ttyUSB1");
end;
GNAT.Serial_Communications.Set
......@@ -86,8 +85,7 @@ package body Native_UART is
GNAT.Serial_Communications.Set
(Port => Nodes (My_Node).UART_Port_Receive,
Rate => GNAT.Serial_Communications.B19200,
Block => True,
Timeout => 15.0);
Block => True);
Put_Line (Normal, "Initialization of UART subsystem"
& " is complete");
......@@ -107,6 +105,7 @@ package body Native_UART is
SEL : AS_Message_Length_Stream;
SEA : AS_Full_Stream;
SEO : Ada.Streams.Stream_Element_Offset;
Packet_Size : Ada.Streams.Stream_Element_Offset;
Data_Received_Index : Ada.Streams.Stream_Element_Offset;
begin
......@@ -122,12 +121,13 @@ package body Native_UART is
GNAT.Serial_Communications.Read
(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;
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
GNAT.Serial_Communications.Read
......@@ -150,20 +150,21 @@ package body Native_UART is
-- Deliver to the peer handler
PolyORB_HI_Generated.Transport.Deliver
(PolyORB_HI_Generated.Deployment.Node_2_Ping_Me_K,
To_PO_HI_Full_Stream (SEA)
(1 .. Stream_Element_Offset (SEO) + 1));
begin
PolyORB_HI_Generated.Transport.Deliver
(Corresponding_Entity
(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
Put_Line ("Got error");
end if;
end loop Main_Loop;
exception
when E : others =>
Put_Line (Exception_Name (E));
Put_Line (Exception_Message (E));
Put_Line ("arghl");
end Receive;
----------
......
......@@ -4,7 +4,7 @@ package body Ping is
use PolyORB_HI.Output;
Var : Simple_Type := 0;
Var : constant Simple_Type := 'a';
-----------------
-- Do_Ping_Spg --
......@@ -14,7 +14,6 @@ package body Ping is
begin
Data_Source := Var;
Put_Line (Normal, "Sending ORDER: " & Simple_Type'Image (Var));
Var := Var + 1;
end Do_Ping_Spg;
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
data Simple_Type
properties
Data_Model::Data_Representation => integer;
Data_Model::Data_Representation => character;
end Simple_Type;
-----------------
......@@ -55,6 +55,7 @@ Mycall : {
connections
parameter P_Spg.Data_Source -> Data_Source;
properties
Source_Stack_Size => 512 KByte;
Dispatch_Protocol => Periodic;
Period => 10 sec;
Priority => 2;
......
......@@ -21,6 +21,17 @@ public
-- 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
features
Out_Port : out event data port Software::Simple_Type;
......@@ -165,7 +176,6 @@ public
-- Note: this setting assumes one RASTA board, with UART DSU #1
-- connected to UART DSU #2.
--
--
-- It shows operation of the GRUART driver.
subcomponents
......@@ -205,9 +215,8 @@ public
system implementation The_Demo.UART_2
-- Note: this setting assumes one RASTA board, with UART DSU #1
-- connected to UART DSU #2.
--
-- Note: this setting assumes one RASTA board and a Native
-- platform, with UART DSU #1 connected to Native platform UART.
--
-- It shows operation of the GRUART driver.
......@@ -267,4 +276,50 @@ public
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;
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