Commit 73862991 authored by Maxime Perrotin's avatar Maxime Perrotin

Add documentation and example of a custom POHIC driver

step by step explanations to add a user-written POHIC communication
driver.
parent f3e865bc
1) edit ocarina_components.aadl and look for this pattern:
--------------------------------------------------
-- USB BRICK (STAR DUNDEE) DEVICE FOR SPACEWIRE --
--------------------------------------------------
2) below this section, add the following to declare the 2 new drivers for two SPW ports:
---------------------------------------------------
-- CUSTOM DRIVER TO SIMULATE SPW PORT A OF GR740 --
---------------------------------------------------
device gr740_spw_a
features
link : requires bus access ocarina_buses::spacewire.generic;
end gr740_spw_a;
device implementation gr740_spw_a.pohic
properties
Deployment::Driver_Name => "gr740_spw_a";
Device_Driver => classifier (ocarina_drivers_gr740_spw_a::driver.gr740_spw_a);
Initialize_Entrypoint => classifier (ocarina_drivers_gr740_spw_a::spw_a_init);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end gr740_spw_a.pohic;
---------------------------------------------------
-- CUSTOM DRIVER TO SIMULATE SPW PORT B OF GR740 --
---------------------------------------------------
device gr740_spw_b
features
link : requires bus access ocarina_buses::spacewire.generic;
end gr740_spw_b;
device implementation gr740_spw_b.pohic
properties
Deployment::Driver_Name => "gr740_spw_b";
Device_Driver => classifier (ocarina_drivers_gr740_spw_b::driver.gr740_spw_b);
Initialize_Entrypoint => classifier (ocarina_drivers_gr740_spw_b::spw_b_init);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end gr740_spw_b.pohic;
!!pay attention to the Driver_Name!!
we have to define the devices in packages named "ocarina_drivers_gr740_spw_a / b"
3) look for that pattern in the file:
with ocarina_drivers_star_dundee_spacewire_brick;
4) just below, add:
with ocarina_drivers_gr740_spw_a;
with ocarina_drivers_gr740_spw_b;
5) look for that pattern:
package ocarina_drivers_star_dundee_spacewire_brick
6) below that patten section, add:
package ocarina_drivers_gr740_spw_a
public
with ocarina_buses;
with Deployment;
subprogram spw_a_poller
properties
Source_Language => (C);
Source_Name => "__po_hi_c_driver_gr740_spw_a_poller";
end spw_a_poller;
subprogram spw_a_sender
properties
Source_Language => (C);
Source_Name => "__po_hi_c_driver_gr740_spw_a_sender";
end spw_a_sender;
subprogram spw_a_init
properties
Source_Language => (C);
Source_Name => "__po_hi_c_driver_gr740_spw_a_init";
end spw_a_init;
thread thr_poller
end thr_poller;
thread implementation thr_poller.i
calls
mycall : {
pspg : subprogram spw_a_poller;
};
properties
Period => 1000ms;
Dispatch_Protocol => Periodic;
end thr_poller.i;
abstract driver
properties
Deployment::Version => "0.1beta";
Deployment::Help => "Write your ASN.1 configuration here";
Deployment::Configuration_Type => classifier (ocarina_drivers::configuration_type_spacewire);
end driver;
abstract implementation driver.gr740_spw_a
subcomponents
receiver_rasta_spacewire : thread thr_poller.i;
sender : subprogram spw_a_sender;
end driver.gr740_spw_a;
end ocarina_drivers_gr740_spw_a;
package ocarina_drivers_gr740_spw_b
public
with ocarina_buses;
with Deployment;
subprogram spw_b_poller
properties
Source_Language => (C);
Source_Name => "__po_hi_c_driver_gr740_spw_b_poller";
end spw_b_poller;
subprogram spw_b_sender
properties
Source_Language => (C);
Source_Name => "__po_hi_c_driver_gr740_spw_b_sender";
end spw_b_sender;
subprogram spw_b_init
properties
Source_Language => (C);
Source_Name => "__po_hi_c_driver_gr740_spw_b_init";
end spw_b_init;
thread thr_poller
end thr_poller;
thread implementation thr_poller.i
calls
mycall : {
pspg : subprogram spw_b_poller;
};
properties
Period => 1000ms;
Dispatch_Protocol => Periodic;
end thr_poller.i;
abstract driver
properties
Deployment::Version => "0.1beta";
Deployment::Help => "Write your ASN.1 configuration here";
Deployment::Configuration_Type => classifier (ocarina_drivers::configuration_type_spacewire);
end driver;
abstract implementation driver.gr740_spw_b
subcomponents
receiver_rasta_spacewire : thread thr_poller.i;
sender : subprogram spw_b_sender;
end driver.gr740_spw_b;
end ocarina_drivers_gr740_spw_b;
6) for the moment note this line:
Deployment::Configuration_Type => classifier (ocarina_drivers::configuration_type_spacewire);
It is defined in the file like this:
data configuration_type_spacewire
properties
Type_Source_Name => "Spacewire-Conf-T";
Deployment::ASN1_Module_Name => "POHICDRIVER-SPACEWIRE";
Source_Language => (ASN1);
Source_Text => ("/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/src/drivers/configuration/spacewire.asn", "drivers/configuration/spacewire.h");
end configuration_type_spacewire;
This can be modified to add a custom type for the configuration of our device ...
7) go to ~/tool-src/polyorb-hi-c/src/drivers
Create (or copy from another driver) the C code of the driver
name of the file: po_hi_driver_gr740_spw_a.c
// The following pattern is __PO_HI_NEED_DRIVER_<Driver_Name>
// the Driver_Name is in the AADL file (Deployment::Driver_Name)
// Then the definition will be done in deployment.h automatically
#ifdef __PO_HI_NEED_DRIVER_GR740_SPW_A
8) go to ~/tool-src/polyorb-hi-c/include/drivers
Create (or copy from another driver) the include file of the driver
name of the file: po_hi_driver_gr740_spw_a.h
9) The drivers must be copied to:
/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/include/drivers/ (.h files)
and
/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/src/drivers (.c files)
This is normally done by the Makefile in pohic/src/drivers
the following two files must be completed with the new driver names (.c and .o):
Makefile.common.in in tool-src/polyorb-hi-c/share/make (add the .o)
Makefile.am in tool-srtc/polyorb-hi-c/src/drivers (add the .c)
package ocarina_buses
public
bus generic_bus
end generic_bus;
bus implementation generic_bus.i
end generic_bus.i;
bus dummy_bus
end dummy_bus;
bus implementation dummy_bus.i
end dummy_bus.i;
bus ip
end ip;
bus implementation ip.pohic
end ip.pohic;
bus implementation ip.i
subcomponents
asn : virtual bus asn1.i;
pohic : virtual bus pohi.c;
pohiada : virtual bus pohi.ada;
end ip.i;
bus implementation ip.pohiada
end ip.pohiada;
bus spacewire
end spacewire;
bus implementation spacewire.generic
end spacewire.generic;
bus serial
end serial;
bus implementation serial.generic
end serial.generic;
----------------------
-- Virtual buses --
----------------------
virtual bus raw
end raw;
virtual bus implementation raw.i
end raw.i;
virtual bus asn1
end asn1;
virtual bus implementation asn1.i
end asn1.i;
virtual bus pohi
end pohi;
virtual bus implementation pohi.c
end pohi.c;
virtual bus implementation pohi.ada
end pohi.ada;
end ocarina_buses;
package ocarina_drivers
public
with deployment;
with ocarina_buses;
with Data_Model;
with Base_Types;
with ocarina_drivers_leon_serial;
with ocarina_drivers_rasta_1553;
with ocarina_drivers_rasta_serial;
with ocarina_drivers_rasta_spacewire;
with ocarina_drivers_rtems_ne2000;
with ocarina_drivers_star_dundee_spacewire_brick;
with ocarina_drivers_gr740_spw_a;
with ocarina_drivers_gr740_spw_b;
with ocarina_drivers_udp_exarm;
with ocarina_drivers_serial;
with ocarina_drivers_ip_pohic;
with ocarina_drivers_exarm_ni_6071e_analog;
with ocarina_drivers_exarm_ni_6071e_digital;
with ocarina_drivers_generic_keyboard;
with GRUART;
with GRSPW;
with Native_UART;
with TCP_IP_Protocol;
------------------------
-- Configuration Type --
------------------------
data configuration_type_ip
properties
Type_Source_Name => "IP-Conf-T";
Deployment::ASN1_Module_Name => "POHICDRIVER-IP";
Source_Language => (ASN1);
Source_Text => ("/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/src/drivers/configuration/ip.asn" , "drivers/configuration/ip.h");
end configuration_type_ip;
data configuration_type_serial
properties
Type_Source_Name => "Serial-Conf-T";
Deployment::ASN1_Module_Name => "POHICDRIVER-UART";
Source_Language => (ASN1);
Source_Text => ("/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/src/drivers/configuration/serial.asn", "drivers/configuration/serial.h");
end configuration_type_serial;
data configuration_type_spacewire
properties
Type_Source_Name => "Spacewire-Conf-T";
Deployment::ASN1_Module_Name => "POHICDRIVER-SPACEWIRE";
Source_Language => (ASN1);
Source_Text => ("/home/taste/tool-inst/include/ocarina/runtime/polyorb-hi-c/src/drivers/configuration/spacewire.asn", "drivers/configuration/spacewire.h");
end configuration_type_spacewire;
--------------
-- Keyboard --
--------------
device generic_keyboard
features
key_pressed : out data port Base_Types::Character;
properties
Deployment::Driver_Name => "generic_keyboard";
Device_Driver => classifier (ocarina_drivers_generic_keyboard::generic_keyboard_driver.i);
Initialize_Entrypoint => classifier (ocarina_drivers_generic_keyboard::spg_generic_keyboard_init);
end generic_keyboard;
device implementation generic_keyboard.linux
end generic_keyboard.linux;
-------------------
-- LEON ETHERNET --
-------------------
device leon_ethernet
features
link : requires bus access ocarina_buses::ip.i;
end leon_ethernet;
device implementation leon_ethernet.raw
properties
Deployment::Driver_Name => "eth_leon";
Device_Driver => classifier (ocarina_drivers_leon_eth::eth_driver.leon);
Initialize_Entrypoint => classifier (ocarina_drivers_leon_eth::spg_leon_eth_init);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end leon_ethernet.raw;
------------------
-- RASTA SERIAL --
------------------
device leon_serial
features
link : requires bus access ocarina_buses::serial.generic;
end leon_serial;
device implementation leon_serial.raw
properties
Deployment::Driver_Name => "serial_leon";
Device_Driver => classifier (ocarina_drivers_leon_serial::serial_driver.leon);
Initialize_Entrypoint => classifier (ocarina_drivers_leon_serial::spg_serial_init_leon);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::raw.i));
end leon_serial.raw;
device implementation leon_serial.raw_sender
properties
Deployment::Driver_Name => "serial_leon_sender";
Device_Driver => classifier (ocarina_drivers_leon_serial::serial_driver.leon_sender);
Initialize_Entrypoint => classifier (ocarina_drivers_leon_serial::spg_serial_init_leon_sender);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::raw.i));
end leon_serial.raw_sender;
----------------
-- RASTA 1553 --
----------------
device rasta_1553
end rasta_1553;
device implementation rasta_1553.terminal
properties
Deployment::Driver_Name => "1553_rasta";
Device_Driver => classifier (ocarina_drivers_rasta_1553::if1553_driver.rasta_terminal);
Initialize_Entrypoint => classifier (ocarina_drivers_rasta_1553::spg_1553_init_rasta_terminal);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end rasta_1553.terminal;
device implementation rasta_1553.controller_sender_only
properties
Deployment::Driver_Name => "1553_rasta";
Device_Driver => classifier (ocarina_drivers_rasta_1553::if1553_driver.rasta_controller_sender_only);
Initialize_Entrypoint => classifier (ocarina_drivers_rasta_1553::spg_1553_init_rasta_controller);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end rasta_1553.controller_sender_only;
------------------
-- RASTA SERIAL --
------------------
device rasta_serial
features
link : requires bus access ocarina_buses::serial.generic;
end rasta_serial;
device implementation rasta_serial.raw
properties
Deployment::Driver_Name => "serial_rasta";
Device_Driver => classifier (ocarina_drivers_rasta_serial::serial_driver.rasta);
Initialize_Entrypoint => classifier (ocarina_drivers_rasta_serial::spg_serial_init_rasta);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::raw.i));
end rasta_serial.raw;
device implementation rasta_serial.pohiada
properties
Deployment::Driver_Name => "serial_rasta";
Device_Driver => classifier (GRUART::Driver_GRUART_Protocol.impl);
Initialize_Entrypoint => classifier (GRUART::Initialize);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::raw.i));
end rasta_serial.pohiada;
--------------------------------------------------
-- USB BRICK (STAR DUNDEE) DEVICE FOR SPACEWIRE --
--------------------------------------------------
device usb_brick_spacewire
features
link : requires bus access ocarina_buses::spacewire.generic;
end usb_brick_spacewire;
device implementation usb_brick_spacewire.pohic
properties
Deployment::Driver_Name => "spacewire_usb_brick";
Device_Driver => classifier (ocarina_drivers_star_dundee_spacewire_brick::driver.usb_brick);
Initialize_Entrypoint => classifier (ocarina_drivers_star_dundee_spacewire_brick::spg_init);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end usb_brick_spacewire.pohic;
---------------------------------------------------
-- CUSTOM DRIVER TO SIMULATE SPW PORT A OF GR740 --
---------------------------------------------------
device gr740_spw_a
features
link : requires bus access ocarina_buses::spacewire.generic;
end gr740_spw_a;
device implementation gr740_spw_a.pohic
properties
Deployment::Driver_Name => "gr740_spw_a";
Device_Driver => classifier (ocarina_drivers_gr740_spw_a::driver.gr740_spw_a);
Initialize_Entrypoint => classifier (ocarina_drivers_gr740_spw_a::spw_a_init);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end gr740_spw_a.pohic;
---------------------------------------------------
-- CUSTOM DRIVER TO SIMULATE SPW PORT B OF GR740 --
---------------------------------------------------
device gr740_spw_b
features
link : requires bus access ocarina_buses::spacewire.generic;
end gr740_spw_b;
device implementation gr740_spw_b.pohic
properties
Deployment::Driver_Name => "gr740_spw_b";
Device_Driver => classifier (ocarina_drivers_gr740_spw_b::driver.gr740_spw_b);
Initialize_Entrypoint => classifier (ocarina_drivers_gr740_spw_b::spw_b_init);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end gr740_spw_b.pohic;
---------------------
-- RASTA SPACEWIRE --
---------------------
device rasta_spacewire
features
link : requires bus access ocarina_buses::spacewire.generic;
end rasta_spacewire;
device implementation rasta_spacewire.pohic
properties
Deployment::Driver_Name => "spacewire_rasta";
Device_Driver => classifier (ocarina_drivers_rasta_spacewire::spacewire_driver.rasta);
Initialize_Entrypoint => classifier (ocarina_drivers_rasta_spacewire::spg_spacewire_init_rasta);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end rasta_spacewire.pohic;
device implementation rasta_spacewire.pohiada
properties
Deployment::Driver_Name => "spacewire_rasta";
Device_Driver => classifier (GRSPW::Driver_GRSPW_Protocol.impl);
Initialize_Entrypoint => classifier (GRSPW::Initialize);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end rasta_spacewire.pohiada;
---------------------
-- SCOC3 SPACEWIRE --
---------------------
device scoc3_spacewire
features
link : requires bus access ocarina_buses::spacewire.generic;
end scoc3_spacewire;
device implementation scoc3_spacewire.pohic
properties
Deployment::Driver_Name => "spacewire_scoc3";
Device_Driver => classifier (ocarina_drivers_scoc3_spacewire::driver.i);
Initialize_Entrypoint => classifier (ocarina_drivers_scoc3_spacewire::spg_init);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end scoc3_spacewire.pohic;
---------------------------
-- Generic serial driver --
---------------------------
device generic_serial
features
link : requires bus access ocarina_buses::serial.generic;
end generic_serial;
device implementation generic_serial.raw
properties
Deployment::Driver_Name => "serial_linux";
Device_Driver => classifier (ocarina_drivers_serial::serial_driver.linux);
Initialize_Entrypoint => classifier (ocarina_drivers_serial::spg_serial_init_linux);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::raw.i));
end generic_serial.raw;
device implementation generic_serial.pohiada
properties
Deployment::Driver_Name => "serial_linux";
Device_Driver =>
classifier (Native_UART::Driver_Native_UART_Protocol.impl);
Initialize_Entrypoint => classifier (Native_UART::Initialize);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::raw.i));
end generic_serial.pohiada;
device implementation generic_serial.raw_sender
properties
Deployment::Driver_Name => "serial_linux_sender";
Device_Driver => classifier (ocarina_drivers_serial::serial_driver.linux_sender);
Initialize_Entrypoint => classifier (ocarina_drivers_serial::spg_serial_init_linux_sender);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::raw.i));
end generic_serial.raw_sender;
device implementation generic_serial.raw_receiver
properties
Deployment::Driver_Name => "serial_linux_receiver";
Device_Driver => classifier (ocarina_drivers_serial::serial_driver.linux_receiver);
Initialize_Entrypoint => classifier (ocarina_drivers_serial::spg_serial_init_linux_receiver);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::raw.i));
end generic_serial.raw_receiver;
-------------------------------
-- Generic sockets/ip driver --
-------------------------------
device generic_sockets_ip
features
link : requires bus access ocarina_buses::ip.i;
end generic_sockets_ip;
device implementation generic_sockets_ip.pohic
properties
Deployment::Driver_Name => "sockets";
Device_Driver => classifier (ocarina_drivers_ip_pohic::sockets_impl.i);
Initialize_Entrypoint => classifier (ocarina_drivers_ip_pohic::spg_sockets_init);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end generic_sockets_ip.pohic;
device implementation generic_sockets_ip.pohiada
properties
Deployment::Driver_Name => "socketsnew";
Device_Driver => classifier (TCP_IP_Protocol::Driver_TCP_IP_Protocol.impl);
Initialize_Entrypoint => classifier (TCP_IP_Protocol::Initialize);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end generic_sockets_ip.pohiada;
------------------
-- RTEMS NE2000 --
------------------
device rtems_ne2000
features
link : requires bus access ocarina_buses::ip.i;
end rtems_ne2000;
device implementation rtems_ne2000.ip_pohic
properties
Deployment::Driver_Name => "rtems_ne2000_sockets";
Device_Driver => classifier (ocarina_drivers_rtems_ne2000::driver.i);
Initialize_Entrypoint => classifier (ocarina_drivers_rtems_ne2000::init);
Provided_Virtual_Bus_Class => (classifier (ocarina_buses::pohi.c));
end rtems_ne2000.ip_pohic;
------------------------------------------
-- Exarm UDP driver --
------------------------------------------
-- This driver is used to communicate --
-- with the exarm robot and also --
-- the Matlab simulator. --
------------------------------------------
device exarm_ip
features
link : requires bus access ocarina_buses::ip.i;
end exarm_ip;
device implementation exarm_ip.vr_udp
properties
Deployment::Driver_Name => "exarm";
Device_Driver => classifier (ocarina_drivers_udp_exarm::driver.i);
Initialize_Entrypoint => classifier (ocarina_drivers_udp_exarm::init);
end exarm_ip.vr_udp;
data exarm_protocol_data
end exarm_protocol_data;
data implementation exarm_protocol_data.vr extends ocarina_drivers_udp_exarm::protocol.vr
properties
Data_Model::Data_Representation => Struct;
end exarm_protocol_data.vr;
data implementation exarm_protocol_data.robot extends ocarina_drivers_udp_exarm::protocol.robot
properties
Data_Model::Data_Representation => Struct;