File tree 2 files changed +19
-2
lines changed
src/main/native/include/rev
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 36
36
#include < iostream>
37
37
#include < chrono>
38
38
39
+ #define NON_RESERVED_ARB_ID_MASK 0x1FFFFFFF
40
+
39
41
namespace rev {
40
42
namespace usb {
41
43
Original file line number Diff line number Diff line change 53
53
#include < hal/simulation/CanData.h>
54
54
#include < hal/CAN.h>
55
55
56
+ #define CANDLE_EXTENDED_ID_MASK 0x80000000
57
+ #define CANDLE_REMOTE_FRAME_MASK 0x40000000
58
+
56
59
namespace rev {
57
60
namespace usb {
58
61
@@ -169,8 +172,20 @@ class CandleWinUSBDeviceThread :public DriverDeviceThread {
169
172
if (el.m_intervalMs <= 1 || (now - el.m_prevTimestamp >= std::chrono::milliseconds (el.m_intervalMs )) ) {
170
173
candle_frame_t frame;
171
174
frame.can_dlc = el.m_msg .GetSize ();
172
- // set extended id flag
173
- frame.can_id = el.m_msg .GetMessageId () | 0x80000000 ;
175
+
176
+ uint32_t messageId = el.m_msg .GetMessageId () & NON_RESERVED_ARB_ID_MASK;
177
+
178
+ bool isExtended = true ; // FRC CAN is always extended
179
+ bool isRtr = messageId & HAL_CAN_IS_FRAME_REMOTE;
180
+
181
+ frame.can_id = messageId;
182
+ if (isExtended) {
183
+ frame.can_id |= CANDLE_EXTENDED_ID_MASK;
184
+ }
185
+ if (isRtr) {
186
+ frame.can_id |= CANDLE_REMOTE_FRAME_MASK;
187
+ }
188
+
174
189
memcpy (frame.data , el.m_msg .GetData (), frame.can_dlc );
175
190
frame.timestamp_us = now.time_since_epoch ().count () / 1000 ;
176
191
You can’t perform that action at this time.
0 commit comments