Commit 4f6dcdac authored by yoogx's avatar yoogx

* Ping example with sampling port working

	For openaadl/ocarina#160
parent cf3cc4b0
......@@ -3,7 +3,7 @@ AADL_ROOT = ping.ima
OTHER_FILES =
CLEANDIRS = hello_impl
CLEANDIRS = ping_ima
CLEANFILES =
include $(srcdir)/../../Makefile.common
......
#include <stdio.h>
#include <deployment.h>
#include <po_hi_debug.h>
#include <po_hi_types.h>
#include <po_hi_transport.h>
#include <po_hi_gqueue.h>
#include <request.h>
#include <air.h>
#include <a653.h>
void user_ports_polling ()
{
__po_hi_port_t portno;
__po_hi_node_t mynode;
__po_hi_node_t tmpnode;
__po_hi_request_t request;
__po_hi_port_kind_t pkind;
RETURN_CODE_TYPE rc;
MESSAGE_SIZE_TYPE SIZE;
UPDATED_TYPE UPDATED;
VALIDITY_TYPE VALIDITY;
SAMPLING_PORT_CURRENT_STATUS_TYPE STATUS;
MESSAGE_SIZE_TYPE len;
PARTITION_ID_TYPE self_id;
char message[1024];
__DEBUGMSG ("Polling ports for partition \n");
mynode = __po_hi_transport_get_mynode ();
for (portno = 0 ; portno < __PO_HI_NB_PORTS ; portno++) {
pkind = __po_hi_transport_get_port_kind (portno);
tmpnode = __po_hi_transport_get_node_from_entity
(__po_hi_get_entity_from_global_port (portno));
if (tmpnode == mynode) {
/*
if (pkind == __PO_HI_IN_DATA_INTER_PROCESS) {
ret = XM_read_sampling_message
(__po_hi_transport_xtratum_get_port (portno),
&request,
sizeof (__po_hi_request_t),
0);
}
*/
__DEBUGMSG ("Testing port %d\n",
__po_hi_transport_xtratum_get_port (portno));
if (pkind == __PO_HI_IN_EVENT_DATA_INTER_PROCESS) {
RECEIVE_QUEUING_MESSAGE
(__po_hi_transport_xtratum_get_port (portno),
INFINITE_TIME_VALUE,
&request,
&len,
&rc);
if (rc == NO_ERROR) {
__po_hi_main_deliver (&request);
}
}
}
}
}
......@@ -4,6 +4,28 @@ public
with Deployment;
with ARINC653;
subprogram do_ports_polling
properties
source_language => C;
source_name => "user_ports_polling";
source_text => ("air_polling.c");
end do_ports_polling;
thread port_poller
end port_poller;
thread implementation port_poller.i
calls
Mycalls: {
P_Spg : subprogram do_ports_polling;
};
properties
Dispatch_Protocol => Periodic;
Period => 100 ms;
Deadline => 100 ms;
end port_poller.i;
---------------
-- Processes --
---------------
......@@ -28,6 +50,7 @@ public
process implementation B.Impl
subcomponents
Ping_Me : thread Software::Q.Impl ;
poll_port : thread port_poller.i;
connections
port Data_Sink -> Ping_Me.Data_Sink;
end B.Impl;
......@@ -50,9 +73,9 @@ public
memory implementation myram.sdram
subcomponents
segment1 : memory segment.i
{Base_Address => 40100000; Byte_Count => 524288;};
{Base_Address => 16#40100000#; Byte_Count => 16#400000#; };
segment2 : memory segment.i
{Base_Address => 40180000; Byte_Count => 524288;};
{Base_Address => 16#40200000#; Byte_Count => 16#400000#; };
end myram.sdram;
processor leon3
......@@ -72,11 +95,17 @@ public
processor implementation leon3.AIR_2partitions extends leon3.AIR
subcomponents
part1 : virtual processor AIR_partition.generic
{ Deployment::Execution_Platform => AIR;};
{ Deployment::Execution_Platform => AIR;
ARINC653::Partition_Identifier => 1;
ARINC653::Partition_Name => "part1";
};
part2 : virtual processor AIR_partition.generic
{ Deployment::Execution_Platform => AIR;};
properties
{ Deployment::Execution_Platform => AIR;
ARINC653::Partition_Identifier => 2;
ARINC653::Partition_Name => "part2";
};
properties
ARINC653::Module_Schedule =>
( [Partition => reference (part1);
Duration => 20 ms;
......
#include <stdio.h>
int p=0;
void user_do_ping_spg (int *v)
{
printf ("*** SENDING PING *** %d\n", p);
*v=p;
p++;
fflush (stdout);
}
void user_ping_spg (int i)
{
printf ("*** PING *** %d\n" ,i);
fflush (stdout);
}
void recover (void)
{
printf ("*** RECOVER ACTION ***\n");
fflush (stdout);
}
#ifndef __PING_H_
#define __PING_H_
#include <stdint.h>
typedef int64_t custom_int;
#endif
-- This AADL model illustrates how to model a simple interaction
-- between tasks, in a local or distributed environment.
--
-- One task pings another, sending a data periodically.
--
-- $Id: software.aadl 344 2007-04-17 14:48:16Z zalila $
package Software
public
with Data_Model;
----------
-- Data --
----------
data Simple_Type
properties
Type_Source_Name => "custom_int";
Source_Text => ("ping");
Source_Data_Size => 8 Bytes;
end Simple_Type;
----------
-- Data --
----------
-----------------
-- Subprograms --
-----------------
data Simple_Type
properties
Type_Source_Name => "custom_int";
Source_Text => ("ping");
Source_Data_Size => 8 Bytes;
end Simple_Type;
subprogram Do_Ping_Spg
features
Data_Source : out parameter Simple_Type;
properties
source_language => C;
source_name => "user_do_ping_spg";
source_text => ("ping.c");
end Do_Ping_Spg;
-----------------
-- Subprograms --
-----------------
subprogram Ping_Spg
features
Data_Sink : in parameter Simple_Type;
properties
source_language => C;
source_name => "user_ping_spg";
source_text => ("ping.c");
end Ping_Spg;
subprogram Do_Ping_Spg
features
Data_Source : out parameter Simple_Type;
properties
Source_Language => (C);
Source_Name => "user_do_ping_spg";
Source_Text => ("ping.c");
end Do_Ping_Spg;
subprogram Ping_Spg
features
Data_Sink : in parameter Simple_Type;
properties
Source_Language => C;
Source_Name => "user_ping_spg";
Source_Text => ("ping.c");
end Ping_Spg;
-------------
-- Threads --
-------------
-------------
-- Threads --
-------------
thread P
features
Data_Source : out event data port Simple_Type;
end P;
thread P
features
Data_Source : out event data port Simple_Type;
end P;
thread implementation P.Impl
calls
Mycalls: {
P_Spg : subprogram Do_Ping_Spg;
};
connections
parameter P_Spg.Data_Source -> Data_Source;
properties
Recover_Entrypoint_Source_Text => "recover";
Dispatch_Protocol => Periodic;
Period => 2000 Ms;
Deadline => 2000 ms;
Priority => 2;
Dispatch_Offset => 500 Ms;
end P.Impl;
thread implementation P.Impl
calls
Mycalls: {
P_Spg : subprogram Do_Ping_Spg;
};
connections
parameter P_Spg.Data_Source -> Data_Source;
properties
Dispatch_Protocol => Periodic;
Period => 2000 Ms;
Deadline => 2000 ms;
Priority => 2;
Dispatch_Offset => 500 Ms;
end P.Impl;
thread Q
features
Data_Sink : in event data port Simple_Type;
end Q;
thread Q
features
Data_Sink : in event data port Simple_Type;
end Q;
thread implementation Q.Impl
calls
Mycalls: {
Q_Spg : subprogram Ping_Spg;
};
connections
parameter Data_Sink -> Q_Spg.Data_Sink;
properties
Dispatch_Protocol => Sporadic;
Period => 10 Ms;
deadline => 10 Ms;
Priority => 1;
end Q.Impl;
thread implementation Q.Impl
calls
Mycalls: {
Q_Spg : subprogram Ping_Spg;
};
connections
parameter Data_Sink -> Q_Spg.Data_Sink;
properties
Dispatch_Protocol => Sporadic;
Period => 10 Ms;
deadline => 10 Ms;
Priority => 1;
end Q.Impl;
end Software;
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