Skip to content

Commit

Permalink
Merge pull request #18 from karl-dietmann/main
Browse files Browse the repository at this point in the history
extending .write() for sending CAN remote frames
  • Loading branch information
pazi88 authored Oct 17, 2023
2 parents 591969c + 43b54d5 commit 33cea10
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions STM32_CAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,16 @@ bool STM32_CAN::write(CAN_message_t &CAN_tx_msg, bool sendMB)
TxHeader.IDE = CAN_ID_STD;
}

TxHeader.RTR = CAN_RTR_DATA;
TxHeader.DLC = CAN_tx_msg.len;
if (CAN_tx_msg.flags.remote == 1) // Remote frame when CAN_tx_msg.flags.remote is 1
{
TxHeader.RTR = CAN_RTR_REMOTE;
TxHeader.DLC = 0;
}
else{
TxHeader.RTR = CAN_RTR_DATA;
TxHeader.DLC = CAN_tx_msg.len;
}

TxHeader.TransmitGlobalTime = DISABLE;

if(HAL_CAN_AddTxMessage( n_pCanHandle, &TxHeader, CAN_tx_msg.buf, &TxMailbox) != HAL_OK)
Expand Down

0 comments on commit 33cea10

Please sign in to comment.