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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
#! /bin/bash
###########################################################################
# @licence app begin@
# SPDX-License-Identifier: MPL-2.0
#
# \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen
#
# \file run
#
# \brief This file is part of the Build System.
#
# \author # Author: Martin Schaller <martin.schaller@it-schaller.de>
#
# \version 1.0
#
# This Source Code Form is subject to the terms of the
# Mozilla Public License (MPL), v. 2.0.
# If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# For further information see http://www.genivi.org/.
#
# List of changes:
#
# 5-8-2014, Philippe Colliot, Refine, add a sleep and improve comments
# 30-9-2014, Philippe Colliot, Make it simpler and add a check for availability of hmi style-sheets
#
# @licence end@
###########################################################################
# function to start a process by freezing some of the options
function run
{
local x=$xterm
local g=$gdb
local l=$log
local title="$1"
shift
if [ "$1" = "-n" ]
then
shift
x=0
log=0
fi
if [ "$1" = -"g" ]
then
shift
g=0
fi
if [ "$x" = 1 ]
then
if [ "$g" = 1 ]
then
set -- gdb -ex run --args "$@"
fi
xterm -T "$title" -sb -sl 5000 -e "$@" &
elif [ "$log" = 1 ]
then
"$@" >"$CUR_DIR/$title.log" 2>&1 &
else
"$@" &
fi
PIDS="$PIDS $!"
}
# function to wait for the dbus service to be started, exit if too long
function wait_for_service
{
for i in $(seq 1 50)
do
if dbus-send --dest=$1 $2 org.freedesktop.DBus.Introspectable.Introspect
then
return
fi
echo "Waiting for $1"
sleep 0.1
done
exit 1
}
# function to catch the ctrl C or exit and to stop cleanly
function terminate
{
set +e
trap "" EXIT INT
kill $PIDS 2>/dev/null
if [ "$gdb" = 1 ]
then
kill -9 $PIDS 2>/dev/null
fi
if [ -n "$wm" ]
then
sleep 2
cd
nohup $wm >/dev/null 2>/dev/null &
fi
}
# default settings
gdb=0 #no debug
xterm=0 #no subprocess into a separate xterm
log=0 #no log file
enhpos=1 #enhanced position server enabled
replayer=1 #replayer enabled
gateway=0 #vehicle gateway disabled
lm=0 #layer manager disabled
wm="" #to store the current window manager (in case of start with the layer manager)
verbose=0 #no debug or log messages displayed
center="4612 N 0608 E" #geneva
config_file=fsa_switzerland.conf #switzerland settings
persistent=0 #reuse of persistent data disabled
CUR_DIR=$PWD
BIN_DIR=$CUR_DIR/build
SRC_DIR=$CUR_DIR
SCRIPT_DIR=$SRC_DIR/script
HMI_DIR=$SRC_DIR/hmi
app=$HMI_DIR/qml/NavigationApp.qml # hmi panel launched by default
STYLE_SHEETS_GENERATED_INDICATOR=$HMI_DIR/style-sheets/the-style-sheets-have-been-generated-css.js
CONFIG_DIR=$HMI_DIR/config
REPLAYER_LOG_FILE=none
export REPLAYER_LOG_FILE
# location of exe, lib and config files
AUTOMOTIVE_MESSAGE_BROKER=automotive-message-broker
AUTOMOTIVE_MESSAGE_BROKER_SRC_DIR=$SRC_DIR/$AUTOMOTIVE_MESSAGE_BROKER
AUTOMOTIVE_MESSAGE_BROKER_BIN_DIR=$AUTOMOTIVE_MESSAGE_BROKER_SRC_DIR/src/$AUTOMOTIVE_MESSAGE_BROKER-build
GENIVI_LOGREPLAYER=genivilogreplayer
GENIVI_LOGREPLAYER_SRC_DIR=$SRC_DIR/$GENIVI_LOGREPLAYER
GENIVI_LOGREPLAYER_BIN_DIR=$BIN_DIR/$GENIVI_LOGREPLAYER
NAVIGATION=navigation
NAVIGATION_SRC_DIR=$SRC_DIR/$NAVIGATION/src/navigation
NAVIGATION_BIN_DIR=$BIN_DIR/$NAVIGATION
NAVIT=navit
NAVIT_BIN_DIR=$NAVIGATION_BIN_DIR/navit/navit
POI_SERVER=poi-server
POI_SERVER_SRC_DIR=$SRC_DIR/$NAVIGATION/src/poi-service/$POI_SERVER
POI_SERVER_BIN_DIR=$SRC_DIR/$NAVIGATION/src/poi-service/bin
POI_SERVER_RESOURCE_DIR=$SRC_DIR/$NAVIGATION/src/poi-service/resource
poidatabase=$POI_SERVER_RESOURCE_DIR/empty.db # empty poi database by default
LOG_REPLAYER=log-replayer
LOG_REPLAYER_SRC_DIR=$NAVIGATION_SRC_DIR/positioning/$LOG_REPLAYER
LOG_REPLAYER_BIN_DIR=$NAVIGATION_SRC_DIR/bin
ENHANCED_POSITION_SERVICE=enhanced-position-service
ENHANCED_POSITION_SERVICE_SRC_DIR=$NAVIGATION_SRC_DIR/positioning/$ENHANCED_POSITION_SERVICE
ENHANCED_POSITION_SERVICE_BIN_DIR=$NAVIGATION_SRC_DIR/bin
FUEL_STOP_ADVISOR=fuel-stop-advisor
FUEL_STOP_ADVISOR_SRC_DIR=$SRC_DIR/$FUEL_STOP_ADVISOR
FUEL_STOP_ADVISOR_BIN_DIR=$BIN_DIR/$FUEL_STOP_ADVISOR
HMI_LAUNCHER=hmi-launcher
HMI_LAUNCHER_SRC_DIR=$SRC_DIR/hmi/$HMI_LAUNCHER
HMI_LAUNCHER_BIN_DIR=$BIN_DIR/hmi/$HMI_LAUNCHER
VEHICLE_GATEWAY=vehicle-gateway
VEHICLE_GATEWAY_SRC_DIR=$SRC_DIR/$VEHICLE_GATEWAY
VEHICLE_GATEWAY_BIN_DIR=$BIN_DIR/$VEHICLE_GATEWAY
devices="/dev/ttyUSB0 /dev/ttyACM0"
# options analysis
while getopts a:c:df:g:hlnoprvx opt
do
case $opt in
a) #select another hmi panel
app=$(readlink -f $OPTARG)
;;
c) #set the map center
case "$OPTARG" in
paris)
center="2.34 48.84"
config_file=fsa_paris.conf
;;
tokyo)
center="139.74 35.70"
config_file=fsa_tokyo.conf
;;
london)
center="-0.13 51.51"
config_file=fsa_london.conf
;;
seoul)
center="126.99 37.54"
config_file=fsa_seoul.conf
;;
[0-9-]*)
center=$OPTARG
;;
*)
echo "Unsupported center $OPTARG" >&2
exit 1
;;
esac
;;
d) #enable the debugger
gdb=1
;;
f) #load another poi database
poidatabase=$(readlink -f $OPTARG)
;;
g) #enable the vehicle gateway
gateway=1
devices=$OPTARG
;;
l) #enable the layer manager
lm=1
;;
n) #disable the enhanced position server
enhpos=0
;;
o) #enable the log file
log=1
;;
p) #enable the reuse of persistent data
persistent=1
;;
r) #disable the log replayer
replayer=0
;;
v) #enable log messages
verbose=1
;;
x) #enable subprocess in a separate xterm
xterm=1
;;
h)
echo "Usage:"
echo "$0 [-a application][-c center][-ghlnoprvx]"
echo "-a: Set application (default application.qml)"
echo "-c: Set center (supported values: paris,tokyo,london,seoul,longitude latitude). Default is geneve"
echo "-d: Run subprocesses within gdb (only with -x)"
echo "-f: Load another database (for poi)"
echo "-g: Run the vehicle gateway (only with -r) -g \"<ELM327device> <GNSSdevice>\""
echo "-h: Help"
echo "-l: Use layermanager"
echo "-n: Don't start enhanced positioning service"
echo "-o: Create log file of subprocess output"
echo "-p: Reuse of persistent data (i.e. in $HOME, so don't reinit it with default file)"
echo "-r: Don't start replayer"
echo "-v: Enable the output of log or debug messages"
echo "-x: Run subprocesses in own xterm to get separated log messages (doesn't make sense with -l)"
exit 1
esac
done
# check if style sheets have been generated
if [ ! -f $STYLE_SHEETS_GENERATED_INDICATOR ]
then
echo "Please generate the style sheets before"
$SCRIPT_DIR/prepare.sh -h
exit 1
fi
# check and kill remaining ambd process
ambd_process_id=$(pidof ambd)
if [ -n $ambd_process_id ]
then
kill -9 $ambd_process_id
fi
trap "terminate" EXIT INT
set -e #exit on error now
echo "the graphic for navit is based on sdl"
export NAVIT_GRAPHICS='sdl'
# set the language to en_US for navit
export LANGUAGE=en_US
if [ "$persistent" = 0 ]
then
if [ ! -d $HOME"/.config/navigation" ]
then
mkdir -p $HOME/.config
mkdir $HOME/.config/navigation
fi
# reinit the config file for Qt (persistent data)
cp $CONFIG_DIR/$config_file $HOME/.config/navigation/fsa.conf
fi
# start the automotive message broker and wait for dbus service
cd $AUTOMOTIVE_MESSAGE_BROKER_BIN_DIR
if [ "$verbose" = "1" ]
then
run "Automotive Message Broker" ./ambd/ambd --config $GENIVI_LOGREPLAYER_SRC_DIR/logreplayerconfig.in.json
else
run "Automotive Message Broker" ./ambd/ambd > /dev/null 2>&1 --config $GENIVI_LOGREPLAYER_SRC_DIR/logreplayerconfig.in.json
fi
wait_for_service org.automotive.message.broker /
# start the poi server and wait for dbus service
run "POI service" $POI_SERVER_BIN_DIR/$POI_SERVER -f $poidatabase
wait_for_service org.genivi.poiservice.POISearch /org/genivi/poiservice/POISearch
if [ "$enhpos" = 1 ]
then # start the enhanced position service
run "EnhancedPositionService" $ENHANCED_POSITION_SERVICE_BIN_DIR/$ENHANCED_POSITION_SERVICE
wait_for_service org.genivi.positioning.EnhancedPosition /org/genivi/positioning/EnhancedPosition
fi
# start the two instances of navit with plugins (one for navigation core and another one for map viewer)
cd $NAVIT_BIN_DIR
>bookmark.txt
echo "$center" >center.txt
if [ "$verbose" = "1" ]
then
run "MapViewer" ./$NAVIT -d 3 -c navit_genivi_mapviewer.xml
else
run "MapViewer" ./$NAVIT -d 0 -c navit_genivi_mapviewer.xml 2>~/mapviewer.log
fi
wait_for_service org.genivi.mapviewer.Configuration /org/genivi/mapviewer
wait_for_service org.genivi.mapviewer.MapViewerControl /org/genivi/mapviewer
wait_for_service org.genivi.mapviewer.Session /org/genivi/mapviewer
if [ "$verbose" = "1" ]
then
run "NavigationCore" ./$NAVIT -d 3 -c navit_genivi_navigationcore.xml
else
run "NavigationCore" ./$NAVIT -d 0 -c navit_genivi_navigationcore.xml
fi
wait_for_service org.genivi.navigationcore.Configuration /org/genivi/navigationcore
wait_for_service org.genivi.navigationcore.Guidance /org/genivi/navigationcore
wait_for_service org.genivi.navigationcore.LocationInput /org/genivi/navigationcore
wait_for_service org.genivi.navigationcore.MapMatchedPosition /org/genivi/navigationcore
wait_for_service org.genivi.navigationcore.Routing /org/genivi/navigationcore
wait_for_service org.genivi.navigationcore.Session /org/genivi/navigationcore
if [ "$replayer" = 1 ]
then # start the log replayer (of the fsa) with a sample log file
run "Log Replayer" $LOG_REPLAYER_BIN_DIR/$LOG_REPLAYER $LOG_REPLAYER_SRC_DIR/logs/geneve-cologny.log
else
if [ "$gateway" = 1 ]
then
run "Vehicle gateway" $VEHICLE_GATEWAY_BIN_DIR/$VEHICLE_GATEWAY $devices
fi
fi
sleep 3 # need a sleep here (to be improved)
# start the fuel stop advisor application
run "Fuel Stop Advisor" $FUEL_STOP_ADVISOR_BIN_DIR/$FUEL_STOP_ADVISOR
# log trace into a file
if [ "$log" = 1 ]
then
exec >$CUR_DIR/fsa.log
exec 2>&1
fi
# start the hmi
$HMI_LAUNCHER_BIN_DIR/$HMI_LAUNCHER $app
|