File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
libraries/Arduino_CAN/src Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -190,9 +190,11 @@ int R7FA6M5_CAN::disableInternalLoopback()
190
190
191
191
int R7FA6M5_CAN::write (CanMsg const & msg)
192
192
{
193
+ bool const is_standard_id = msg.isStandardId ();
194
+
193
195
can_frame_t can_msg = {
194
- /* id = */ msg.id ,
195
- /* id_mode = */ CAN_ID_MODE_EXTENDED,
196
+ /* id = */ is_standard_id ? msg.getStandardId () : msg. getExtendedId () ,
197
+ /* id_mode = */ is_standard_id ? CAN_ID_MODE_STANDARD : CAN_ID_MODE_EXTENDED,
196
198
/* type = */ CAN_FRAME_TYPE_DATA,
197
199
/* data_length_code = */ min (msg.data_length , CAN_DATA_BUFFER_LENGTH),
198
200
/* options = */ 0 /* This ensures that CAN Classic is used. */
@@ -221,7 +223,7 @@ size_t R7FA6M5_CAN::available()
221
223
/* Extract the received CAN message. */
222
224
CanMsg const msg
223
225
(
224
- frame.id ,
226
+ ( frame.id_mode == CAN_ID_MODE_STANDARD) ? CanStandardId (frame. id ) : CanExtendedId (frame. id ) ,
225
227
frame.data_length_code ,
226
228
frame.data
227
229
);
@@ -247,7 +249,7 @@ void R7FA6M5_CAN::onCanFDCallback(can_callback_args_t * p_args)
247
249
/* Extract the received CAN message. */
248
250
CanMsg const msg
249
251
(
250
- p_args->frame .id ,
252
+ ( p_args->frame .id_mode == CAN_ID_MODE_STANDARD) ? CanStandardId (p_args-> frame . id ) : CanExtendedId (p_args-> frame . id ) ,
251
253
p_args->frame .data_length_code ,
252
254
p_args->frame .data
253
255
);
You can’t perform that action at this time.
0 commit comments