Commit 47cc798e authored by hugues.jerome's avatar hugues.jerome Committed by yoogx

* Native UART driver is now working



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-ada@706 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent e2303e9b
......@@ -26,6 +26,7 @@ if HAS_GNATMAKE_FOR_LEON
SCENARIO_FILES+= $(srcdir)/scenario_spw.aadl \
$(srcdir)/scenario.aadl $(srcdir)/scenario_uart.aadl \
$(srcdir)/scenario_uart_2.aadl \
$(srcdir)/scenario_uart_native.aadl \
$(srcdir)/scenario_no_cnx_leon.aadl \
$(srcdir)/scenario_no_cnx_native.aadl
endif
......
......@@ -26,15 +26,12 @@ package body Native_UART is
use PolyORB_HI.Output;
type Node_Record is record
-- SpaceWire is a simple protocol, we use one core to send,
-- another to receive.
-- UART is a simple protocol, we use one port to send, another
-- to receive.
UART_Port_Send : GNAT.Serial_Communications.Serial_Port;
-- UART_Device_Send : Uart.Core.UART_Device;
UART_Port_Receive : GNAT.Serial_Communications.Serial_Port;
-- UART_Device_Receive : Uart.Core.UART_Device;
end record;
Nodes : array (Node_Type) of Node_Record;
......@@ -60,30 +57,31 @@ package body Native_UART is
procedure Initialize (Name_Table : PolyORB_HI.Utils.Naming_Table_Type) is
begin
Put_Line ("coin");
begin
GNAT.Serial_Communications.Open
(Port => Nodes (My_Node).UART_Port_Send,
Name => "/dev/ttyS0");
exception
when others =>
Put_Line ("ttyS0");
when E : others =>
Put_Line (Ada.Exceptions.Exception_Information (E));
end;
begin
GNAT.Serial_Communications.Open
(Port => Nodes (My_Node).UART_Port_Receive,
Name => "/dev/ttyUSB1");
Name => "/dev/ttyUSB0");
exception
when others =>
Put_Line ("ttyUSB1");
when E : others =>
Put_Line (Ada.Exceptions.Exception_Information (E));
end;
GNAT.Serial_Communications.Set
(Port => Nodes (My_Node).UART_Port_Send,
Parity => GNAT.Serial_Communications.Even,
Rate => GNAT.Serial_Communications.B19200);
GNAT.Serial_Communications.Set
(Port => Nodes (My_Node).UART_Port_Receive,
Parity => GNAT.Serial_Communications.Even,
Rate => GNAT.Serial_Communications.B19200,
Block => True);
......@@ -111,8 +109,6 @@ package body Native_UART is
Main_Loop : loop
Put_Line ("Using user-provided Native_UART stack to receive");
-- Put_Line ("Waiting on UART #"
-- & Nodes (My_Node).UART_Device_Receive'Img);
-- UART is a character-oriented protocol
......@@ -123,18 +119,20 @@ package body Native_UART is
Packet_Size := Ada.Streams.Stream_Element_Offset
(To_Length (To_PO_HI_Message_Length_Stream (SEL)));
SEO := Packet_Size;
SEA (1 .. Message_Length_Size) := SEL;
Data_Received_Index := Message_Length_Size + 1;
while Data_Received_Index < Packet_Size loop
while Data_Received_Index <= Packet_Size + Message_Length_Size loop
-- We must loop to make sure we receive all data
GNAT.Serial_Communications.Read
(Nodes (My_Node).UART_Port_Receive,
SEA (Data_Received_Index .. SEO + 1),
SEO);
Data_Received_Index := 1 + SEO;
Data_Received_Index := 1 + SEO + 1;
end loop;
-- 2/ Receive full message
......@@ -142,9 +140,7 @@ package body Native_UART is
if SEO /= SEA'First - 1 then
Put_Line
(Normal,
"UART #"
-- & Nodes (My_Node).UART_Device_Receive'Img
& " received"
"UART received"
& Ada.Streams.Stream_Element_Offset'Image (SEO)
& " bytes");
......@@ -159,7 +155,6 @@ package body Native_UART is
exception
when E : others =>
Put_Line (Ada.Exceptions.Exception_Information (E));
Put_Line ("arghl");
end;
else
Put_Line ("Got error");
......@@ -191,7 +186,6 @@ package body Native_UART is
begin
Put_Line ("Using user-provided UART stack to send");
Put_Line ("Sending through UART #"
-- & Nodes (Node).UART_Device_Send'Img
& Size'Img & " bytes");
GNAT.Serial_Communications.Write
......@@ -200,6 +194,7 @@ package body Native_UART is
return Error_Kind'(Error_None);
-- Note: we have no way to no there was an error here
end Send;
end Native_UART;
-- 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.uart_native";
end delayed_connections;
system implementation delayed_connections.Impl
end delayed_connections.Impl;
......@@ -57,7 +57,7 @@ connections
properties
Source_Stack_Size => 512 KByte;
Dispatch_Protocol => Periodic;
Period => 10 sec;
Period => 3 sec;
Priority => 2;
end Pinger.Impl;
......
......@@ -213,6 +213,46 @@ public
---------------------------------------------------------------------------
system implementation The_Demo.UART_Native
-- XXX
subcomponents
Bus_UART : bus Generic_Bus::Generic_Bus.impl;
-- Node #1 hardware components
Processor_1 : processor Generic_Native::Generic_Processor.impl;
Memory_1 : memory Generic_Native::Memory_Segment.impl;
UART_Cnx_1 : device Native_UART_Protocol::Native_UART_Device.impl
{ Deployment::Location => "1:2";
-- Configure UART port #1 to send, #2 to receive
};
-- Node #1 software components
Node_1 : process Process_Simple.Impl;
connections
bus access Bus_UART -> UART_Cnx_1.DB9_Wire;
port Node_1.Out_Port -> Node_1.In_Port
{ Actual_Connection_Binding => (reference (Bus_UART)); };
properties
Actual_Processor_Binding => (reference (Processor_1)) applies to Node_1;
Actual_Processor_Binding => (reference (Processor_1))
applies to UART_Cnx_1;
end The_Demo.UART_Native;
---------------------------------------------------------------------------
system implementation The_Demo.UART_2
-- Note: this setting assumes one RASTA board and a Native
......
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