dispatch.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2015-2019, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Dataspeed Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef _DBW_MKZ_CAN_DISPATCH_H
36 #define _DBW_MKZ_CAN_DISPATCH_H
37 #include <stdint.h>
38 
39 namespace dbw_mkz_can
40 {
41 
42 #pragma pack(push, 1) // Pack structures to a single byte
43 
44 typedef struct {
45  uint16_t PCMD;
46  uint8_t BCMD :1; // Only for legacy firmware
47  uint8_t ABOO :1; // Only for legacy firmware
48  uint8_t :2;
49  uint8_t CMD_TYPE :4;
50  uint8_t EN :1;
51  uint8_t CLEAR :1;
52  uint8_t IGNORE :1;
53  uint8_t :4;
54  uint8_t RES1 :1;
55  uint8_t :8;
56  uint8_t :8;
57  uint8_t :8;
58  uint8_t COUNT;
59 } MsgBrakeCmd;
60 
61 typedef struct {
62  uint16_t PI;
63  uint16_t PC;
64  uint16_t PO;
65  uint8_t BTYPE :2;
66  uint8_t BC :1;
67  uint8_t WDCBRK :1;
68  uint8_t WDCSRC :4;
69  uint8_t ENABLED :1;
70  uint8_t OVERRIDE :1;
71  uint8_t DRIVER :1;
72  uint8_t FLTWDC :1;
73  uint8_t FLT1 :1;
74  uint8_t FLT2 :1;
75  uint8_t FLTPWR :1;
76  uint8_t TMOUT :1;
78 
79 typedef struct {
80  uint16_t PCMD;
81  uint8_t :4;
82  uint8_t CMD_TYPE :4;
83  uint8_t EN :1;
84  uint8_t CLEAR :1;
85  uint8_t IGNORE :1;
86  uint8_t :4;
87  uint8_t RES1 :1;
88  uint8_t :8;
89  uint8_t :8;
90  uint8_t :8;
91  uint8_t COUNT;
93 
94 typedef struct {
95  uint16_t PI;
96  uint16_t PC;
97  uint16_t PO;
98  uint8_t :4;
99  uint8_t WDCSRC :4;
100  uint8_t ENABLED :1;
101  uint8_t OVERRIDE :1;
102  uint8_t DRIVER :1;
103  uint8_t FLTWDC :1;
104  uint8_t FLT1 :1;
105  uint8_t FLT2 :1;
106  uint8_t FLTPWR :1;
107  uint8_t TMOUT :1;
109 
110 typedef struct {
111  int16_t SCMD;
112  uint8_t EN :1;
113  uint8_t CLEAR :1;
114  uint8_t IGNORE :1;
115  uint8_t :1;
116  uint8_t QUIET :1;
117  uint8_t RES1 :1;
118  uint8_t :1;
119  uint8_t CMD_TYPE :1;
120  uint8_t SVEL;
121  uint8_t :8;
122  uint8_t :8;
123  uint8_t :8;
124  uint8_t COUNT;
126 
127 typedef struct {
128  int16_t ANGLE;
129  int16_t CMD :15;
130  uint8_t TMODE :1; // Torque mode
131  uint16_t SPEED;
132  int8_t TORQUE;
133  uint8_t ENABLED :1;
134  uint8_t OVERRIDE :1;
135  uint8_t FLTPWR :1;
136  uint8_t FLTWDC :1;
137  uint8_t FLTBUS1 :1;
138  uint8_t FLTBUS2 :1;
139  uint8_t FLTCAL :1;
140  uint8_t TMOUT :1;
142 
143 typedef struct {
144  uint8_t GCMD :3;
145  uint8_t :3;
146  uint8_t RES1 :1;
147  uint8_t CLEAR :1;
148 } MsgGearCmd;
149 
150 typedef struct {
151  uint8_t STATE :3;
152  uint8_t OVERRIDE :1;
153  uint8_t CMD :3;
154  uint8_t FLTBUS :1;
155  uint8_t REJECT :3;
156  uint8_t :5;
157 } MsgGearReport;
158 
159 typedef struct {
160  uint8_t TRNCMD :2;
161  uint8_t :6;
163 
164 typedef struct {
165  uint8_t turn_signal :2;
166  uint8_t head_light_hi :2;
167  uint8_t wiper_front :4;
168  uint8_t light_ambient :3;
169  uint8_t btn_cc_on :1;
170  uint8_t btn_cc_off :1;
171  uint8_t btn_cc_res :1;
172  uint8_t btn_cc_cncl :1;
173  uint8_t btn_cc_res_inc :1;
174  uint8_t btn_cc_on_off :1;
175  uint8_t btn_cc_res_cncl :1;
176  uint8_t btn_cc_set_inc :1;
177  uint8_t btn_cc_set_dec :1;
178  uint8_t btn_cc_gap_inc :1;
179  uint8_t btn_cc_gap_dec :1;
180  uint8_t btn_la_on_off :1;
181  uint8_t FLTBUS :1;
182  uint8_t door_driver :1;
183  uint8_t door_passenger :1;
184  uint8_t door_rear_left :1;
185  uint8_t door_rear_right :1;
186  uint8_t door_hood :1;
187  uint8_t door_trunk :1;
188  uint8_t pasngr_detect :1;
189  uint8_t pasngr_airbag :1;
190  uint8_t buckle_driver :1;
191  uint8_t buckle_pasngr :1;
192  uint8_t btn_ld_ok :1;
193  uint8_t btn_ld_up :1;
194  uint8_t btn_ld_down :1;
195  uint8_t btn_ld_left :1;
196  uint8_t btn_ld_right :1;
197  uint8_t btn_cc_res_dec :1;
198  uint8_t :1; // btn_cc_mode
199  uint8_t :1;
200  uint8_t btn_rd_ok :1;
201  uint8_t btn_rd_up :1;
202  uint8_t btn_rd_down :1;
203  uint8_t btn_rd_left :1;
204  uint8_t btn_rd_right :1;
205  uint8_t btn_media :1;
206  uint8_t btn_vol_inc :1;
207  uint8_t btn_vol_dec :1;
208  uint8_t btn_mute :1;
209  uint8_t btn_speak :1;
210  uint8_t btn_prev :1;
211  uint8_t btn_next :1;
212  uint8_t btn_call_start :1;
213  uint8_t btn_call_end :1;
214  uint8_t outside_air_temp :8;
215 } MsgMiscReport;
216 
217 typedef struct {
218  int16_t front_left;
219  int16_t front_right;
220  int16_t rear_left;
221  int16_t rear_right;
223 
224 typedef struct {
225  int16_t accel_lat;
226  int16_t accel_long;
227  int16_t accel_vert;
229 
230 typedef struct {
231  int16_t gyro_roll;
232  int16_t gyro_yaw;
233 } MsgReportGyro;
234 
235 typedef struct {
236  int32_t latitude :31;
237  int32_t lat_valid :1;
238  int32_t longitude :31;
239  int32_t long_valid :1;
240 } MsgReportGps1;
241 
242 typedef struct {
243  uint8_t utc_year :7;
244  uint8_t :1;
245  uint8_t utc_month :4;
246  uint8_t :4;
247  uint8_t utc_day :5;
248  uint8_t :3;
249  uint8_t utc_hours :5;
250  uint8_t :3;
251  uint8_t utc_minutes :6;
252  uint8_t :2;
253  uint8_t utc_seconds :6;
254  uint8_t :2;
255  uint8_t compass_dir :4;
256  uint8_t :4;
257  uint8_t pdop :5;
258  uint8_t fault :1;
259  uint8_t inferred :1;
260  uint8_t :1;
261 } MsgReportGps2;
262 
263 typedef struct {
264  int16_t altitude;
265  uint16_t heading;
266  uint8_t speed;
267  uint8_t hdop;
268  uint8_t vdop;
269  uint8_t quality :3;
270  uint8_t num_sats :5;
271 } MsgReportGps3;
272 
273 typedef struct {
274  int16_t front_left;
275  int16_t front_right;
276  int16_t rear_left;
277  int16_t rear_right;
279 
280 typedef struct {
281  uint16_t front_left;
282  uint16_t front_right;
283  uint16_t rear_left;
284  uint16_t rear_right;
286 
287 typedef struct {
288  int16_t fuel_level :11; // 0.18696 %
289  uint8_t :3;
290  uint16_t battery_hev :10; // 0.5 V
291  uint8_t battery_12v :8; // 0.0625 V
292  uint32_t odometer :24; // 0.1 km
293  uint8_t :8;
295 
296 typedef struct {
297  uint8_t l_cta_alert :1;
298  uint8_t l_cta_enabled :1;
299  uint8_t l_blis_alert :1;
300  uint8_t l_blis_enabled :1;
301  uint8_t r_cta_alert :1;
302  uint8_t r_cta_enabled :1;
303  uint8_t r_blis_alert :1;
304  uint8_t r_blis_enabled :1;
305  uint8_t sonar_00 :4;
306  uint8_t sonar_01 :4;
307  uint8_t sonar_02 :4;
308  uint8_t sonar_03 :4;
309  uint8_t sonar_04 :4;
310  uint8_t sonar_05 :4;
311  uint8_t sonar_06 :4;
312  uint8_t sonar_07 :4;
313  uint8_t sonar_08 :4;
314  uint8_t sonar_09 :4;
315  uint8_t sonar_10 :4;
316  uint8_t sonar_11 :4;
317  uint8_t :6;
318  uint8_t sonar_enabled :1;
319  uint8_t sonar_fault :1;
321 
322 typedef struct {
323  uint16_t brake_torque_request :12;
324  uint8_t hsa_stat :3;
325  uint8_t stationary :1;
326  uint16_t brake_torque_actual :12;
327  uint8_t hsa_mode :2;
328  uint8_t parking_brake :2;
329  int16_t wheel_torque :14;
330  uint8_t bped_qf :2;
331  int16_t accel_over_ground_est :10;
332  uint8_t abs_active :1;
333  uint8_t abs_enabled :1;
334  uint8_t stab_active :1;
335  uint8_t stab_enabled :1;
336  uint8_t trac_active :1;
337  uint8_t trac_enabled :1;
339 
340 typedef struct {
341  uint16_t engine_rpm :16;
342  uint16_t throttle_pc :10;
343  uint8_t :4;
344  uint8_t aped_qf :2;
345  int8_t throttle_rate :8;
346  uint8_t gear_num :5;
347  uint8_t :3;
348  uint8_t :2;
349  int16_t batt_curr :14;
351 
352 typedef struct {
353  uint8_t decel :8;
354  uint8_t decel_src :2;
355  uint8_t :1;
356  uint8_t fcw_enabled :1;
357  uint8_t fcw_active :1;
358  uint8_t aeb_enabled :1;
359  uint8_t aeb_precharge :1;
360  uint8_t aeb_braking :1;
361  uint8_t :1;
362  uint8_t acc_enabled :1;
363  uint8_t acc_braking :1;
364  uint8_t :5;
366 
367 typedef enum {
368  LIC_MUX_F0 = 0x00, // Feature 0 (BASE)
369  LIC_MUX_F1 = 0x01, // Feature 1 (CONTROL)
370  LIC_MUX_F2 = 0x02, // Feature 2 (SENSORS)
371  LIC_MUX_F3 = 0x03, // Feature 3 (unused)
372  LIC_MUX_F4 = 0x04, // Feature 4 (unused)
373  LIC_MUX_F5 = 0x05, // Feature 5 (unused)
374  LIC_MUX_F6 = 0x06, // Feature 6 (unused)
375  LIC_MUX_F7 = 0x07, // Feature 7 (unused)
378  LIC_MUX_MAC = 0x80,
381  LIC_MUX_VIN0 = 0x83,
382  LIC_MUX_VIN1 = 0x84,
383  LIC_MUX_VIN2 = 0x85,
384 } LicenseMux;
385 typedef struct {
386  uint8_t mux;
387  uint8_t ready :1;
388  uint8_t trial :1;
389  uint8_t expired :1;
390  uint8_t :1;
391  uint8_t module :4;
392  union {
393  struct {
394  uint8_t enabled :1;
395  uint8_t trial :1;
396  uint8_t :6;
397  uint8_t :8;
398  uint16_t trials_used;
399  uint16_t trials_left;
400  } license;
401  struct {
402  uint8_t ldate0;
403  uint8_t ldate1;
404  uint8_t ldate2;
405  uint8_t ldate3;
406  uint8_t ldate4;
407  uint8_t ldate5;
408  } ldate0;
409  struct {
410  uint8_t ldate6;
411  uint8_t ldate7;
412  uint8_t ldate8;
413  uint8_t ldate9;
414  uint8_t :8;
415  uint8_t :8;
416  } ldate1;
417  struct {
418  uint8_t addr0;
419  uint8_t addr1;
420  uint8_t addr2;
421  uint8_t addr3;
422  uint8_t addr4;
423  uint8_t addr5;
424  } mac;
425  struct {
426  uint8_t date0;
427  uint8_t date1;
428  uint8_t date2;
429  uint8_t date3;
430  uint8_t date4;
431  uint8_t date5;
432  } bdate0;
433  struct {
434  uint8_t date6;
435  uint8_t date7;
436  uint8_t date8;
437  uint8_t date9;
438  uint8_t :8;
439  uint8_t :8;
440  } bdate1;
441  struct {
442  uint8_t vin00;
443  uint8_t vin01;
444  uint8_t vin02;
445  uint8_t vin03;
446  uint8_t vin04;
447  uint8_t vin05;
448  } vin0;
449  struct {
450  uint8_t vin06;
451  uint8_t vin07;
452  uint8_t vin08;
453  uint8_t vin09;
454  uint8_t vin10;
455  uint8_t vin11;
456  } vin1;
457  struct {
458  uint8_t vin12;
459  uint8_t vin13;
460  uint8_t vin14;
461  uint8_t vin15;
462  uint8_t vin16;
463  uint8_t :8;
464  } vin2;
465  };
466 } MsgLicense;
467 
468 typedef struct {
469  uint8_t module;
470  uint8_t platform;
471  uint16_t major;
472  uint16_t minor;
473  uint16_t build;
474 } MsgVersion;
475 
476 #define BUILD_ASSERT(cond) do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
477 static void dispatchAssertSizes() {
478  BUILD_ASSERT(8 == sizeof(MsgBrakeCmd));
479  BUILD_ASSERT(8 == sizeof(MsgBrakeReport));
480  BUILD_ASSERT(8 == sizeof(MsgThrottleCmd));
481  BUILD_ASSERT(8 == sizeof(MsgThrottleReport));
482  BUILD_ASSERT(8 == sizeof(MsgSteeringCmd));
483  BUILD_ASSERT(8 == sizeof(MsgSteeringReport));
484  BUILD_ASSERT(1 == sizeof(MsgGearCmd));
485  BUILD_ASSERT(2 == sizeof(MsgGearReport));
486  BUILD_ASSERT(1 == sizeof(MsgTurnSignalCmd));
487  BUILD_ASSERT(8 == sizeof(MsgMiscReport));
488  BUILD_ASSERT(8 == sizeof(MsgReportWheelSpeed));
489  BUILD_ASSERT(6 == sizeof(MsgReportAccel));
490  BUILD_ASSERT(4 == sizeof(MsgReportGyro));
491  BUILD_ASSERT(8 == sizeof(MsgReportGps1));
492  BUILD_ASSERT(8 == sizeof(MsgReportGps2));
493  BUILD_ASSERT(8 == sizeof(MsgReportGps3));
494  BUILD_ASSERT(8 == sizeof(MsgReportWheelPosition));
495  BUILD_ASSERT(8 == sizeof(MsgReportTirePressure));
496  BUILD_ASSERT(8 == sizeof(MsgReportFuelLevel));
497  BUILD_ASSERT(8 == sizeof(MsgReportSurround));
498  BUILD_ASSERT(8 == sizeof(MsgReportBrakeInfo));
499  BUILD_ASSERT(8 == sizeof(MsgReportThrottleInfo));
500  BUILD_ASSERT(3 == sizeof(MsgReportDriverAssist));
501  BUILD_ASSERT(8 == sizeof(MsgLicense));
502  BUILD_ASSERT(8 == sizeof(MsgVersion));
503 }
504 #undef BUILD_ASSERT
505 
506 enum {
507  ID_BRAKE_CMD = 0x060,
513  ID_GEAR_CMD = 0x066,
514  ID_GEAR_REPORT = 0x067,
515  ID_MISC_CMD = 0x068,
516  ID_MISC_REPORT = 0x069,
519  ID_REPORT_GYRO = 0x06C,
520  ID_REPORT_GPS1 = 0x06D,
521  ID_REPORT_GPS2 = 0x06E,
522  ID_REPORT_GPS3 = 0x06F,
530  ID_LICENSE = 0x07E,
531  ID_VERSION = 0x07F,
532 };
533 
534 #pragma pack(pop) // Undo packing
535 
536 } // namespace dbw_mkz_can
537 
538 #endif // _DBW_MKZ_CAN_DISPATCH_H
539 
static void dispatchAssertSizes()
Definition: dispatch.h:477
#define BUILD_ASSERT(cond)
Definition: dispatch.h:476


dbw_mkz_can
Author(s): Kevin Hallenbeck
autogenerated on Fri May 14 2021 02:47:08