1 # OpenXC Message Format Specification
3 This specification is a part of the [OpenXC platform][OpenXC].
5 An OpenXC vehicle interface sends generic vehicle data over one or more output
6 interfaces (e.g. USB or Bluetooth) as JSON or Protocol Buffers (protobuf).
8 This document describes the JSON format and includes a high level description of
9 each type and field. Each JSON message published by a VI is delimited with a
12 The Protocol Buffer format is specified in the file `openxc.proto`. Those are
13 published using the standard length-delimited method (any protobuf library
18 There may not be a 1:1 relationship between input and output signals - i.e. raw
19 engine timing CAN signals may be summarized in an "engine performance" metric on
20 the abstract side of the interface.
22 The expected format of a single valued message is:
24 {"name": "steering_wheel_angle", "value": 45}
28 The expected format of an event message is:
30 {"name": "button_event", "value": "up", "event": "pressed"}
32 This format is good for something like a button event, where there are two
33 discrete pieces of information in the measurement.
35 ## Raw CAN Message format
37 An OpenXC vehicle interface may also output raw CAN messages. Each CAN message
38 is sent as a JSON object, separated by newlines. The format of each object is:
40 {"bus": 1, "id": 1234, "value": "0x12345678"}
42 **bus** - the numerical identifier of the CAN bus where this message originated,
43 most likely 1 or 2 (for a vehicle interface with 2 CAN controllers).
45 **id** - the CAN message ID
47 **data** - up to 8 bytes of data from the CAN message's payload, represented as
48 a hexidecimal number in a string. Many JSON parser cannot handle 64-bit
49 integers, which is why we are not using a numerical data type. Each byte in
50 the string *must* be represented with 2 characters, e.g. `0x1` is `0x01` - the
51 complete string must have an even number of characters.
53 ## Diagnostic Messages
57 A request to add or update a diagnostic request is sent to a vehicle interface
58 with this command format:
60 { "command": "diagnostic_request",
67 "multiple_responses": false,
76 **bus** - the numerical identifier of the CAN bus where this request should be
77 sent, most likely 1 or 2 (for a vehicle interface with 2 CAN controllers).
79 **id** - the CAN arbitration ID for the request.
81 **mode** - the OBD-II mode of the request - 1 through 15 (1 through 9 are the
84 **pid** - (optional) the PID for the request, if applicable.
86 **payload** - (optional) up to 7 bytes of data for the request's payload
87 represented as a hexidecimal number in a string. Many JSON parser cannot
88 handle 64-bit integers, which is why we are not using a numerical data type.
89 Each byte in the string *must* be represented with 2 characters, e.g. `0x1`
90 is `0x01` - the complete string must have an even number of characters.
92 **name** - (optional, defaults to nothing) A human readable, string name for
93 this request. If provided, the response will have a `name` field (much like a
94 normal translated message) with this value in place of `bus`, `id`, `mode` and
97 **multiple_responses** - (optional, false by default) if true, request will stay
98 active for a full 100ms, even after receiving a diagnostic response message.
99 This is useful for requests to the functional broadcast arbitration ID
100 (`0x7df`) when you need to get responses from multiple modules. It's possible
101 to set this to `true` for non-broadcast requests, but in practice you won't
102 see any additional responses after the first and it will just take up memory
103 in the VI for longer.
105 **frequency** - (optional, defaults to 0) The frequency in Hz to send this
106 request. To send a single non-recurring request, set this to 0 or leave it
109 **decoded_type** - (optional, defaults to "obd2" if the request is a recognized
110 OBD-II mode 1 request, otherwise "none") If specified, the valid values are
111 `"none"` and `"obd2"`. If `obd2`, the payload will be decoded according to the
112 OBD-II specification and returned in the `value` field. Set this to `none` to
113 manually override the OBD-II decoding feature for a known PID.
115 A diagnostic request's `bus`, `id`, `mode` and `pid` (or lack of a `pid`)
116 combine to create a unique key to identify a recurring request. This means that
117 you cannot simultaneosly have recurring requests at 2Hz and 5Hz for the same PID
120 If you send a new `diagnostic_request` command with a `bus + id + mode + pid`
121 key matching an existing recurring request, it will update it with whatever
122 other parameters you've provided (e.g. it will change the frequency if you
125 To cancel a recurring request, send a `diagnostic_request` command with the
126 matching request information (i.e. the `bus`, `id`, `mode` and `pid`) but a
129 Non-recurring requests may have the same `bus+id+mode(+pid)` key as a recurring
130 request, and they will co-exist without issue. As soon as a non-recurring
131 request is either completed or times out, it is removed from the active list.
133 If you're just requesting a PID, you can use this minimal field set for the
136 {"bus": 1, "id": 1234, "mode": 1, "pid": 5}
140 The response to a successful request:
150 and to an unsuccessful request, with the `negative_response_code` and no `pid`
157 "negative_response_code": 17}
159 **bus** - the numerical identifier of the CAN bus where this response was
162 **id** - the CAN arbitration ID for this response.
164 **mode** - the OBD-II mode of the original diagnostic request.
166 **pid** - (optional) the PID for the request, if applicable.
168 **success** - true if the response received was a positive response. If this
169 field is false, the remote node returned an error and the
170 `negative_response_code` field should be populated.
172 **negative_response_code** - (optional) If requested node returned an error,
173 `success` will be `false` and this field will contain the negative response
176 Finally, the `payload` and `value` fields are mutually exclusive:
178 **payload** - (optional) up to 7 bytes of data returned in the response,
179 represented as a hexadecimal number in a string. Many JSON parser cannot
180 handle 64-bit integers, which is why we are not using a numerical data type.
182 **value** - (optional) if the response had a payload, this may be the
183 payload interpreted as an integer.
185 The response to a simple PID request would look like this:
187 {"success": true, "bus": 1, "id": 1234, "mode": 1, "pid": 5, "payload": "0x2"}
193 The `version` command triggers the VI to inject a firmware version identifier
194 response into the outgoing data stream.
198 { "command": "version"}
202 { "command_response": "version", "message": "v6.0-dev (default)"}
206 The `device_id` command triggers the VI to inject a unique device ID (e.g. the
207 MAC address of an included Bluetooth module) into into the outgoing data stream.
211 { "command": "device_id"}
215 { "command_response": "device_id", "message": "0012345678"}
219 An OpenXC vehicle trace file is a plaintext file that contains JSON objects,
220 separated by newlines.
222 The first line may be a metadata object, although this is optional:
227 "vehicle_interface_id": "7ABF",
231 "trim": "V6 Premium",
234 "description": "highway drive to work",
235 "driver_name": "TJ Giuli",
236 "vehicle_id": "17N1039247929"
240 The following lines are OpenXC messages with a `timestamp` field added, e.g.:
242 {"timestamp": 1385133351.285525, "name": "steering_wheel_angle", "value": 45}
244 The timestamp is in [UNIX time](http://en.wikipedia.org/wiki/Unix_time)
245 (i.e. seconds since the UNIX epoch, 00:00:00 UTC, 1/1/1970).
249 These signal names are a part of the OpenXC specification, although some
250 manufacturers may support custom message names.
252 * steering_wheel_angle
253 * numerical, -600 to +600 degrees
255 * torque_at_transmission
256 * numerical, -500 to 1500 Nm
259 * numerical, 0 to 16382 RPM
262 * numerical, 0 to 655 km/h (this will be positive even if going in reverse
263 as it's not a velocity, although you can use the gear status to figure out
266 * accelerator_pedal_position
269 * parking_brake_status
270 * boolean, (true == brake engaged)
271 * 1Hz, but sent immediately on change
273 * boolean (True == pedal pressed)
274 * 1Hz, but sent immediately on change
275 * transmission_gear_position
276 * states: first, second, third, fourth, fifth, sixth, seventh, eighth,
278 * 1Hz, but sent immediately on change
279 * gear_lever_position
280 * states: neutral, park, reverse, drive, sport, low, first, second, third,
282 * 1Hz, but sent immediately on change
285 0 to 16777214.000 km, with about .2m resolution
288 * states: off, accessory, run, start
289 * 1Hz, but sent immediately on change
293 * fuel_consumed_since_restart
294 * numerical, 0 - 4294967295.0 L (this goes to 0 every time the vehicle
295 restarts, like a trip meter)
298 * Value is State: driver, passenger, rear_left, rear_right.
299 * Event is boolean: true == ajar
300 * 1Hz, but sent immediately on change
302 * boolean, true is on
303 * 1Hz, but sent immediately on change
305 * boolean, true is on
306 * 1Hz, but sent immediately on change
307 * windshield_wiper_status
308 * boolean, true is on
309 * 1Hz, but sent immediately on change
311 * numerical, -89.0 to 89.0 degrees with standard GPS accuracy
314 * numerical, -179.0 to 179.0 degrees with standard GPS accuracy
320 Copyright (c) 2012-2013 Ford Motor Company
322 Licensed under the BSD license.
324 [OpenXC]: http://openxcplatform.com