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 :3;
54  uint8_t RES2 :1;
55  uint8_t RES1 :1;
56  uint8_t :8;
57  uint8_t :8;
58  uint8_t :8;
59  uint8_t COUNT;
60 } MsgBrakeCmd;
61 
62 typedef struct {
63  uint16_t PI;
64  uint16_t PC;
65  uint16_t PO;
66  uint8_t BTYPE :2;
67  uint8_t BC :1;
68  uint8_t WDCBRK :1;
69  uint8_t WDCSRC :4;
70  uint8_t ENABLED :1;
71  uint8_t OVERRIDE :1;
72  uint8_t DRIVER :1;
73  uint8_t FLTWDC :1;
74  uint8_t FLT1 :1;
75  uint8_t FLT2 :1;
76  uint8_t FLTPWR :1;
77  uint8_t TMOUT :1;
79 
80 typedef struct {
81  uint16_t PCMD;
82  uint8_t :4;
83  uint8_t CMD_TYPE :4;
84  uint8_t EN :1;
85  uint8_t CLEAR :1;
86  uint8_t IGNORE :1;
87  uint8_t :3;
88  uint8_t RES2 :1;
89  uint8_t RES1 :1;
90  uint8_t :8;
91  uint8_t :8;
92  uint8_t :8;
93  uint8_t COUNT;
95 
96 typedef struct {
97  uint16_t PI;
98  uint16_t PC;
99  uint16_t PO;
100  uint8_t :4;
101  uint8_t WDCSRC :4;
102  uint8_t ENABLED :1;
103  uint8_t OVERRIDE :1;
104  uint8_t DRIVER :1;
105  uint8_t FLTWDC :1;
106  uint8_t FLT1 :1;
107  uint8_t FLT2 :1;
108  uint8_t FLTPWR :1;
109  uint8_t TMOUT :1;
111 
112 typedef struct {
113  int16_t SCMD;
114  uint8_t EN :1;
115  uint8_t CLEAR :1;
116  uint8_t IGNORE :1;
117  uint8_t :1;
118  uint8_t QUIET :1;
119  uint8_t RES1 :1;
120  uint8_t ALERT :1;
121  uint8_t CMD_TYPE :1;
122  uint8_t SVEL;
123  uint8_t RES2 :1;
124  uint8_t :7;
125  uint8_t :8;
126  uint8_t :8;
127  uint8_t COUNT;
129 
130 typedef struct {
131  int16_t ANGLE;
132  int16_t CMD :15;
133  uint8_t TMODE :1; // Torque mode
134  int16_t VEH_VEL;
135  int8_t TORQUE;
136  uint8_t ENABLED :1;
137  uint8_t OVERRIDE :1;
138  uint8_t FLTPWR :1;
139  uint8_t FLTWDC :1;
140  uint8_t FLTBUS1 :1;
141  uint8_t FLTBUS2 :1;
142  uint8_t FLTCAL :1;
143  uint8_t TMOUT :1;
145 
146 typedef struct {
147  uint8_t GCMD :3;
148  uint8_t :2;
149  uint8_t RES2 :1;
150  uint8_t RES1 :1;
151  uint8_t CLEAR :1;
152 } MsgGearCmd;
153 
154 typedef struct {
155  uint8_t STATE :3;
156  uint8_t OVERRIDE :1;
157  uint8_t CMD :3;
158  uint8_t FLTBUS :1;
159  uint8_t REJECT :3;
160  uint8_t :4;
161  uint8_t READY :1;
162 } MsgGearReport;
163 
164 typedef struct {
165  uint8_t TRNCMD :2;
166  uint8_t PBRKCMD :2;
167  uint8_t :4;
168 } MsgMiscCmd;
169 typedef MsgMiscCmd MsgTurnSignalCmd; // Backwards compatiblity
170 
171 typedef struct {
172  uint8_t turn_signal :2;
173  uint8_t head_light_hi :2;
174  uint8_t wiper_front :4;
175  uint8_t light_ambient :3;
176  uint8_t btn_cc_on :1;
177  uint8_t btn_cc_off :1;
178  uint8_t btn_cc_res :1;
179  uint8_t btn_cc_cncl :1;
180  uint8_t btn_cc_res_inc :1;
181  uint8_t btn_cc_on_off :1;
182  uint8_t btn_cc_res_cncl :1;
183  uint8_t btn_cc_set_inc :1;
184  uint8_t btn_cc_set_dec :1;
185  uint8_t btn_cc_gap_inc :1;
186  uint8_t btn_cc_gap_dec :1;
187  uint8_t btn_la_on_off :1;
188  uint8_t FLTBUS :1;
189  uint8_t door_driver :1;
190  uint8_t door_passenger :1;
191  uint8_t door_rear_left :1;
192  uint8_t door_rear_right :1;
193  uint8_t door_hood :1;
194  uint8_t door_trunk :1;
195  uint8_t pasngr_detect :1;
196  uint8_t pasngr_airbag :1;
197  uint8_t buckle_driver :1;
198  uint8_t buckle_pasngr :1;
199  uint8_t btn_ld_ok :1;
200  uint8_t btn_ld_up :1;
201  uint8_t btn_ld_down :1;
202  uint8_t btn_ld_left :1;
203  uint8_t btn_ld_right :1;
204  uint8_t btn_cc_res_dec :1;
205  uint8_t :1; // btn_cc_mode
206  uint8_t :1;
207  uint8_t btn_rd_ok :1;
208  uint8_t btn_rd_up :1;
209  uint8_t btn_rd_down :1;
210  uint8_t btn_rd_left :1;
211  uint8_t btn_rd_right :1;
212  uint8_t btn_media :1;
213  uint8_t btn_vol_inc :1;
214  uint8_t btn_vol_dec :1;
215  uint8_t btn_mute :1;
216  uint8_t btn_speak :1;
217  uint8_t btn_prev :1;
218  uint8_t btn_next :1;
219  uint8_t btn_call_start :1;
220  uint8_t btn_call_end :1;
221  uint8_t outside_air_temp :8;
222 } MsgMiscReport;
223 
224 typedef struct {
225  int16_t front_left;
226  int16_t front_right;
227  int16_t rear_left;
228  int16_t rear_right;
230 
231 typedef struct {
232  int16_t accel_lat;
233  int16_t accel_long;
234  int16_t accel_vert;
236 
237 typedef struct {
238  int16_t gyro_roll;
239  int16_t gyro_yaw;
240 } MsgReportGyro;
241 
242 typedef struct {
243  int32_t latitude :31;
244  int32_t lat_valid :1;
245  int32_t longitude :31;
246  int32_t long_valid :1;
247 } MsgReportGps1;
248 
249 typedef struct {
250  uint8_t utc_year :7;
251  uint8_t :1;
252  uint8_t utc_month :4;
253  uint8_t :4;
254  uint8_t utc_day :5;
255  uint8_t :3;
256  uint8_t utc_hours :5;
257  uint8_t :3;
258  uint8_t utc_minutes :6;
259  uint8_t :2;
260  uint8_t utc_seconds :6;
261  uint8_t :2;
262  uint8_t compass_dir :4;
263  uint8_t :4;
264  uint8_t pdop :5;
265  uint8_t fault :1;
266  uint8_t inferred :1;
267  uint8_t :1;
268 } MsgReportGps2;
269 
270 typedef struct {
271  int16_t altitude;
272  uint16_t heading;
273  uint8_t speed;
274  uint8_t hdop;
275  uint8_t vdop;
276  uint8_t quality :3;
277  uint8_t num_sats :5;
278 } MsgReportGps3;
279 
280 typedef struct {
281  int16_t front_left;
282  int16_t front_right;
283  int16_t rear_left;
284  int16_t rear_right;
286 
287 typedef struct {
288  uint16_t front_left;
289  uint16_t front_right;
290  uint16_t rear_left;
291  uint16_t rear_right;
293 
294 typedef struct {
295  int16_t fuel_level :11; // 0.18696 %
296  uint8_t :3;
297  uint16_t battery_hev :10; // 0.5 V
298  uint8_t battery_12v :8; // 0.0625 V
299  uint32_t odometer :24; // 0.1 km
300  uint8_t :8;
302 
303 typedef struct {
304  uint8_t l_cta_alert :1;
305  uint8_t l_cta_enabled :1;
306  uint8_t l_blis_alert :1;
307  uint8_t l_blis_enabled :1;
308  uint8_t r_cta_alert :1;
309  uint8_t r_cta_enabled :1;
310  uint8_t r_blis_alert :1;
311  uint8_t r_blis_enabled :1;
312  uint8_t sonar_00 :4;
313  uint8_t sonar_01 :4;
314  uint8_t sonar_02 :4;
315  uint8_t sonar_03 :4;
316  uint8_t sonar_04 :4;
317  uint8_t sonar_05 :4;
318  uint8_t sonar_06 :4;
319  uint8_t sonar_07 :4;
320  uint8_t sonar_08 :4;
321  uint8_t sonar_09 :4;
322  uint8_t sonar_10 :4;
323  uint8_t sonar_11 :4;
324  uint8_t :6;
325  uint8_t sonar_enabled :1;
326  uint8_t sonar_fault :1;
328 
329 typedef struct {
330  uint16_t brake_torque_request :12;
331  uint8_t hsa_stat :3;
332  uint8_t stationary :1;
333  uint16_t brake_torque_actual :12;
334  uint8_t hsa_mode :2;
335  uint8_t parking_brake :2;
336  int16_t wheel_torque :14;
337  uint8_t bped_qf :2;
339  uint8_t abs_active :1;
340  uint8_t abs_enabled :1;
341  uint8_t stab_active :1;
342  uint8_t stab_enabled :1;
343  uint8_t trac_active :1;
344  uint8_t trac_enabled :1;
346 
347 typedef struct {
348  uint16_t engine_rpm :16;
349  uint16_t throttle_pc :10;
350  uint8_t :4;
351  uint8_t aped_qf :2;
352  int8_t throttle_rate :8;
353  uint8_t gear_num :5;
354  uint8_t :3;
355  uint8_t ign_stat :2;
356  int16_t batt_curr :14;
358 
359 typedef struct {
360  uint8_t decel :8;
361  uint8_t decel_src :2;
362  uint8_t :1;
363  uint8_t fcw_enabled :1;
364  uint8_t fcw_active :1;
365  uint8_t aeb_enabled :1;
366  uint8_t aeb_precharge :1;
367  uint8_t aeb_braking :1;
368  uint8_t :1;
369  uint8_t acc_enabled :1;
370  uint8_t acc_braking :1;
371  uint8_t :5;
373 
374 typedef enum {
375  LIC_MUX_F0 = 0x00, // Feature 0 (BASE)
376  LIC_MUX_F1 = 0x01, // Feature 1 (CONTROL)
377  LIC_MUX_F2 = 0x02, // Feature 2 (SENSORS)
378  LIC_MUX_F3 = 0x03, // Feature 3 (unused)
379  LIC_MUX_F4 = 0x04, // Feature 4 (unused)
380  LIC_MUX_F5 = 0x05, // Feature 5 (unused)
381  LIC_MUX_F6 = 0x06, // Feature 6 (unused)
382  LIC_MUX_F7 = 0x07, // Feature 7 (unused)
385  LIC_MUX_MAC = 0x80,
388  LIC_MUX_VIN0 = 0x83,
389  LIC_MUX_VIN1 = 0x84,
390  LIC_MUX_VIN2 = 0x85,
391 } LicenseMux;
392 typedef struct {
393  uint8_t mux;
394  uint8_t ready :1;
395  uint8_t trial :1;
396  uint8_t expired :1;
397  uint8_t :1;
398  uint8_t module :4;
399  union {
400  struct {
401  uint8_t enabled :1;
402  uint8_t trial :1;
403  uint8_t :6;
404  uint8_t :8;
405  uint16_t trials_used;
406  uint16_t trials_left;
407  } license;
408  struct {
409  uint8_t ldate0;
410  uint8_t ldate1;
411  uint8_t ldate2;
412  uint8_t ldate3;
413  uint8_t ldate4;
414  uint8_t ldate5;
415  } ldate0;
416  struct {
417  uint8_t ldate6;
418  uint8_t ldate7;
419  uint8_t ldate8;
420  uint8_t ldate9;
421  uint8_t :8;
422  uint8_t :8;
423  } ldate1;
424  struct {
425  uint8_t addr0;
426  uint8_t addr1;
427  uint8_t addr2;
428  uint8_t addr3;
429  uint8_t addr4;
430  uint8_t addr5;
431  } mac;
432  struct {
433  uint8_t date0;
434  uint8_t date1;
435  uint8_t date2;
436  uint8_t date3;
437  uint8_t date4;
438  uint8_t date5;
439  } bdate0;
440  struct {
441  uint8_t date6;
442  uint8_t date7;
443  uint8_t date8;
444  uint8_t date9;
445  uint8_t :8;
446  uint8_t :8;
447  } bdate1;
448  struct {
449  uint8_t vin00;
450  uint8_t vin01;
451  uint8_t vin02;
452  uint8_t vin03;
453  uint8_t vin04;
454  uint8_t vin05;
455  } vin0;
456  struct {
457  uint8_t vin06;
458  uint8_t vin07;
459  uint8_t vin08;
460  uint8_t vin09;
461  uint8_t vin10;
462  uint8_t vin11;
463  } vin1;
464  struct {
465  uint8_t vin12;
466  uint8_t vin13;
467  uint8_t vin14;
468  uint8_t vin15;
469  uint8_t vin16;
470  uint8_t :8;
471  } vin2;
472  };
473 } MsgLicense;
474 
475 typedef struct {
476  uint8_t module;
477  uint8_t platform;
478  uint16_t major;
479  uint16_t minor;
480  uint16_t build;
481 } MsgVersion;
482 
483 #define BUILD_ASSERT(cond) do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
484 static void dispatchAssertSizes() {
485  BUILD_ASSERT(8 == sizeof(MsgBrakeCmd));
486  BUILD_ASSERT(8 == sizeof(MsgBrakeReport));
487  BUILD_ASSERT(8 == sizeof(MsgThrottleCmd));
488  BUILD_ASSERT(8 == sizeof(MsgThrottleReport));
489  BUILD_ASSERT(8 == sizeof(MsgSteeringCmd));
490  BUILD_ASSERT(8 == sizeof(MsgSteeringReport));
491  BUILD_ASSERT(1 == sizeof(MsgGearCmd));
492  BUILD_ASSERT(2 == sizeof(MsgGearReport));
493  BUILD_ASSERT(1 == sizeof(MsgMiscCmd));
494  BUILD_ASSERT(8 == sizeof(MsgMiscReport));
495  BUILD_ASSERT(8 == sizeof(MsgReportWheelSpeed));
496  BUILD_ASSERT(6 == sizeof(MsgReportAccel));
497  BUILD_ASSERT(4 == sizeof(MsgReportGyro));
498  BUILD_ASSERT(8 == sizeof(MsgReportGps1));
499  BUILD_ASSERT(8 == sizeof(MsgReportGps2));
500  BUILD_ASSERT(8 == sizeof(MsgReportGps3));
501  BUILD_ASSERT(8 == sizeof(MsgReportWheelPosition));
502  BUILD_ASSERT(8 == sizeof(MsgReportTirePressure));
503  BUILD_ASSERT(8 == sizeof(MsgReportFuelLevel));
504  BUILD_ASSERT(8 == sizeof(MsgReportSurround));
505  BUILD_ASSERT(8 == sizeof(MsgReportBrakeInfo));
506  BUILD_ASSERT(8 == sizeof(MsgReportThrottleInfo));
507  BUILD_ASSERT(3 == sizeof(MsgReportDriverAssist));
508  BUILD_ASSERT(8 == sizeof(MsgLicense));
509  BUILD_ASSERT(8 == sizeof(MsgVersion));
510 }
511 #undef BUILD_ASSERT
512 
513 enum {
514  ID_BRAKE_CMD = 0x060,
520  ID_GEAR_CMD = 0x066,
521  ID_GEAR_REPORT = 0x067,
522  ID_MISC_CMD = 0x068,
523  ID_MISC_REPORT = 0x069,
526  ID_REPORT_GYRO = 0x06C,
527  ID_REPORT_GPS1 = 0x06D,
528  ID_REPORT_GPS2 = 0x06E,
529  ID_REPORT_GPS3 = 0x06F,
537  ID_LICENSE = 0x07E,
538  ID_VERSION = 0x07F,
539 };
540 
541 #pragma pack(pop) // Undo packing
542 
543 } // namespace dbw_mkz_can
544 
545 #endif // _DBW_MKZ_CAN_DISPATCH_H
546 
static void dispatchAssertSizes()
Definition: dispatch.h:484
#define BUILD_ASSERT(cond)
Definition: dispatch.h:483
MsgMiscCmd MsgTurnSignalCmd
Definition: dispatch.h:169


dbw_mkz_can
Author(s): Kevin Hallenbeck
autogenerated on Fri Jun 16 2023 02:54:50