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