Renaming configuration to application
[apps/low-level-can-service.git] / docs / 3-Usage.md
index 7c0a4f1..5bea1d9 100644 (file)
@@ -30,7 +30,7 @@ loop1
     253:4    0    10G  0 dm   /var/lib/docker/devicemapper/mnt/e9f80849a2681e18549d3a4238cbf031e44052e36cd88a0abf041804b799b61c
 sdb                                                                                       8:16   0 238.5G  0 disk
 ├─sdb2                                                                                    8:18   0   238G  0 part
-│ └─Shamash-agl                                                                         253:1    0   238G  0 lvm  /home/claneys/Workspace/agl-docker
+│ └─agl                                                                         253:1    0   238G  0 lvm  /home/claneys/Workspace/agl-docker
 └─sdb1                                                                                    8:17   0   500M  0 part /boot
 sr0                                                                                      11:0    1  1024M  0 rom
 loop0                                                                                     7:0    0   100G  0 loop
@@ -41,8 +41,8 @@ sdc
 └─sdc1                                                                                    8:33   1     2G  0 part /run/media/claneys/97f418a5-612f-44e9-b968-a19505695151
 sda                                                                                       8:0    0 931.5G  0 disk
 ├─sda2                                                                                    8:2    0   500G  0 part
-│ ├─Shamash-home                                                                        253:2    0   150G  0 lvm  /home
-│ └─Shamash-root                                                                        253:0    0    50G  0 lvm  /
+│ ├─home                                                                        253:2    0   150G  0 lvm  /home
+│ └─root                                                                        253:0    0    50G  0 lvm  /
 └─sda1                                                                                    8:1    0    16G  0 part [SWAP]
 ```
 
@@ -51,8 +51,12 @@ Copy, still from your host:
 > **CAUTION:** Make sure to sync IO with sync command before unplug your SDcard. It could be corrupted if removed before all pending IO aren't done.
 
 ```bash
-$ sudo cp ~/devel/docker/share/libafbwsc-dev-1.0-r0.cortexa15hf_neon.rpm /run/media/claneys/97f418a5-612f-44e9-b968-a19505695151/home/root
+$ sudo umount /dev/sdc1
+$ export SDCARD=/mnt
+$ sudo mount /dev/sdc1 $SDCARD
+$ sudo cp ~/devel/docker/share/libafbwsc-dev-1.0-r0.cortexa15hf_neon.rpm $SDCARD/home/root
 $ sync
+$ sudo umount $SDCARD
 ```
 
 Insert the modified SDcard in your Porter board and boot from it. You are ready to go.
@@ -91,7 +95,7 @@ Once connected, launch `dmesg` command and search which device to use :
 [ 1872.809356] usbcore: registered new interface driver usb_8dev
 ```
 
-Here device is named **can0**.
+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:
 
@@ -108,32 +112,58 @@ This instruction assuming a speed of 500000kbps for your CAN bus, you can try ot
     clock 16000000
 ```
 
+For a Porter board, you'll have your CAN device as `can1` because `can0` already exists as an embedded device.
+
+The instructions will be the same:
+
+```bash
+# ip link set can1 type can bitrate 500000
+# ip link set can1 up
+# ip link show can1
+  can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
+    link/can
+    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
+    bitrate 500000 sample-point 0.875
+    tq 125 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
+    sja1000: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
+    clock 16000000
+```
+
 ## Configure the binding
 
-Configure the binding specifying in the JSON configuration file the CAN device\(s\) that it will to connect to. Edit file _/var/lib/afm/applications/low-can-binding/0.1/can\_buses.json_ and change the CAN device name to the one you have :
+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` :
 
