more gears
[apps/agl-service-can-low-level.git] / README.md
1 # OpenXC Message Format Specification
2
3 This specification is a part of the [OpenXC platform][OpenXC].
4
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.
7
8 There are two valid message types - single valued and evented.
9
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.
13
14 ## Single Valued
15
16 The expected format of a single valued message is:
17
18     {"name": "steering_wheel_angle", "value": 45}
19
20 ## Evented
21
22 The expected format of an event message is:
23
24     {"name": "button_event", "value": "up", "event": "pressed"}
25
26 This format is good for something like a button event, where there are two
27 discrete pieces of information in the measurement.
28
29 ## Raw CAN Message format
30
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:
33
34     {"bus": 1, "id": 1234, "value": "0x12345678"}
35
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).
38
39 **id** - the CAN message ID
40
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.
44
45 ## Trace File Format
46
47 An OpenXC vehicle trace file is a plaintext file that contains JSON objects,
48 separated by newlines.
49
50 The first line may be a metadata object, although this is optional:
51
52 ```
53 {"metadata": {
54     "version": "v3.0",
55     "vehicle_interface_id": "7ABF",
56     "vehicle": {
57         "make": "Ford",
58         "model": "Mustang",
59         "trim": "V6 Premium",
60         "year": 2013
61     },
62     "description": "highway drive to work",
63     "driver_name": "TJ Giuli",
64     "vehicle_id": "17N1039247929"
65 }
66 ```
67
68 The following lines are OpenXC messages with a `timestamp` field added, e.g.:
69
70     {"timestamp": 1385133351.285525, "name": "steering_wheel_angle", "value": 45}
71
72 The timestamp is in [UNIX time](http://en.wikipedia.org/wiki/Unix_time)
73 (i.e. seconds since the UNIX epoch, 00:00:00 UTC, 1/1/1970).
74
75 ## Official Signals
76
77 These signal names are a part of the OpenXC specification, although some
78 manufacturers may support custom message names.
79
80 * steering_wheel_angle
81     * numerical, -600 to +600 degrees
82     * 10Hz
83 * torque_at_transmission
84     * numerical, -500 to 1500 Nm
85     * 10Hz
86 * engine_speed
87     * numerical, 0 to 16382 RPM
88     * 10Hz
89 * vehicle_speed
90     * numerical, 0 to 655 km/h (this will be positive even if going in reverse
91       as it's not a velocity, although you can use the gear status to figure out
92       direction)
93     * 10Hz
94 * accelerator_pedal_position
95     * percentage
96     * 10Hz
97 * parking_brake_status
98     * boolean, (true == brake engaged)
99     * 1Hz, but sent immediately on change
100 * brake_pedal_status
101     * boolean (True == pedal pressed)
102     * 1Hz, but sent immediately on change
103 * transmission_gear_position
104     * states: first, second, third, fourth, fifth, sixth, seventh, eighth,
105       ninth, tenth, reverse, neutral
106     * 1Hz, but sent immediately on change
107 * gear_lever_position
108     * states: neutral, park, reverse, drive, sport, low, first, second, third,
109       fourth, fifth, sixth, seventh, eighth, ninth, tenth
110     * 1Hz, but sent immediately on change
111 * odometer
112     * Numerical, km
113         0 to 16777214.000 km, with about .2m resolution
114     * 10Hz
115 * ignition_status
116     * states: off, accessory, run, start
117     * 1Hz, but sent immediately on change
118 * fuel_level
119     * percentage
120     * 2Hz
121 * fuel_consumed_since_restart
122     * numerical, 0 - 4294967295.0 L (this goes to 0 every time the vehicle
123       restarts, like a trip meter)
124     * 10Hz
125 * door_status
126     * Value is State: driver, passenger, rear_left, rear_right.
127     * Event is boolean: true == ajar
128     * 1Hz, but sent immediately on change
129 * headlamp_status
130     * boolean, true is on
131     * 1Hz, but sent immediately on change
132 * high_beam_status
133     * boolean, true is on
134     * 1Hz, but sent immediately on change
135 * windshield_wiper_status
136     * boolean, true is on
137     * 1Hz, but sent immediately on change
138 * latitude
139     * numerical, -89.0 to 89.0 degrees with standard GPS accuracy
140     * 1Hz
141 * longitude
142     * numerical, -179.0 to 179.0 degrees with standard GPS accuracy
143     * 1Hz
144
145 License
146 =======
147
148 Copyright (c) 2012-2013 Ford Motor Company
149
150 Licensed under the BSD license.
151
152 [OpenXC]: http://openxcplatform.com