dispatch.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2015-2019, Dataspeed Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Dataspeed Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 #ifndef _DBW_MKZ_CAN_DISPATCH_H
00036 #define _DBW_MKZ_CAN_DISPATCH_H
00037 #include <stdint.h>
00038 
00039 namespace dbw_mkz_can
00040 {
00041 
00042 #pragma pack(push, 1) // Pack structures to a single byte
00043 
00044 typedef struct {
00045   uint16_t PCMD;
00046   uint8_t BCMD :1; // Only for legacy firmware
00047   uint8_t ABOO :1; // Only for legacy firmware
00048   uint8_t :2;
00049   uint8_t CMD_TYPE :4;
00050   uint8_t EN :1;
00051   uint8_t CLEAR :1;
00052   uint8_t IGNORE :1;
00053   uint8_t :4;
00054   uint8_t RES1 :1;
00055   uint8_t :8;
00056   uint8_t :8;
00057   uint8_t :8;
00058   uint8_t COUNT;
00059 } MsgBrakeCmd;
00060 
00061 typedef struct {
00062   uint16_t PI;
00063   uint16_t PC;
00064   uint16_t PO;
00065   uint8_t BTYPE :1;
00066   uint8_t BC :1;
00067   uint8_t BI :1;
00068   uint8_t WDCBRK :1;
00069   uint8_t WDCSRC :4;
00070   uint8_t ENABLED :1;
00071   uint8_t OVERRIDE :1;
00072   uint8_t DRIVER :1;
00073   uint8_t FLTWDC :1;
00074   uint8_t FLT1 :1;
00075   uint8_t FLT2 :1;
00076   uint8_t FLTPWR :1;
00077   uint8_t TMOUT :1;
00078 } MsgBrakeReport;
00079 
00080 typedef struct {
00081   uint16_t PCMD;
00082   uint8_t :4;
00083   uint8_t CMD_TYPE :4;
00084   uint8_t EN :1;
00085   uint8_t CLEAR :1;
00086   uint8_t IGNORE :1;
00087   uint8_t :4;
00088   uint8_t RES1 :1;
00089   uint8_t :8;
00090   uint8_t :8;
00091   uint8_t :8;
00092   uint8_t COUNT;
00093 } MsgThrottleCmd;
00094 
00095 typedef struct {
00096   uint16_t PI;
00097   uint16_t PC;
00098   uint16_t PO;
00099   uint8_t :4;
00100   uint8_t WDCSRC :4;
00101   uint8_t ENABLED :1;
00102   uint8_t OVERRIDE :1;
00103   uint8_t DRIVER :1;
00104   uint8_t FLTWDC :1;
00105   uint8_t FLT1 :1;
00106   uint8_t FLT2 :1;
00107   uint8_t FLTPWR :1;
00108   uint8_t TMOUT :1;
00109 } MsgThrottleReport;
00110 
00111 typedef struct {
00112   int16_t SCMD;
00113   uint8_t EN :1;
00114   uint8_t CLEAR :1;
00115   uint8_t IGNORE :1;
00116   uint8_t :1;
00117   uint8_t QUIET :1;
00118   uint8_t :2;
00119   uint8_t CMD_TYPE :1;
00120   uint8_t SVEL;
00121   uint8_t :8;
00122   uint8_t :8;
00123   uint8_t :8;
00124   uint8_t COUNT;
00125 } MsgSteeringCmd;
00126 
00127 typedef struct {
00128   int16_t ANGLE;
00129   int16_t CMD :15;
00130   uint8_t TMODE :1; // Torque mode
00131   uint16_t SPEED;
00132   int8_t TORQUE;
00133   uint8_t ENABLED :1;
00134   uint8_t OVERRIDE :1;
00135   uint8_t FLTPWR :1;
00136   uint8_t FLTWDC :1;
00137   uint8_t FLTBUS1 :1;
00138   uint8_t FLTBUS2 :1;
00139   uint8_t FLTCAL :1;
00140   uint8_t TMOUT :1;
00141 } MsgSteeringReport;
00142 
00143 typedef struct {
00144   uint8_t GCMD :3;
00145   uint8_t :4;
00146   uint8_t CLEAR :1;
00147 } MsgGearCmd;
00148 
00149 typedef struct {
00150   uint8_t STATE :3;
00151   uint8_t OVERRIDE :1;
00152   uint8_t CMD :3;
00153   uint8_t FLTBUS :1;
00154   uint8_t REJECT :3;
00155   uint8_t :5;
00156 } MsgGearReport;
00157 
00158 typedef struct {
00159   uint8_t TRNCMD :2;
00160   uint8_t :6;
00161 } MsgTurnSignalCmd;
00162 
00163 typedef struct {
00164   uint8_t turn_signal :2;
00165   uint8_t head_light_hi :2;
00166   uint8_t wiper_front :4;
00167   uint8_t light_ambient :3;
00168   uint8_t btn_cc_on :1;
00169   uint8_t btn_cc_off :1;
00170   uint8_t btn_cc_res :1;
00171   uint8_t btn_cc_cncl :1;
00172   uint8_t btn_cc_res_inc :1;
00173   uint8_t btn_cc_on_off :1;
00174   uint8_t btn_cc_res_cncl :1;
00175   uint8_t btn_cc_set_inc :1;
00176   uint8_t btn_cc_set_dec :1;
00177   uint8_t btn_cc_gap_inc :1;
00178   uint8_t btn_cc_gap_dec :1;
00179   uint8_t btn_la_on_off :1;
00180   uint8_t FLTBUS :1;
00181   uint8_t door_driver :1;
00182   uint8_t door_passenger :1;
00183   uint8_t door_rear_left :1;
00184   uint8_t door_rear_right :1;
00185   uint8_t door_hood :1;
00186   uint8_t door_trunk :1;
00187   uint8_t pasngr_detect :1;
00188   uint8_t pasngr_airbag :1;
00189   uint8_t buckle_driver :1;
00190   uint8_t buckle_pasngr :1;
00191   uint8_t btn_ld_ok :1;
00192   uint8_t btn_ld_up :1;
00193   uint8_t btn_ld_down :1;
00194   uint8_t btn_ld_left :1;
00195   uint8_t btn_ld_right :1;
00196   uint8_t btn_cc_res_dec :1;
00197   uint8_t :8;
00198   uint8_t :8;
00199   uint8_t outside_air_temp :8;
00200 } MsgMiscReport;
00201 
00202 typedef struct {
00203   int16_t front_left;
00204   int16_t front_right;
00205   int16_t rear_left;
00206   int16_t rear_right;
00207 } MsgReportWheelSpeed;
00208 
00209 typedef struct {
00210   int16_t accel_lat;
00211   int16_t accel_long;
00212   int16_t accel_vert;
00213 } MsgReportAccel;
00214 
00215 typedef struct {
00216   int16_t gyro_roll;
00217   int16_t gyro_yaw;
00218 } MsgReportGyro;
00219 
00220 typedef struct {
00221   int32_t latitude :31;
00222   int32_t lat_valid :1;
00223   int32_t longitude :31;
00224   int32_t long_valid :1;
00225 } MsgReportGps1;
00226 
00227 typedef struct {
00228   uint8_t utc_year :7;
00229   uint8_t :1;
00230   uint8_t utc_month :4;
00231   uint8_t :4;
00232   uint8_t utc_day :5;
00233   uint8_t :3;
00234   uint8_t utc_hours :5;
00235   uint8_t :3;
00236   uint8_t utc_minutes :6;
00237   uint8_t :2;
00238   uint8_t utc_seconds :6;
00239   uint8_t :2;
00240   uint8_t compass_dir :4;
00241   uint8_t :4;
00242   uint8_t pdop :5;
00243   uint8_t fault :1;
00244   uint8_t inferred :1;
00245   uint8_t :1;
00246 } MsgReportGps2;
00247 
00248 typedef struct {
00249   int16_t altitude;
00250   uint16_t heading;
00251   uint8_t speed;
00252   uint8_t hdop;
00253   uint8_t vdop;
00254   uint8_t quality :3;
00255   uint8_t num_sats :5;
00256 } MsgReportGps3;
00257 
00258 typedef struct {
00259   int16_t front_left;
00260   int16_t front_right;
00261   int16_t rear_left;
00262   int16_t rear_right;
00263 } MsgReportWheelPosition;
00264 
00265 typedef struct {
00266   uint16_t front_left;
00267   uint16_t front_right;
00268   uint16_t rear_left;
00269   uint16_t rear_right;
00270 } MsgReportTirePressure;
00271 
00272 typedef struct {
00273   int16_t  fuel_level :11;    // 0.18696 %
00274   uint8_t :3;
00275   uint16_t battery_hev :10;   // 0.5 V
00276   uint8_t  battery_12v :8;    // 0.0625 V
00277   uint32_t odometer :24;      // 0.1 km
00278   uint8_t :8;
00279 } MsgReportFuelLevel;
00280 
00281 typedef struct {
00282   uint8_t l_cta_alert :1;
00283   uint8_t l_cta_enabled :1;
00284   uint8_t l_blis_alert :1;
00285   uint8_t l_blis_enabled :1;
00286   uint8_t r_cta_alert :1;
00287   uint8_t r_cta_enabled :1;
00288   uint8_t r_blis_alert :1;
00289   uint8_t r_blis_enabled :1;
00290   uint8_t sonar_00 :4;
00291   uint8_t sonar_01 :4;
00292   uint8_t sonar_02 :4;
00293   uint8_t sonar_03 :4;
00294   uint8_t sonar_04 :4;
00295   uint8_t sonar_05 :4;
00296   uint8_t sonar_06 :4;
00297   uint8_t sonar_07 :4;
00298   uint8_t sonar_08 :4;
00299   uint8_t sonar_09 :4;
00300   uint8_t sonar_10 :4;
00301   uint8_t sonar_11 :4;
00302   uint8_t :6;
00303   uint8_t sonar_enabled :1;
00304   uint8_t sonar_fault :1;
00305 } MsgReportSurround;
00306 
00307 typedef struct {
00308   uint16_t brake_torque_request :12;
00309   uint8_t hsa_stat :3;
00310   uint8_t stationary :1;
00311   uint16_t brake_torque_actual :12;
00312   uint8_t hsa_mode :2;
00313   uint8_t parking_brake :2;
00314   int16_t wheel_torque :14;
00315   uint8_t bped_qf :2;
00316   int16_t accel_over_ground_est :10;
00317   uint8_t abs_active :1;
00318   uint8_t abs_enabled :1;
00319   uint8_t stab_active :1;
00320   uint8_t stab_enabled :1;
00321   uint8_t trac_active :1;
00322   uint8_t trac_enabled :1;
00323 } MsgReportBrakeInfo;
00324 
00325 typedef struct {
00326   uint16_t engine_rpm :16;
00327   uint16_t throttle_pc :10;
00328   uint8_t :4;
00329   uint8_t aped_qf :2;
00330   int8_t throttle_rate :8;
00331   uint8_t :8;
00332   uint8_t :8;
00333   uint8_t :8;
00334 } MsgReportThrottleInfo;
00335 
00336 typedef struct {
00337   uint8_t decel :8;
00338   uint8_t decel_src :2;
00339   uint8_t :1;
00340   uint8_t fcw_enabled :1;
00341   uint8_t fcw_active :1;
00342   uint8_t aeb_enabled :1;
00343   uint8_t aeb_precharge :1;
00344   uint8_t aeb_braking :1;
00345   uint8_t :1;
00346   uint8_t acc_enabled :1;
00347   uint8_t acc_braking :1;
00348   uint8_t :5;
00349 } MsgReportDriverAssist;
00350 
00351 typedef enum {
00352   LIC_MUX_F0 = 0x00, // Feature 0 (Main)
00353   LIC_MUX_MAC   = 0x80,
00354   LIC_MUX_DATE0 = 0x81,
00355   LIC_MUX_DATE1 = 0x82,
00356   LIC_MUX_VIN0  = 0x83,
00357   LIC_MUX_VIN1  = 0x84,
00358   LIC_MUX_VIN2  = 0x85,
00359 } LicenseMux;
00360 typedef struct {
00361   uint8_t mux;
00362   uint8_t ready :1;
00363   uint8_t trial :1;
00364   uint8_t expired :1;
00365   uint8_t :5;
00366   union {
00367     struct {
00368       uint8_t enabled :1;
00369       uint8_t trial :1;
00370       uint8_t :6;
00371       uint8_t :8;
00372       uint16_t trials_used;
00373       uint16_t trials_left;
00374     } license;
00375     struct {
00376       uint8_t addr0;
00377       uint8_t addr1;
00378       uint8_t addr2;
00379       uint8_t addr3;
00380       uint8_t addr4;
00381       uint8_t addr5;
00382     } mac;
00383     struct {
00384       uint8_t date0;
00385       uint8_t date1;
00386       uint8_t date2;
00387       uint8_t date3;
00388       uint8_t date4;
00389       uint8_t date5;
00390     } date0;
00391     struct {
00392       uint8_t date6;
00393       uint8_t date7;
00394       uint8_t date8;
00395       uint8_t date9;
00396       uint8_t :8;
00397       uint8_t :8;
00398     } date1;
00399     struct {
00400       uint8_t vin00;
00401       uint8_t vin01;
00402       uint8_t vin02;
00403       uint8_t vin03;
00404       uint8_t vin04;
00405       uint8_t vin05;
00406     } vin0;
00407     struct {
00408       uint8_t vin06;
00409       uint8_t vin07;
00410       uint8_t vin08;
00411       uint8_t vin09;
00412       uint8_t vin10;
00413       uint8_t vin11;
00414     } vin1;
00415     struct {
00416       uint8_t vin12;
00417       uint8_t vin13;
00418       uint8_t vin14;
00419       uint8_t vin15;
00420       uint8_t vin16;
00421       uint8_t :8;
00422     } vin2;
00423   };
00424 } MsgLicense;
00425 
00426 typedef struct {
00427   uint8_t module;
00428   uint8_t platform;
00429   uint16_t major;
00430   uint16_t minor;
00431   uint16_t build;
00432 } MsgVersion;
00433 
00434 #define BUILD_ASSERT(cond) do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
00435 static void dispatchAssertSizes() {
00436   BUILD_ASSERT(8 == sizeof(MsgBrakeCmd));
00437   BUILD_ASSERT(8 == sizeof(MsgBrakeReport));
00438   BUILD_ASSERT(8 == sizeof(MsgThrottleCmd));
00439   BUILD_ASSERT(8 == sizeof(MsgThrottleReport));
00440   BUILD_ASSERT(8 == sizeof(MsgSteeringCmd));
00441   BUILD_ASSERT(8 == sizeof(MsgSteeringReport));
00442   BUILD_ASSERT(1 == sizeof(MsgGearCmd));
00443   BUILD_ASSERT(2 == sizeof(MsgGearReport));
00444   BUILD_ASSERT(1 == sizeof(MsgTurnSignalCmd));
00445   BUILD_ASSERT(8 == sizeof(MsgMiscReport));
00446   BUILD_ASSERT(8 == sizeof(MsgReportWheelSpeed));
00447   BUILD_ASSERT(6 == sizeof(MsgReportAccel));
00448   BUILD_ASSERT(4 == sizeof(MsgReportGyro));
00449   BUILD_ASSERT(8 == sizeof(MsgReportGps1));
00450   BUILD_ASSERT(8 == sizeof(MsgReportGps2));
00451   BUILD_ASSERT(8 == sizeof(MsgReportGps3));
00452   BUILD_ASSERT(8 == sizeof(MsgReportWheelPosition));
00453   BUILD_ASSERT(8 == sizeof(MsgReportTirePressure));
00454   BUILD_ASSERT(8 == sizeof(MsgReportFuelLevel));
00455   BUILD_ASSERT(8 == sizeof(MsgReportSurround));
00456   BUILD_ASSERT(8 == sizeof(MsgReportBrakeInfo));
00457   BUILD_ASSERT(8 == sizeof(MsgReportThrottleInfo));
00458   BUILD_ASSERT(3 == sizeof(MsgReportDriverAssist));
00459   BUILD_ASSERT(8 == sizeof(MsgLicense));
00460   BUILD_ASSERT(8 == sizeof(MsgVersion));
00461 }
00462 #undef BUILD_ASSERT
00463 
00464 enum {
00465   ID_BRAKE_CMD              = 0x060,
00466   ID_BRAKE_REPORT           = 0x061,
00467   ID_THROTTLE_CMD           = 0x062,
00468   ID_THROTTLE_REPORT        = 0x063,
00469   ID_STEERING_CMD           = 0x064,
00470   ID_STEERING_REPORT        = 0x065,
00471   ID_GEAR_CMD               = 0x066,
00472   ID_GEAR_REPORT            = 0x067,
00473   ID_MISC_CMD               = 0x068,
00474   ID_MISC_REPORT            = 0x069,
00475   ID_REPORT_WHEEL_SPEED     = 0x06A,
00476   ID_REPORT_ACCEL           = 0x06B,
00477   ID_REPORT_GYRO            = 0x06C,
00478   ID_REPORT_GPS1            = 0x06D,
00479   ID_REPORT_GPS2            = 0x06E,
00480   ID_REPORT_GPS3            = 0x06F,
00481   ID_REPORT_WHEEL_POSITION  = 0x070,
00482   ID_REPORT_TIRE_PRESSURE   = 0x071,
00483   ID_REPORT_FUEL_LEVEL      = 0x072,
00484   ID_REPORT_SURROUND        = 0x073,
00485   ID_REPORT_BRAKE_INFO      = 0x074,
00486   ID_REPORT_THROTTLE_INFO   = 0x075,
00487   ID_REPORT_DRIVER_ASSIST   = 0x079,
00488   ID_LICENSE                = 0x07E,
00489   ID_VERSION                = 0x07F,
00490 };
00491 
00492 #pragma pack(pop) // Undo packing
00493 
00494 } // namespace dbw_mkz_can
00495 
00496 #endif // _DBW_MKZ_CAN_DISPATCH_H
00497 


dbw_mkz_can
Author(s): Kevin Hallenbeck
autogenerated on Thu Jul 4 2019 20:08:17