-```json
-{
-    "canbus":  "can0"
-}
+Using virtual CAN device as described in the previous chapter:
+```ini
+[CANbus-mapping]
+hs="vcan0"
+ls="vcan1"
+```
+
+Using real CAN device, this example assume CAN bus traffic will be on can0.
+```ini
+[CANbus-mapping]
+hs="can0"
+ls="can1"
 ```
 
-If you have several specify CAN bus devices use an array:
+On a Porter board there is an embedded CAN device so `can0` already exists.
 
-```json
-{
-    "canbus": [ "vcan0", "can0" ]
-}
+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"
 ```
 
-> **WARNING:** 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](http://github.com/iotbzh/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 !
 
 You can run the binding using **afm-util** tool, here is the classic way to go :
 
 ```bash
-# afm-util run low-can-binding@0.1
+# afm-util run low-can-binding@1.0
 1
 ```
 
@@ -144,14 +174,14 @@ But you can't control nor interact with it because you don't know security token
 So, to test it, it is better to launch the binding manually. In the following example, we will use port **1234** and left empty security token for testing purpose:
 
 ```bash
-# afb-daemon --ldpaths=/usr/lib/afb:/var/lib/afm/applications/low-can-binding/0.1/libs/ --rootdir=/var/lib/afm/applications/low-can-binding/0.1/ --port=1234 --token=
+# afb-daemon --ldpaths=/usr/lib/afb:/var/lib/afm/applications/low-can-binding/1.0/libs/ --rootdir=/var/lib/afm/applications/low-can-binding/1.0/ --port=1234 --token=1
 NOTICE: binding [/usr/lib/afb/afb-dbus-binding.so] calling registering function afbBindingV1Register
 NOTICE: binding /usr/lib/afb/afb-dbus-binding.so loaded with API prefix dbus
 NOTICE: binding [/usr/lib/afb/authLogin.so] calling registering function afbBindingV1Register
 NOTICE: binding /usr/lib/afb/authLogin.so loaded with API prefix auth
-NOTICE: binding [/var/lib/afm/applications/low-can-binding/0.1/libs//low-can-binding.so] calling registering function afbBindingV1Register
-NOTICE: binding /var/lib/afm/applications/low-can-binding/0.1/libs//low-can-binding.so loaded with API prefix low-can
-NOTICE: Waiting port=1234 rootdir=/var/lib/afm/applications/low-can-binding/0.1/
+NOTICE: binding [/var/lib/afm/applications/low-can-binding/1.0/libs//low-can-binding.so] calling registering function afbBindingV1Register
+NOTICE: binding /var/lib/afm/applications/low-can-binding/1.0/libs//low-can-binding.so loaded with API prefix low-can
+NOTICE: Waiting port=1234 rootdir=/var/lib/afm/applications/low-can-binding/1.0/
 NOTICE: Browser URL= http:/*localhost:1234
 NOTICE: vcan0 device opened and reading {binding low-can}
 NOTICE: Initialized 1/1 can bus device(s) {binding low-can}
@@ -160,7 +190,7 @@ NOTICE: Initialized 1/1 can bus device(s) {binding low-can}
 On another terminal, connect to the binding using previously installed _**AFB Websocket CLI**_ tool:
 
 ```bash
-# afb-client-demo ws://localhost:1234/api?token=
+# 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.
@@ -196,7 +226,7 @@ ON-REPLY 1:low-can/subscribe: {"jtype":"afb-reply","request":{"status":"success"
 
 Subscription and unsubscription can take wildcard in their _event_ value.
 
-To reveive all doors events :
+To receive all doors events :
 
 ```json
 low-can subscribe { "event" : "doors*" }
@@ -243,11 +273,33 @@ To watch watch going on a CAN bus use:
 # candump can0
 ```
 
+Or for an USB CAN adapter connected to porter board:
+
+```bash
+# candump can1
+```
+
 Send a custom message:
 
 ```bash
 # 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.
+
+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`:
+```bash
+# canplayer -I trip_test_with_obd2_vehicle_speed_requests vcan0=can0
+```
 
+Replay on a CAN device `can0`:
+```bash
+# canplayer -I trip_test_with_obd2_vehicle_speed_requests can0
+```
+
+Replay on a CAN device `can1` (porter by example):
+```bash
+# canplayer -I trip_test_with_obd2_vehicle_speed_requests can1=can0
+```