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 objects, separated by newlines.
8 There are two valid message types - single valued and evented.
10 There may not be a 1:1 relationship between input and output signals - i.e. raw
11 engine timing CAN signals may be summarized in an "engine performance" metric on
12 the abstract side of the interface.
16 The expected format of a single valued message is:
18 {"name": "steering_wheel_angle", "value": 45}
22 The expected format of an event message is:
24 {"name": "button_event", "value": "up", "event": "pressed"}
26 This format is good for something like a button event, where there are two
27 discrete pieces of information in the measurement.
29 ## Raw CAN Message format
31 An OpenXC vehicle interface may also output raw CAN messages. Each CAN message
32 is sent as a JSON object, separated by newlines. The format of each object is:
34 {"bus": 1, "id": 1234, "value": "0x12345678"}
36 **bus** - the numerical identifier of the CAN bus where this message originated,
37 most likely 1 or 2 (for a vehicle interface with 2 CAN controllers).
39 **id** - the CAN message ID
41 **data** - up to 8 bytes of data from the CAN message's payload, represented as
42 a hexidecimal number in a string. Many JSON parser cannot handle 64-bit
43 integers, which is why we are not using a numerical data type.
45 ## Diagnostic Messages
49 A request to add or update a diagnostic request is sent to a vehicle interface
50 with this command format:
52 { "command": "diagnostic_request",
59 "parse_payload": true,
60 "multiple_response": false,
69 **bus** - the numerical identifier of the CAN bus where this request should be
70 sent, most likely 1 or 2 (for a vehicle interface with 2 CAN controllers).
72 **id** - the CAN arbitration ID for the request.
74 **mode** - the OBD-II mode of the request - 1 through 15 (1 through 9 are the
77 **pid** - (optional) the PID for the request, if applicable.
79 **payload** - (optional) up to 7 bytes of data for the request's payload
80 represented as a hexidecimal number in a string. Many JSON parser cannot
81 handle 64-bit integers, which is why we are not using a numerical data type.
83 **parse_payload** - (optional, false by default) if true, the complete payload in the
84 response message will be parsed as a number and returned in the 'value' field of
85 the response. The 'payload' field will be omitted in responses with a
88 **multiple_response** - (optional, false by default) if true, request will stay
89 active for a full 100ms, even after receiving a diagnostic response message.
90 This is useful for requests to the functional broadcast arbitration ID
91 (`0x7df`) when you need to get responses from multiple modules. It's possible
92 to set this to `true` for non-broadcast requests, but in practice you won't
93 see any additional responses after the first and it will just take up memory
96 **factor** - (optional, 1.0 by default) if `parse_payload` is true, the value in
97 the payload will be multiplied by this factor before returning. The `factor`
98 is applied before the `offset`.
100 **offset** - (optional, 0 by default) if `parse_payload` is true, this offset
101 will be added to the value in the payload before returning. The `offset` is
102 applied after the `factor`.
104 **frequency** - (optional, defaults to 0) The frequency in Hz to send this
105 request. To send a single request, set this to 0 or leave it out.
107 **name** - (optional, defaults to nothing) A human readable, string name for
108 this request. If provided, the response will have a `name` field (much like a
109 normal translated message) in place of the request details (i.e. the bus,
110 id, mode and pid). TODO elaborate on this.
112 The `bus+id+mode+pid` key is unique, so if you send a create request with that
113 key twice, it'll overwrite the existing one (i.e. it will change the frequency,
114 the only other parameter). To cancel a recurring request, send this command with
115 the frequency set to 0.
117 TODO it'd be nice to have the OBD-II PIDs built in, with the proper conversion
118 functions - that may need a different output format
120 If you're just requesting a PID, you can use this minimal field set for the
123 {"bus": 1, "id": 1234, "mode": 1, "pid": 5}
132 "negative_response_code": 17,
134 "parsed_payload": 4660}
136 **bus** - the numerical identifier of the CAN bus where this response was
139 **id** - the CAN arbitration ID for this response.
141 **mode** - the OBD-II mode of the original diagnostic request.
143 **pid** - (optional) the PID for the request, if applicable.
145 **success** - true if the response received was a positive response. If this
146 field is false, the remote node returned an error and the
147 `negative_response_code` field should be populated.
149 **negative_response_code** - (optional) If requested node returned an error,
150 `success` will be `false` and this field will contain the negative response
153 Finally, the `payload` and `value` fields are mutually exclusive:
155 **payload** - (optional) up to 7 bytes of data returned in the response,
156 represented as a hexadecimal number in a string. Many JSON parser cannot
157 handle 64-bit integers, which is why we are not using a numerical data type.
159 **value** - (optional) if the response had a payload, this may be the
160 payload interpreted as an integer and transformed with a factor and offset
161 provided with the request.
163 The response to a simple PID request would look like this:
165 {"bus": 1, "id": 1234, "mode": 1, "pid": 5, "payload": "0x2"}
167 TODO again, it'd be nice to have the OBD-II PIDs built in, with the proper
168 conversion functions so the response here included the actual transformed value
169 of the pid and a human readable name
173 An OpenXC vehicle trace file is a plaintext file that contains JSON objects,
174 separated by newlines.
176 The first line may be a metadata object, although this is optional:
181 "vehicle_interface_id": "7ABF",
185 "trim": "V6 Premium",
188 "description": "highway drive to work",
189 "driver_name": "TJ Giuli",
190 "vehicle_id": "17N1039247929"
194 The following lines are OpenXC messages with a `timestamp` field added, e.g.:
196 {"timestamp": 1385133351.285525, "name": "steering_wheel_angle", "value": 45}
198 The timestamp is in [UNIX time](http://en.wikipedia.org/wiki/Unix_time)
199 (i.e. seconds since the UNIX epoch, 00:00:00 UTC, 1/1/1970).
203 These signal names are a part of the OpenXC specification, although some
204 manufacturers may support custom message names.
206 * steering_wheel_angle
207 * numerical, -600 to +600 degrees
209 * torque_at_transmission
210 * numerical, -500 to 1500 Nm
213 * numerical, 0 to 16382 RPM
216 * numerical, 0 to 655 km/h (this will be positive even if going in reverse
217 as it's not a velocity, although you can use the gear status to figure out
220 * accelerator_pedal_position
223 * parking_brake_status
224 * boolean, (true == brake engaged)
225 * 1Hz, but sent immediately on change
227 * boolean (True == pedal pressed)
228 * 1Hz, but sent immediately on change
229 * transmission_gear_position
230 * states: first, second, third, fourth, fifth, sixth, seventh, eighth,
232 * 1Hz, but sent immediately on change
233 * gear_lever_position
234 * states: neutral, park, reverse, drive, sport, low, first, second, third,
236 * 1Hz, but sent immediately on change
239 0 to 16777214.000 km, with about .2m resolution
242 * states: off, accessory, run, start
243 * 1Hz, but sent immediately on change
247 * fuel_consumed_since_restart
248 * numerical, 0 - 4294967295.0 L (this goes to 0 every time the vehicle
249 restarts, like a trip meter)
252 * Value is State: driver, passenger, rear_left, rear_right.
253 * Event is boolean: true == ajar
254 * 1Hz, but sent immediately on change
256 * boolean, true is on
257 * 1Hz, but sent immediately on change
259 * boolean, true is on
260 * 1Hz, but sent immediately on change
261 * windshield_wiper_status
262 * boolean, true is on
263 * 1Hz, but sent immediately on change
265 * numerical, -89.0 to 89.0 degrees with standard GPS accuracy
268 * numerical, -179.0 to 179.0 degrees with standard GPS accuracy
274 Copyright (c) 2012-2013 Ford Motor Company
276 Licensed under the BSD license.
278 [OpenXC]: http://openxcplatform.com