Set docs revision to 4.99-EERC1
[apps/agl-service-can-low-level.git] / docs / 3-Usage.md
index eecf5a8..ba2c63f 100644 (file)
@@ -129,7 +129,7 @@ You can find instructions to use afm-util tool [here](http://docs.iot.bzh/docs/a
 
 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, we 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
@@ -189,10 +189,10 @@ 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_
+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},"jtype":"afb-event"})
+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_.
@@ -223,7 +223,7 @@ ON-REPLY 3:low-can/unsubscribe: {"jtype":"afb-reply","request":{"status":"succes
 
 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. 
+* 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)
 
@@ -237,6 +237,40 @@ low-can subscribe {"event": "messages.engine.load", "filter": { "min": 30, "max"
 low-can subscribe {"event": "messages.vehicle.speed", "filter": { "frequency": 2}}
 ```
 
+## Get last signal value and list of configured signals
+
+You can also ask for a particular signal value on one shot using **get** verb, like
+this:
+
+```json
+low-can get {"event": "messages.engine.speed"}
+ON-REPLY 1:low-can/get: {"response":[{"event":"messages.engine.speed","value":0}],"jtype":"afb-reply","request":{"status":"success"}}
+```
+
+> **CAUTION** Only one event could be requested.
+
+Also, if you want to know the supported CAN signals loaded by **low-can**, use verb
+**list**
+
+```json
+low-can list
+ON-REPLY 2:low-can/list: {"response":["messages.hvac.fan.speed","messages.hvac.temperature.left","messages.hvac.temperature.right","messages.hvac.temperature.average","messages.engine.speed","messages.fuel.level.low","messages.fuel.level","messages.vehicle.average.speed","messages.engine.oil.temp","messages.engine.oil.temp.high","messages.doors.boot.open","messages.doors.front_left.open","messages.doors.front_right.open","messages.doors.rear_left.open","messages.doors.rear_right.open","messages.windows.front_left.open","messages.windows.front_right.open","messages.windows.rear_left.open","messages.windows.rear_right.open","diagnostic_messages.engine.load","diagnostic_messages.engine.coolant.temperature","diagnostic_messages.fuel.pressure","diagnostic_messages.intake.manifold.pressure","diagnostic_messages.engine.speed","diagnostic_messages.vehicle.speed","diagnostic_messages.intake.air.temperature","diagnostic_messages.mass.airflow","diagnostic_messages.throttle.position","diagnostic_messages.running.time","diagnostic_messages.EGR.error","diagnostic_messages.fuel.level","diagnostic_messages.barometric.pressure","diagnostic_messages.ambient.air.temperature","diagnostic_messages.commanded.throttle.position","diagnostic_messages.ethanol.fuel.percentage","diagnostic_messages.accelerator.pedal.position","diagnostic_messages.hybrid.battery-pack.remaining.life","diagnostic_messages.engine.oil.temperature","diagnostic_messages.engine.fuel.rate","diagnostic_messages.engine.torque"],"jtype":"afb-reply","request":{"status":"success","uuid":"32df712a-c7fa-4d58-b70b-06a87f03566b"}}
+```
+
+## 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.
+
+Examples:
+
+```json
+# Write a raw can frame to the CAN id 0x620
+low-can write { "bus_name": "hs", "frame": { "can_id": 1568, "can_dlc":
+8, "can_data": [ 255,255,255,255,255,255,255,255]} }
+# Write a signal's value.
+low-can write { "signal_name": "engine.speed", "value": 1256}
+```
+
 ## Using CAN utils to monitor CAN activity
 
 You can watch CAN traffic and send custom CAN messages using can-utils preinstalled on AGL target.
@@ -264,16 +298,19 @@ You can also replay a previously dumped CAN logfiles. These logfiles can be foun
 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
 ```