3 title: Installation and Usage Guide
5 https://git.automotivelinux.org/apps/agl-service-can-high-level-viwi/plain/docs/2-Install-Usage.md?h=master
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/apis_services/master/high-level-developer-guides-api-services-book.yml -->
14 Low level CAN service (>=4.0) must be installed. Prerequisites are the same.
17 $ git clone --recursive https://gerrit.automotivelinux.org/gerrit/apps/low-level-can-service
20 ## Clone and build high level binding
22 ### Build requirements
24 * CMake version 3.0 or later
25 * G++, Clang++ or any C++11 compliant compiler.
31 $ git clone --recusive https://github.com/iotbzh/high-level-viwi-service.git
37 $ cd $WD/high-level-viwi-service
48 ## JSON configuration file
50 This file must be named *high.json*, and must accessible from afb-daemon.
52 > **NOTE** A sample is available at the root of the git repository.
54 The json configuration file consists in 2 sections:
56 ### Definitions section
58 This section describes each resources defined in the high-level binding. Each resource is composed with different properties having a name, a type and a description.
59 Type can be boolean, double, string, or int. Properties "id", "uri" and "name" are compulsory.
65 "name": "/car/demoboard/",
69 "description": "identifier"
73 "description": "object uri"
81 "description": "units"
85 "description": "vehicle centerpoint speed as shown by the instrument cluster"
89 "description": "engine rotations per minute"
93 "description": "level of tankage"
97 "description": "engine load"
105 ### Resources section
107 This section defines which values should be assigned to resource's properties as defined in the definitions section.
108 The link to the definitions section is made through the name of the resource.
110 Some values are static, some are linked to low-level requests.
112 In case a value is linked to a low-level request, the value will start with "${" and end with "}". In that case the value will consist in the name of the low-level signal, followed
113 with the frequency of the signal in ms. -1 in the frequency means that high level binding should subscribe to low level binding for all changes, without specifying a frequency.
118 "name": "/car/demoboard/",
120 "name": "vehicleSpeed",
122 "speed": "${diagnostic_messages.vehicle.speed,1000}"
124 "name": "engineSpeed",
126 "rpm": "${diagnostic_messages.engine.speed,1000}"
130 "level": "${diagnostic_messages.fuel.level,1000}"
132 "name": "engineLoad",
134 "load": "${diagnostic_messages.engine.load,1000}"
141 ## Running and testing
143 ### Launch the binder together with the two bindings
145 The Json high level configuration file *high.json* must be placed in the directory where you launch afb-daemon.
148 $ cp $WD/high-level-viwi-service/high.json $WD
152 Then you can natively under linux you can launch afb-daemon with the low-level and high-level bindings with a command like:
156 $ afb-daemon --rootdir=$WD/low-level-can-service/CAN-binder/build/package --binding=$WD/low-level-can-service/CAN-binder/build/package/lib/afb-low-can.so --binding=$WD/high-level-viwi-service/build/package/lib/afb-high-viwi.so --port=1234 --tracereq=common --token=1 --verbose
159 ### Use afb-client-demo to test high level binding
161 On another terminal, connect to the binding using previously installed _**AFB Websocket CLI**_ tool:
164 $ afb-client-demo ws://localhost:1234/api?token=1
167 You will be on an interactive session where you can communicate directly with the binding API.
169 The binding provides at this moment 3 verbs, _get_, _subscribe_ and _unsubscribe_, which can take a JSON object as an argument.
172 To use the _**AFB Websocket CLI**_ tool, a command line will be like the following :
175 <api> <verb> <arguments>
180 * API : _**high-viwi**_.
181 * Verb : _**get**_, _**subscribe**_ or _**unsubscribe**_
182 * Arguments : _**{ "name": "/car/doors/" }**_
184 You can therefore use commands such as:
187 high-viwi subscribe {"name":"/car/doors/","interval":10000}
188 high-viwi unsubscribe {"name":"/car/doors/","interval":10000}
189 high-viwi get {"name":"/car/demoboard/"}
190 high-viwi get {"name":"/car/demoboard/","fields":["fuelLevel","engineLoad"]}
193 For instance the output of the third command should be:
196 high-viwi get {"name":"/car/demoboard/"}
197 ON-REPLY 1:high-viwi/get: {"response":{"\/car\/demoboard\/2159e2-5b638a-39e242-7a2f5":{"id":"2159e2-5b638a-39e242-7a2f5","name":"vehicleSpeed","speed":0.000000,"unit":"km\/h","uri":"\/car\/demoboard\/2159e2-5b638a-39e242-7a2f5"},"\/car\/demoboard\/22ad2c-5a3c2b-50fabb-324c82":{"id":"22ad2c-5a3c2b-50fabb-324c82","level":0.000000,"name":"fuelLevel","unit":"litre","uri":"\/car\/demoboard\/22ad2c-5a3c2b-50fabb-324c82"},"\/car\/demoboard\/3a3ab9-2bd52c-11d30-689acf":{"id":"3a3ab9-2bd52c-11d30-689acf","name":"engineSpeed","rpm":0.000000,"unit":"rpm","uri":"\/car\/demoboard\/3a3ab9-2bd52c-11d30-689acf"},"\/car\/demoboard\/5ae808-8093cb-99716-30a605":{"id":"5ae808-8093cb-99716-30a605","load":0.000000,"name":"engineLoad","unit":"Nm","uri":"\/car\/demoboard\/5ae808-8093cb-99716-30a605"}},"jtype":"afb-reply","request":{"status":"success","uuid":"44ce03f9-a7ca-49e1-a62a-40c74db0caa0"}}
200 As you can see for the moment all values are 0, because we didn't inject any CAN data in the binder. To do this, you can use **canplayer** to feed the bindings with some data.
201 You can find an example of data in high level binding, "samples" directory.
203 For instance, on a third terminal:
206 $ canplayer -I candata