Step 2: In-vehicle Setup¶
- The in-vehicle environment here is Raspberry-Pi 4.
- To ease the complexity, a virtual CAN interface,
vcan0, is used here. Therefore you should follow CAN Interface Option 1 - Virtual CAN (Logfile Simulation Purpose) prior to this part.
can-utils¶
can-utilsis a Linux specific set of utilities that enables Linux to communicate with the CAN network on the vehicle. The basic tutorial can be found here.
Open a terminal and install
can-utils:$ sudo apt install can-utils
To test
can-utils, command the following in the same terminal:$ candump vcan0
candumpallows you to print all data that is being received by a CAN interface,vcan0, on the terminal.
Open another terminal and command the following:
$ cansend vcan0 7DF#DEADBEEF
cansendsends a CAN message,7DF#DEADBEEFto the corresponding CAN interface,vcan0.
Confirm whether
candumphas received the CAN message. You should be able to see output like the following on the previous terminal:vcan0 7DF [4] DE AD BE EF
kuksa.val Infrastructure¶
Install Git:
$ sudo apt install git
Recursively clone the
kuksa.valrepository:$ git clone --recursive https://github.com/eclipse/kuksa.val.git
Make a folder named
buildinside thekuksa.valrepository folder and navigate tokuksa.val/build/:$ cd kuksa.val $ mkdir build $ cd build
The following commands should be run before
cmaketo avoid possible errors.
4-1. Install cmake (version 3.12 or higher) if it hasn’t been installed:
$ sudo apt-get update && sudo apt-get upgrade
Raspberry-Pi:
$ sudo apt install cmake
Ubuntu:
$ sudo snap install cmake --classic
4-2. Install dependencies (Boost libraries, OpenSSL, Mosquitto and more):
$ sudo apt-get install libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev libssl-dev mosquitto libmosquitto-dev libglib2.0-dev
You can
cmakenow. Navigate tokuksa.val/build/and command the following:$ cmake ..
Then command
makein the same directory:$ make
If succeeded, you have successfully built the kuksa.val infrastructure.
kuksa.val - kuksa.val VSS Server Setup¶
- The
kuksa.valserver is built based on the Genivi VSS (Vehicle Signal Specification) data structure model. The VSS data structure is created according to the JSON file that is put into thekuksa-val-serverexecutable as an arugment under--vss(e.g.,vss_rel_2.0.json). Before we bring up and run thekuksa.valserver, we can create our own VSS data structure in the following steps.
1-1. Recursively clone the GENIVI/vehicle_signal_specification repository:
$ git clone --recurse-submodules https://github.com/GENIVI/vehicle_signal_specification.git
1-2. The name of the cloned repository folder is vehicle_signal_specification. Inside there is a Makefile that creates the VSS data structure according to vehicle_signal_specification/spec. Since we only need a JSON file as output, we can modify Makefile as follow:
#
# Makefile to generate specifications
#
.PHONY: clean all json
all: clean json
DESTDIR?=/usr/local
TOOLSDIR?=./vss-tools
DEPLOYDIR?=./docs-gen/static/releases/nightly
json:
${TOOLSDIR}/vspec2json.py -i:spec/VehicleSignalSpecification.id -I ./spec ./spec/VehicleSignalSpecification.vspec vss_rel_$$(cat VERSION).json
clean:
rm -f vss_rel_$$(cat VERSION).json
(cd ${TOOLSDIR}/vspec2c/; make clean)
install:
git submodule init
git submodule update
(cd ${TOOLSDIR}/; python3 setup.py install --install-scripts=${DESTDIR}/bin)
$(MAKE) DESTDIR=${DESTDIR} -C ${TOOLSDIR}/vspec2c install
install -d ${DESTDIR}/share/vss
(cd spec; cp -r * ${DESTDIR}/share/vss)
deploy:
if [ -d $(DEPLOYDIR) ]; then \
rm -f ${DEPLOYDIR}/vss_rel_*;\
else \
mkdir -p ${DEPLOYDIR}; \
fi;
cp vss_rel_* ${DEPLOYDIR}/
- Please note that it is recommended to modify the file manually since
Makefileistab-sensitive.
1-3. Now we can replace the vehicle_signal_specification/spec folder with the modified folder. To get the modified spec folder, clone the junh-ki/dias_kuksa repository:
$ git clone https://github.com/junh-ki/dias_kuksa.git
1-4. In the directory, dias_kuksa/utils/in-vehicle/vss_structure_example/, the spec folder can be found. Replace the existing spec folder in vehicle_signal_specification/ with the one from dias_kuksa/utils/in-vehicle/vss_structure_example/. Designing the spec folder’s file structure can be easily self-explained. The following figure illustrates what the GENIVI data structure would look like when created with the spec folder.
- By modifying the structure of
specfolder, a user-specific GENIVI data structure can be created that can be fed ontokuksa-val-server.
1-5. Before commanding make, install python dependencies (anytree, deprecation, stringcase) first:
$ sudo apt install python3-pip
$ pip3 install anytree deprecation stringcase pyyaml
1-6. Navigate to the directory, vehicle_signal_specification/, and command make to create a new JSON file:
$ make
1-7. As a result, you can get a JSON file named as vss_rel_2.0.0-alpha+006.json. Let’s rename this file as modified.json for convenience and move it to kuksa.val/build/src/, where the kuksa-val-server executable file is located.
Now we can bring up and run the
kuksa.valserver withmodified.json. Navigate to the directory,kuksa.val/build/src/, and command the following:$ ./kuksa-val-server --vss modified.json --insecure --log-level ALL
- The
kuksa.valserver is entirely passive. Which means that you would need supplementary applications to feed and fetch the data.dbcfeeder.pyandcloudfeeder.pyare introduced in the following contents. They are meant to deal with setting and getting the data from thekuksa.valserver.
kuksa.val - dbcfeeder.py Setup¶
kuksa.val/examples/dbc2val/dbcfeeder.py is to interpret and write the CAN data that is being received by the CAN interface (e.g., can0 or vcan0) to the kuksa.val server.
dbcfeeder.pytakes four compulsory arguments to be run:- CAN interface (e.g.,
can0orvcan0) /-dor--device/ To connect to the CAN device interface. - JSON token (e.g.,
super-admin.json.token) /-jor--jwt/ To have write-access to the server. - DBC file (e.g.,
dbcfile.dbc) /--dbc/ To translate the raw CAN data. - Mapping YML file (e.g.,
mapping.yml) /--mapping/ To map each of the specific signals to the corresponding path in thekuksa.valserver.
- CAN interface (e.g.,
- Since the
kuksa.valwork package has the admin JSON token already, you only need a DBC file and a YML file. Thejunh-ki/dias_kuksarepository provides the example DBC file and YML file. (DBC file is target-vehicle-specific and can be offered by the target vehicle’s manufacturer.)
Assuming you have already cloned the
junh-ki/dias_kuksarepository, / If you haven’t, please clone it now:$ git clone https://github.com/junh-ki/dias_kuksa.git
Navigate to the directory,
dias_kuksa/utils/in-vehicle/dbcfeeder_example_arguments/, and copydias_mapping.ymlanddias_simple.dbc(omitted due to the copyright issue and thus shared on request) tokuksa.val/clients/feeder/dbc2val/wheredbcfeeder.pyis located.Before running
dbcfeeder.py, install python dependencies (python-can cantools serial) first:$ pip3 install python-can cantools serial websockets
If you haven’t brought up a virtual CAN interface,
vcan0, please do it now by following CAN Interface Option 1 - Virtual CAN (Logfile Simulation Purpose).Navigate to
kuksa.val/clients/feeder/dbc2val/, and command the following:$ python3 dbcfeeder.py -d vcan0 -j ../../../certificates/jwt/super-admin.json.token --dbc dias_simple.dbc --mapping dias_mapping.yml
(Optional) If your DBC file follows J1939 standard, please follow Running dbcfeeder.py with j1939reader.py to run
dbcfeeder.pywith J1939.
kuksa.val - cloudfeeder.py Setup¶
dias_kuksa/utils/in-vehicle/cloudfeeder_telemetry/cloudfeeder.pyfetches the data from thekuksa.valin-vehicle server and preprocesses it with a user-specific preprocessor,dias_kuksa/utils/in-vehicle/cloudfeeder_telemetry/preprocessor_bosch.py, and transmits the result to Hono (kuksa.cloud - Eclipse Hono (Cloud Entry)) in a form of JSON Dictionary.cloudfeeder.pytakes six compulsory arguments to be run:- JSON token (e.g.,
super-admin.json.token) /-jor--jwt/ To have write-access to the server. - Host URL (e.g., “mqtt.bosch-iot-hub.com”) /
--host - Protocol Port Number (e.g., “8883”) /
-por--port - Credential Authorization Username (Configured when creating) (e.g., “{username}@{tenant-id}”) /
-uor--username - Credential Authorization Password (Configured when creating) (e,g., “your_pw”)/
-Por--password - Server Certificate File (MQTT TLS Encryption) (e.g., “iothub.crt”) /
-cor--cafile - Data Type (e.g., “telemetry” or “event”) / “-t” or “–type”
- Host URL (e.g., “mqtt.bosch-iot-hub.com”) /
- JSON token (e.g.,
- (Optional)
preprocessor_bosch.pyis designed to follow Bosch’s diagnostic methodologies. Therefore you can create your ownpreprocessor_xxx.pyor modifypreprocessor_example.pythat replacespreprocessor_bosch.pyto follow your own purpose. Of course, the corresponding lines incloudfeeder.pyshould be modified as well in this case. - Navigate to
dias_kuksa/utils/in-vehicle/cloudfeeder_telemetry/, copycloudfeeder.pyandpreprocessor_example.pytokuksa.val/clients/vss-testclient/, where thetestclient.pyfile is located. - Then the
do_getValue(self, args)function fromkuksa.val/clients/vss-testclient/testclient.pyshould be modified as below.
...
def do_getValue(self, args)::
"""Get the value of a parameter"""
req = {}
req["requestId"] = 1234
req["action"]= "get"
req["path"] = args.Parameter
jsonDump = json.dumps(req)
self.sendMsgQueue.put(jsonDump)
resp = self.recvMsgQueue.get()
# print(highlight(resp, lexers.JsonLexer(), formatters.TerminalFormatter()))
self.pathCompletionItems = []
datastore = json.loads(resp)
return datastore
...
Due to its dependency on the cloud instance information, you should create either a Eclipse Hono or a Bosch-IoT-Hub instance first by following kuksa.cloud - Eclipse Hono (Cloud Entry), so that you can get the required information for running
cloudfeeder.pyready.Download the server certificate here and place it to
kuksa.val/clients/vss-testclient/, where thecloudfeeder.pyfile is located.Before running
cloudfeeder.py, install dependencies (mosquitto,mosquitto-clients, fromaptandpygments,cmd2frompip3) first:$ sudo apt-get update $ sudo apt-get install mosquitto mosquitto-clients $ pip3 install pygments cmd2
When all the required information is ready, navigate to
kuksa.val/clients/vss-testclient/, and runcloudfeeder.pyby commanding:$ python3 cloudfeeder.py -j {admin_json_token} --host {host_url} -p {port_number} -u {auth-id}@{tenant-id} -P {password} -c {server_certificate_file} -t {transmission_type}
- Just a reminder, the information between
{}should be different depending on the target Hono instance. You can follow kuksa.cloud - Eclipse Hono (Cloud Entry) to create a Hono instance. admin_json_tokencan be found under the directory (kuksa.val/certificates/jwt/super-admin.json.token). Therefore,/../certificates/jwt/super-admin.json.tokenshould be entered for-jwhen considering the current directory iskuksa.val/clients/vss-testclient/.- If you have successuly made it here, you would be able to see
cloudfeeder.pyfetching and transmitting the data every 1~2 seconds by now.




