Kick-starting
MARTe offers a generic application loader (see MARTeApp.cpp), that should be sufficiently generic for most use-cases.
The MARTeApp
uses a portable Bootstrap to read the input parameters and to setup the execution environment. The parameters expected by the Loaders (see the Configure method in Loader) can be hard-coded in the application specific Bootstrap
(embedded case) or can be read from the main argv
parameters using the Bootstrap::ReadParameters
method. With the configuration stream returned by the Bootstrap
, the Loader is used by the MARTeApp
to configure the application.
Upon a successful configuration, the MARTeApp
calls the Loader::Start
method. The standard implementation sends a Message to the destination specified in the configuration stream. The RealTimeLoader implementation, configures the RealTimeApplication (that is expected to exist in the configuration stream) and triggers the Start of the RealTimeApplication
(either with a Message or by changing to a state specified in the configuration stream).
The Bootstrap Run
method is then expected to lock until the application is terminated, upon which the Loader Stop
method is called.

The MARTeApp is used in the MARTeApp.sh script (see examples):
1#!/bin/bash
2#Arguments -l LOADER -f FILENAME -m MESSAGE | -s STATE [-d cgdb|strace]
3#-l LOADER=The Loader to use
4#-f FILENAME=MARTe configuration file
5#-m MESSAGE=Start message
6#-s STATE=RealTimeApplication first state
7#-d cgdb=Run with cgdb
8#-d strace=Run with strace
9
10#Run with cgdb or strace?
11DEBUG=""
12
13#Consume input arguments
14while [[ $# -gt 1 ]]
15do
16key="$1"
17
18case $key in
19 -l|--loader)
20 LOADER="$2"
21 shift # past argument
22 ;;
23 -f|--file)
24 FILE="$2"
25 shift # past argument
26 ;;
27 -m|--message)
28 MESSAGE="$2"
29 shift # past argument
30 ;;
31 -s|--state)
32 STATE="$2"
33 shift # past argument
34 ;;
35 -d|--debug)
36 DEBUG="$2"
37 shift # past argument
38 ;;
39 --default)
40 DEFAULT=YES
41 ;;
42 *)
43 # unknown option
44 ;;
45esac
46shift # past argument or value
47done
48
49if [ -z ${MARTe2_DIR+x} ]; then echo "Please set the MARTe2_DIR environment variable"; exit; fi
50if [ -z ${MARTe2_Components_DIR+x} ]; then echo "Please set the MARTe2_Components_DIR environment variable"; exit; fi
51
52LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
53LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../../../../../Build/x86-linux/Examples/Core/
54LD_LIBRARY_PATH=$LD_LIBRARY_PATH:Core/
55LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_DIR/Build/x86-linux/Core/
56LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/EPICSCA/
57LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/LinuxTimer/
58LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/LoggerDataSource/
59LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/DAN/
60LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/NI6259/
61LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/NI6368/
62LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/SDN/
63LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/UDP/
64LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/MDSWriter/
65LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/RealTimeThreadSynchronisation/
66LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/DataSources/FileDataSource/
67LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/GAMs/IOGAM/
68LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/GAMs/BaseLib2GAM/
69LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/GAMs/ConversionGAM/
70LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/GAMs/ConstantGAM/
71LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/GAMs/FilterGAM/
72LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/GAMs/HistogramGAM/
73LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/GAMs/MessageGAM/
74LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/GAMs/StatisticsGAM/
75LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/GAMs/WaveformGAM/
76LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/Interfaces/BaseLib2Wrapper/
77LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/Interfaces/SysLogger/
78LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MARTe2_Components_DIR/Build/x86-linux/Components/Interfaces/EPICS/
79
80echo $LD_LIBRARY_PATH
81export LD_LIBRARY_PATH=$LD_LIBRARY_PATH
82
83MARTeAPP=$MARTe2_DIR/Build/x86-linux/App/MARTeApp.ex
84
85#Start with cgdb or with strace
86if [ "$DEBUG" = "cgdb" ]
87then
88 if [ -z ${STATE+x} ]; then
89 cgdb --args $MARTeAPP -l $LOADER -f $FILE -m $MESSAGE
90 else
91 cgdb --args $MARTeAPP -l $LOADER -f $FILE -s $STATE
92 fi
93elif [ "$DEBUG" = "strace" ]
94then
95 if [ -z ${STATE+x} ]; then
96 strace -o/tmp/strace.err $MARTeAPP -l $LOADER -f $FILE -m $MESSAGE
97 else
98 strace -o/tmp/strace.err $MARTeAPP -l $LOADER -f $FILE -s $STATE
99 fi
100else
101 if [ -z ${STATE+x} ]; then
102 $MARTeAPP -l $LOADER -f $FILE -m $MESSAGE
103 else
104 $MARTeAPP -l $LOADER -f $FILE -s $STATE
105 fi
106fi