include
dbw_polaris_can
dispatch.h
Go to the documentation of this file.
1
/*********************************************************************
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2020, 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_POLARIS_CAN_DISPATCH_H
36
#define _DBW_POLARIS_CAN_DISPATCH_H
37
#include <stdint.h>
38
39
namespace
dbw_polaris_can
40
{
41
42
typedef
struct
{
43
uint16_t PCMD;
44
uint8_t :4;
45
uint8_t CMD_TYPE :4;
46
uint8_t EN :1;
47
uint8_t CLEAR :1;
48
uint8_t IGNORE :1;
49
uint8_t :3;
50
uint8_t RES2 :1;
51
uint8_t RES1 :1;
52
uint8_t :8;
53
uint8_t :8;
54
uint8_t :8;
55
uint8_t COUNT;
56
}
MsgBrakeCmd
;
57
58
typedef
struct
{
59
uint16_t PI;
60
uint16_t PC;
61
uint16_t PO;
62
uint8_t BTYPE :2;
63
uint8_t :1;
64
uint8_t WDCBRK :1;
65
uint8_t WDCSRC :4;
66
uint8_t ENABLED :1;
67
uint8_t OVERRIDE :1;
68
uint8_t DRIVER :1;
69
uint8_t FLTWDC :1;
70
uint8_t FLT1 :1;
71
uint8_t FLT2 :1;
72
uint8_t FLTPWR :1;
73
uint8_t TMOUT :1;
74
}
MsgBrakeReport
;
75
76
typedef
struct
{
77
uint16_t PCMD;
78
uint8_t :4;
79
uint8_t CMD_TYPE :4;
80
uint8_t EN :1;
81
uint8_t CLEAR :1;
82
uint8_t IGNORE :1;
83
uint8_t :3;
84
uint8_t RES2 :1;
85
uint8_t RES1 :1;
86
uint8_t :8;
87
uint8_t :8;
88
uint8_t :8;
89
uint8_t COUNT;
90
}
MsgThrottleCmd
;
91
92
typedef
struct
{
93
uint16_t PI;
94
uint16_t PC;
95
uint16_t PO;
96
uint8_t :4;
97
uint8_t
WDCSRC
:4;
98
uint8_t
ENABLED
:1;
99
uint8_t
OVERRIDE
:1;
100
uint8_t
DRIVER
:1;
101
uint8_t
FLTWDC
:1;
102
uint8_t
FLT1
:1;
103
uint8_t
FLT2
:1;
104
uint8_t
FLTPWR
:1;
105
uint8_t
TMOUT
:1;
106
}
MsgThrottleReport
;
107
108
typedef
struct
{
109
int16_t SCMD;
110
uint8_t
EN
:1;
111
uint8_t CLEAR :1;
112
uint8_t
IGNORE
:1;
113
uint8_t CAL :1;
114
uint8_t QUIET :1;
115
uint8_t
RES1
:1;
116
uint8_t ALERT :1;
117
uint8_t CMD_TYPE :1;
118
uint8_t SVEL;
119
uint8_t RES2 :1;
120
uint8_t :7;
121
uint8_t :8;
122
uint8_t :8;
123
uint8_t COUNT;
124
}
MsgSteeringCmd
;
125
126
typedef
struct
{
127
int16_t ANGLE;
128
int16_t CMD :15;
129
uint8_t TMODE :1;
// Torque mode
130
int16_t VEH_VEL;
131
int8_t TORQUE;
132
uint8_t ENABLED :1;
133
uint8_t OVERRIDE :1;
134
uint8_t FLTPWR :1;
135
uint8_t FLTWDC :1;
136
uint8_t FLTBUS1 :1;
137
uint8_t FLTBUS2 :1;
138
uint8_t FLTCAL :1;
139
uint8_t TMOUT :1;
140
}
MsgSteeringReport
;
141
142
typedef
struct
{
143
uint8_t GCMD :3;
144
uint8_t :2;
145
uint8_t RES2 :1;
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
int16_t accel_lat;
161
int16_t accel_long;
162
int16_t accel_vert;
163
}
MsgReportAccel
;
164
165
typedef
struct
{
166
int16_t gyro_roll;
167
int16_t gyro_yaw;
168
int16_t gyro_pitch;
169
}
MsgReportGyro
;
170
171
typedef
enum
{
172
LIC_MUX_F0
= 0x00,
// Feature 0 (BASE)
173
LIC_MUX_F1
= 0x01,
// Feature 1 (CONTROL)
174
LIC_MUX_F2
= 0x02,
// Feature 2 (SENSORS)
175
LIC_MUX_F3
= 0x03,
// Feature 3 (unused)
176
LIC_MUX_F4
= 0x04,
// Feature 4 (unused)
177
LIC_MUX_F5
= 0x05,
// Feature 5 (unused)
178
LIC_MUX_F6
= 0x06,
// Feature 6 (unused)
179
LIC_MUX_F7
= 0x07,
// Feature 7 (unused)
180
LIC_MUX_LDATE0
= 0x41,
181
LIC_MUX_LDATE1
= 0x42,
182
LIC_MUX_MAC
= 0x80,
183
LIC_MUX_BDATE0
= 0x81,
184
LIC_MUX_BDATE1
= 0x82,
185
LIC_MUX_VIN0
= 0x83,
186
LIC_MUX_VIN1
= 0x84,
187
LIC_MUX_VIN2
= 0x85,
188
}
LicenseMux
;
189
typedef
struct
{
190
uint8_t mux;
191
uint8_t ready :1;
192
uint8_t trial :1;
193
uint8_t expired :1;
194
uint8_t :1;
195
uint8_t module :4;
196
union
{
197
struct
{
198
uint8_t enabled :1;
199
uint8_t trial :1;
200
uint8_t :6;
201
uint8_t :8;
202
uint16_t trials_used;
203
uint16_t trials_left;
204
} license;
205
struct
{
206
uint8_t ldate0;
207
uint8_t ldate1;
208
uint8_t ldate2;
209
uint8_t ldate3;
210
uint8_t ldate4;
211
uint8_t ldate5;
212
} ldate0;
213
struct
{
214
uint8_t ldate6;
215
uint8_t ldate7;
216
uint8_t ldate8;
217
uint8_t ldate9;
218
uint8_t :8;
219
uint8_t :8;
220
} ldate1;
221
struct
{
222
uint8_t addr0;
223
uint8_t addr1;
224
uint8_t addr2;
225
uint8_t addr3;
226
uint8_t addr4;
227
uint8_t addr5;
228
} mac;
229
struct
{
230
uint8_t date0;
231
uint8_t date1;
232
uint8_t date2;
233
uint8_t date3;
234
uint8_t date4;
235
uint8_t date5;
236
} bdate0;
237
struct
{
238
uint8_t date6;
239
uint8_t date7;
240
uint8_t date8;
241
uint8_t date9;
242
uint8_t :8;
243
uint8_t :8;
244
} bdate1;
245
struct
{
246
uint8_t vin00;
247
uint8_t vin01;
248
uint8_t vin02;
249
uint8_t vin03;
250
uint8_t vin04;
251
uint8_t vin05;
252
} vin0;
253
struct
{
254
uint8_t vin06;
255
uint8_t vin07;
256
uint8_t vin08;
257
uint8_t vin09;
258
uint8_t vin10;
259
uint8_t vin11;
260
} vin1;
261
struct
{
262
uint8_t vin12;
263
uint8_t vin13;
264
uint8_t vin14;
265
uint8_t vin15;
266
uint8_t vin16;
267
uint8_t :8;
268
} vin2;
269
};
270
}
MsgLicense
;
271
272
typedef
struct
{
273
uint8_t module;
274
uint8_t platform;
275
uint16_t major;
276
uint16_t minor;
277
uint16_t build;
278
}
MsgVersion
;
279
280
#define BUILD_ASSERT(cond) do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
281
static
void
dispatchAssertSizes
() {
282
BUILD_ASSERT
(8 ==
sizeof
(
MsgBrakeCmd
));
283
BUILD_ASSERT
(8 ==
sizeof
(
MsgBrakeReport
));
284
BUILD_ASSERT
(8 ==
sizeof
(
MsgThrottleCmd
));
285
BUILD_ASSERT
(8 ==
sizeof
(
MsgThrottleReport
));
286
BUILD_ASSERT
(8 ==
sizeof
(
MsgSteeringCmd
));
287
BUILD_ASSERT
(8 ==
sizeof
(
MsgSteeringReport
));
288
BUILD_ASSERT
(1 ==
sizeof
(
MsgGearCmd
));
289
BUILD_ASSERT
(2 ==
sizeof
(
MsgGearReport
));
290
BUILD_ASSERT
(6 ==
sizeof
(
MsgReportAccel
));
291
BUILD_ASSERT
(6 ==
sizeof
(
MsgReportGyro
));
292
BUILD_ASSERT
(8 ==
sizeof
(
MsgLicense
));
293
BUILD_ASSERT
(8 ==
sizeof
(
MsgVersion
));
294
}
295
#undef BUILD_ASSERT
296
297
enum
{
298
ID_BRAKE_CMD
= 0x060,
299
ID_BRAKE_REPORT
= 0x061,
300
ID_THROTTLE_CMD
= 0x062,
301
ID_THROTTLE_REPORT
= 0x063,
302
ID_STEERING_CMD
= 0x064,
303
ID_STEERING_REPORT
= 0x065,
304
ID_GEAR_CMD
= 0x066,
305
ID_GEAR_REPORT
= 0x067,
306
ID_REPORT_ACCEL
= 0x06B,
307
ID_REPORT_GYRO
= 0x06C,
308
ID_LICENSE
= 0x07E,
309
ID_VERSION
= 0x07F,
310
};
311
312
}
// namespace dbw_polaris_can
313
314
#endif // _DBW_POLARIS_CAN_DISPATCH_H
315
dbw_polaris_can::LIC_MUX_MAC
@ LIC_MUX_MAC
Definition:
dispatch.h:214
dbw_polaris_can::LicenseMux
LicenseMux
Definition:
dispatch.h:203
dbw_polaris_can::LIC_MUX_F6
@ LIC_MUX_F6
Definition:
dispatch.h:210
dbw_polaris_can::MsgReportAccel
Definition:
dispatch.h:191
dbw_polaris_can::ID_LICENSE
@ ID_LICENSE
Definition:
dispatch.h:340
dbw_polaris_can::LIC_MUX_F1
@ LIC_MUX_F1
Definition:
dispatch.h:205
dbw_polaris_can::LIC_MUX_F5
@ LIC_MUX_F5
Definition:
dispatch.h:209
dbw_polaris_can::ID_STEERING_REPORT
@ ID_STEERING_REPORT
Definition:
dispatch.h:335
dbw_polaris_can::MsgBrakeReport::FLTWDC
uint8_t FLTWDC
Definition:
dispatch.h:101
dbw_polaris_can::MsgThrottleReport
Definition:
dispatch.h:124
dbw_polaris_can::LIC_MUX_BDATE1
@ LIC_MUX_BDATE1
Definition:
dispatch.h:216
dbw_polaris_can::LIC_MUX_VIN1
@ LIC_MUX_VIN1
Definition:
dispatch.h:218
dbw_polaris_can::LIC_MUX_VIN0
@ LIC_MUX_VIN0
Definition:
dispatch.h:217
dbw_polaris_can::ID_THROTTLE_REPORT
@ ID_THROTTLE_REPORT
Definition:
dispatch.h:333
dbw_polaris_can::LIC_MUX_BDATE0
@ LIC_MUX_BDATE0
Definition:
dispatch.h:215
dbw_polaris_can::LIC_MUX_F7
@ LIC_MUX_F7
Definition:
dispatch.h:211
dbw_polaris_can::MsgSteeringReport
Definition:
dispatch.h:158
dbw_polaris_can::MsgBrakeReport::WDCSRC
uint8_t WDCSRC
Definition:
dispatch.h:97
dbw_polaris_can::LIC_MUX_F3
@ LIC_MUX_F3
Definition:
dispatch.h:207
dbw_polaris_can::ID_BRAKE_CMD
@ ID_BRAKE_CMD
Definition:
dispatch.h:330
dbw_polaris_can::MsgBrakeReport::FLTPWR
uint8_t FLTPWR
Definition:
dispatch.h:104
dbw_polaris_can::MsgBrakeReport::OVERRIDE
uint8_t OVERRIDE
Definition:
dispatch.h:99
dbw_polaris_can::MsgBrakeReport::ENABLED
uint8_t ENABLED
Definition:
dispatch.h:98
dbw_polaris_can::LIC_MUX_F4
@ LIC_MUX_F4
Definition:
dispatch.h:208
dbw_polaris_can::MsgBrakeReport::FLT2
uint8_t FLT2
Definition:
dispatch.h:103
dbw_polaris_can::LIC_MUX_LDATE0
@ LIC_MUX_LDATE0
Definition:
dispatch.h:212
dbw_polaris_can::MsgLicense
Definition:
dispatch.h:221
dbw_polaris_can::LIC_MUX_F0
@ LIC_MUX_F0
Definition:
dispatch.h:204
dbw_polaris_can::MsgBrakeReport::FLT1
uint8_t FLT1
Definition:
dispatch.h:102
dbw_polaris_can::MsgBrakeCmd::IGNORE
uint8_t IGNORE
Definition:
dispatch.h:112
dbw_polaris_can::LIC_MUX_F2
@ LIC_MUX_F2
Definition:
dispatch.h:206
dbw_polaris_can::ID_REPORT_ACCEL
@ ID_REPORT_ACCEL
Definition:
dispatch.h:338
dbw_polaris_can::LIC_MUX_VIN2
@ LIC_MUX_VIN2
Definition:
dispatch.h:219
dbw_polaris_can::MsgThrottleCmd
Definition:
dispatch.h:108
dbw_polaris_can::ID_BRAKE_REPORT
@ ID_BRAKE_REPORT
Definition:
dispatch.h:331
BUILD_ASSERT
#define BUILD_ASSERT(cond)
Definition:
dispatch.h:312
dbw_polaris_can::MsgBrakeCmd
Definition:
dispatch.h:74
dbw_polaris_can::ID_VERSION
@ ID_VERSION
Definition:
dispatch.h:341
dbw_polaris_can::ID_GEAR_CMD
@ ID_GEAR_CMD
Definition:
dispatch.h:336
dbw_polaris_can::MsgReportGyro
Definition:
dispatch.h:197
dbw_polaris_can::LIC_MUX_LDATE1
@ LIC_MUX_LDATE1
Definition:
dispatch.h:213
dbw_polaris_can::MsgSteeringCmd
Definition:
dispatch.h:140
dbw_polaris_can::MsgBrakeCmd::EN
uint8_t EN
Definition:
dispatch.h:110
dbw_polaris_can
Definition:
dispatch.h:39
dbw_polaris_can::MsgBrakeReport
Definition:
dispatch.h:90
dbw_polaris_can::ID_THROTTLE_CMD
@ ID_THROTTLE_CMD
Definition:
dispatch.h:332
dbw_polaris_can::MsgVersion
Definition:
dispatch.h:304
dbw_polaris_can::MsgBrakeCmd::RES1
uint8_t RES1
Definition:
dispatch.h:115
dbw_polaris_can::dispatchAssertSizes
static void dispatchAssertSizes()
Definition:
dispatch.h:313
dbw_polaris_can::MsgBrakeReport::TMOUT
uint8_t TMOUT
Definition:
dispatch.h:105
dbw_polaris_can::ID_GEAR_REPORT
@ ID_GEAR_REPORT
Definition:
dispatch.h:337
dbw_polaris_can::MsgGearReport
Definition:
dispatch.h:182
dbw_polaris_can::MsgBrakeReport::DRIVER
uint8_t DRIVER
Definition:
dispatch.h:100
dbw_polaris_can::MsgGearCmd
Definition:
dispatch.h:174
dbw_polaris_can::ID_STEERING_CMD
@ ID_STEERING_CMD
Definition:
dispatch.h:334
dbw_polaris_can::ID_REPORT_GYRO
@ ID_REPORT_GYRO
Definition:
dispatch.h:339
dbw_polaris_can
Author(s): Kevin Hallenbeck
autogenerated on Thu Jan 4 2024 03:36:18