aboutsummaryrefslogtreecommitdiffstats
path: root/docs/3-Usage.md
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-10-19 11:17:02 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-10-19 11:17:02 +0200
commit03fc96a9671d5739264f2208bfe2475641502164 (patch)
tree5926658db0c5d0c1267383ab86d87e741511ed69 /docs/3-Usage.md
parent4af423a2a09683acf0a9ad1e0a77bc45c2c843d9 (diff)
Details usage of write verb in docs.
Formating Change-Id: I17dd96a8fa64f09272f5c30ef77c6b41a21dea7d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'docs/3-Usage.md')
-rw-r--r--docs/3-Usage.md129
1 files changed, 92 insertions, 37 deletions
diff --git a/docs/3-Usage.md b/docs/3-Usage.md
index ba2c63fc..317e0724 100644
--- a/docs/3-Usage.md
+++ b/docs/3-Usage.md
@@ -2,7 +2,8 @@
## Virtual CAN device
-Connected to the target, here is how to load the virtual CAN device driver and set up a new vcan device :
+Connected to the target, here is how to load the virtual CAN device driver and
+set up a new vcan device :
```bash
modprobe vcan
@@ -10,8 +11,8 @@ ip link add vcan0 type vcan
ip link set vcan0 up
```
-You also can named your linux CAN device like you want and if you need name it `can0` :
-
+You also can named your linux CAN device like you want and if you need name it
+`can0` :
```bash
modprobe vcan
@@ -21,9 +22,10 @@ ip link set can0 up
## CAN device using the USB CAN adapter
-Using real connection to CAN bus of your car using the USB CAN adapter connected to the OBD2 connector.
+Using real connection to CAN bus of your car using the USB CAN adapter
+connected to the OBD2 connector.
-Once connected, launch `dmesg` command and search which device to use :
+Once connected, launch `dmesg` command and search which device to use:
```bash
dmesg
@@ -43,7 +45,8 @@ dmesg
Here device is named `can0`.
-This instruction assuming a speed of 500000kbps for your CAN bus, you can try others supported bitrate like 125000, 250000 if 500000 doesn't work:
+This instruction assuming a speed of 500000kbps for your CAN bus, you can try
+others supported bitrate like 125000, 250000 if 500000 doesn't work:
```bash
ip link set can0 type can bitrate 500000
@@ -58,7 +61,8 @@ ip link show can0
clock 16000000
```
-On a Rcar Gen3 board, you'll have your CAN device as `can1` because `can0` already exists as an embedded device.
+On a Rcar Gen3 board, you'll have your CAN device as `can1` because `can0`
+already exists as an embedded device.
The instructions will be the same:
@@ -77,7 +81,9 @@ ip link show can1
## Rename an existing CAN device
-You can rename an existing CAN device using following command and doing so move an existing `can0` device to anything else and then use another device as `can0`. For a Rcar Gen3 board do the following by example:
+You can rename an existing CAN device using following command and doing so move
+an existing `can0` device to anything else and then use another device as `can0`
+. For a Rcar Gen3 board do the following by example:
```bash
sudo ip link set can0 down
@@ -89,12 +95,17 @@ Then connect your USB CAN device that will be named `can0` by default.
# Configure the binding
-The binding reads system configuration file _/etc/dev-mapping.conf_ at start to map logical name from signals described in JSON file to linux devices name initialized by the system.
+The binding reads system configuration file _/etc/dev-mapping.conf_ at start to
+map logical name from signals described in JSON file to linux devices name
+initialized by the system.
+
Edit file _/etc/dev-mappping.conf_ and add mapping in section `CANbus-mapping`.
-Default binding configuration use a CAN bus named `hs` so you need to map it to the real one, here are some examples:
+Default binding configuration use a CAN bus named `hs` so you need to map it to
+the real one, here are some examples:
* Using virtual CAN device as described in the previous chapter:
+
```ini
[CANbus-mapping]
hs="vcan0"
@@ -102,6 +113,7 @@ ls="vcan1"
```
* Using real CAN device, this example assume CAN bus traffic will be on can0.
+
```ini
[CANbus-mapping]
hs="can0"
@@ -109,14 +121,17 @@ ls="can1"
```
* On a Rcar Gen3 board there is an embedded CAN device so `can0` already exists. So you might want to use your USB CAN adapter plugged to the OBD2 connector, in this case use `can1`:
+
```ini
[CANbus-mapping]
hs="can1"
```
-> **CAUTION VERY IMPORTANT:** Make sure the CAN bus\(es\) you specify in your configuration file match those specified in your generated source file with the `CAN-config-generator`.
+> **CAUTION VERY IMPORTANT:** Make sure the CAN bus\(es\) you specify in your
+> configuration file match those specified in your generated source file with
+> the `CAN-config-generator`.
-# Run it, test it, use it !
+# Run it, test it, use it.
You can run the binding using **afm-util** tool, here is the classic way to go :
@@ -125,11 +140,16 @@ afm-util run low-can-service@4.0
1
```
-You can find instructions to use afm-util tool [here](http://docs.iot.bzh/docs/apis_services/en/dev/reference/af-main/afm-daemons.html#using-afm-util), as well as documentation about Application Framework.
+You can find instructions to use afm-util tool
+[here](http://docs.iot.bzh/docs/apis_services/en/dev/reference/af-main/afm-daemons.html#using-afm-util),
+ as well as documentation about Application Framework.
-But you can't control nor interact with it because you don't know security token that **Application Framework** gaves it at launch.
+But you can't control nor interact with it because you don't know security
+token that **Application Framework** gaves it at launch.
-So, to test it, it is better to launch the binding manually. In the following example, it will use port **1234** and left empty security token for testing purpose:
+So, to test it, it is better to launch the binding manually. In the following
+example, it will use port **1234** and left empty security token for testing
+purpose:
```bash
afb-daemon --binding=/var/lib/afm/applications/low-can-service/4.0/lib/afb-low-can.so --rootdir=/var/lib/afm/applications/low-can-service/4.0/ --port=1234 --token=1
@@ -143,19 +163,24 @@ NOTICE: Waiting port=1234 rootdir=/var/lib/afm/applications/low-can-service/4.0/
NOTICE: Browser URL= http:/*localhost:1234
```
-On another terminal, connect to the binding using previously installed _**AFB Websocket CLI**_ tool:
+On another terminal, connect to the binding using previously installed
+**AFB Websocket CLI** tool:
```bash
afb-client-demo ws://localhost:1234/api?token=1
```
-You will be on an interactive session where you can communicate directly with the binding API.
+You will be on an interactive session where you can communicate directly with
+the binding API.
-The binding provides at this moment 2 verbs, _subscribe_ and _unsubscribe_, which can take argument by a JSON **event** object.
+The binding provides at this moment 2 verbs, _subscribe_ and _unsubscribe_,
+which can take argument by a JSON **event** object.
-The argument value is the CAN message **generic\_name** as described in the JSON file used to generate cpp file for the binding.
+The argument value is the CAN message **generic\_name** as described in the
+JSON file used to generate cpp file for the binding.
-To use the _**AFB Websocket CLI**_ tool, a command line will be like the following :
+To use the _**AFB Websocket CLI**_ tool, a command line will be like the
+following:
```
<api> <verb> <arguments>
@@ -169,9 +194,11 @@ Where:
## Subscription and unsubscription
-You can ask to subscribe to chosen CAN event with a call to _subscribe_ API verb with the CAN messages name as JSON argument.
+You can ask to subscribe to chosen CAN event with a call to _subscribe_ API
+verb with the CAN messages name as JSON argument.
-> **NOTE:** If no argument is provided, then you'll subscribe to all signals at once.
+> **NOTE:** If no argument is provided, then you'll subscribe to all signals
+> at once.
For example from a websocket session:
@@ -189,17 +216,23 @@ low-can subscribe { "event" : "doors*" }
ON-REPLY 1:low-can/subscribe: {"jtype":"afb-reply","request":{"status":"success","uuid":"511c872e-d7f3-4f3b-89c2-aa9a3e9fbbdb"}}
```
-Then you will receive an event each time a CAN message is decoded for the event named _doors.driver.open_ with its received timestamp if available:
+Then you will receive an event each time a CAN message is decoded for the event
+named _doors.driver.open_ with its received timestamp if available:
```json
ON-EVENT low-can/messages.doors.driver.open({"event":"low-can\/messages.doors.driver.open","data":{"name":"messages.doors.driver.open","value":true, "timestamp": 1505812906020023},"jtype":"afb-event"})
```
-Notice that event shows you that the CAN event is named _messages.doors.driver.open_ but you ask for event about _doors.driver.open_.
+Notice that event shows you that the CAN event is named
+_messages.doors.driver.open_ but you ask for event about
+_doors.driver.open_.
-This is because all CAN messages or diagnostic messages are prefixed by the JSON parent node name, **messages** for CAN messages and **diagnostic\_messages** for diagnostic messages like OBD2.
+This is because all CAN messages or diagnostic messages are prefixed by the
+JSON parent node name, **messages** for CAN messages and
+**diagnostic\_messages** for diagnostic messages like OBD2.
-This will let you subscribe or unsubcribe to all signals at once, not recommended, and better make filter on subscribe operation based upon their type. Examples:
+This will let you subscribe or unsubcribe to all signals at once, not
+recommended, and better make filter on subscribe operation based upon their type. Examples:
```json
low-can subscribe { "event" : "*speed*" } --> will subscribe to all messages with speed in their name. Search will be make without prefix for it.
@@ -221,13 +254,21 @@ ON-REPLY 3:low-can/unsubscribe: {"jtype":"afb-reply","request":{"status":"succes
### Filtering capabilities
-It is possible to limits received event notifications into minimum and maximum boundaries as well as doing frequency thinning. This is possible using the argument filter with one or more of the filters available :
+It is possible to limits received event notifications into minimum and maximum
+boundaries as well as doing frequency thinning. This is possible using the
+argument filter with one or more of the filters available :
-* frequency: specify in Hertz the frequency which will be used to getting notified of new CAN events for the designated signal. If, during the blocked time, further changed CAN messages are received, the last valid one will be transferred after the lockout with a RX_CHANGED.
-* min: Minimum value that the decoded value needs to be above to get pushed to the subscribed client(s).
-* max: Maximum value that the decoded value needs to be below to get pushed to the subscribed client(s)
+* frequency: specify in Hertz the frequency which will be used to getting
+ notified of new CAN events for the designated signal. If, during the blocked
+ time, further changed CAN messages are received, the last valid one will be
+ transferred after the lockout with a RX_CHANGED.
+* min: Minimum value that the decoded value needs to be above to get pushed to
+ the subscribed client(s).
+* max: Maximum value that the decoded value needs to be below to get pushed to
+ the subscribed client(s)
-Order doesn't matter neither the number of filters chosen, you can use one, two or all of them at once.
+Order doesn't matter neither the number of filters chosen, you can use one, two
+or all of them at once.
Usage examples :
@@ -249,8 +290,8 @@ ON-REPLY 1:low-can/get: {"response":[{"event":"messages.engine.speed","value":0}
> **CAUTION** Only one event could be requested.
-Also, if you want to know the supported CAN signals loaded by **low-can**, use verb
-**list**
+Also, if you want to know the supported CAN signals loaded by **low-can**, use
+verb **list**
```json
low-can list
@@ -259,7 +300,9 @@ ON-REPLY 2:low-can/list: {"response":["messages.hvac.fan.speed","messages.hvac.t
## Write on CAN buses
-A new capability as been introcuded to be able to write on handled CAN buses. Two modes could be used for that which is either specifying the CAN bus and a *RAW* CAN message either by specifying a defined signal and its value.
+A new capability as been introcuded to be able to write on handled CAN buses.
+Two modes could be used for that which is either specifying the CAN bus and a
+*RAW* CAN message either by specifying a defined signal and its value.
Examples:
@@ -271,9 +314,18 @@ low-can write { "bus_name": "hs", "frame": { "can_id": 1568, "can_dlc":
low-can write { "signal_name": "engine.speed", "value": 1256}
```
+To be able to use write capability, you need to add the permission
+ ```urn:AGL:permission:low-can:platform:write``` to your package configuration
+ file that need to write on CAN bus through **low-can** api.
+
+Then in order to write on bus, your app needs to call verb **auth**
+before calling **write**, to raise its **LOA**, Level Of Assurance,
+which controls usage of verb **write**.
+
## Using CAN utils to monitor CAN activity
-You can watch CAN traffic and send custom CAN messages using can-utils preinstalled on AGL target.
+You can watch CAN traffic and send custom CAN messages using can-utils
+preinstalled on AGL target.
To watch watch going on a CAN bus use:
@@ -293,9 +345,12 @@ Send a custom message:
cansend can0 ID#DDDDAAAATTTTAAAA
```
-You can also replay a previously dumped CAN logfiles. These logfiles can be found in _can_samples_ directory under Git repository. Following examples use a real trip from an Auris Toyota car.
+You can also replay a previously dumped CAN logfiles. These logfiles can be
+found in _can_samples_ directory under Git repository. Following examples use
+a real trip from an Auris Toyota car.
-Trace has been recorded from a CAN device `can0` so you have to map it to the correct one you use for your tests.
+Trace has been recorded from a CAN device `can0` so you have to map it to the
+correct one you use for your tests.
Replay on a virtual CAN device `vcan0`: