send ext id

This commit is contained in:
Matthew Kennedy 2020-12-12 20:06:21 -08:00
parent 614281225e
commit 05aa1a2da4
2 changed files with 4 additions and 4 deletions

View File

@ -2,8 +2,8 @@
#include <cstring> #include <cstring>
CanTxMessage::CanTxMessage(uint32_t eid, uint8_t dlc) { CanTxMessage::CanTxMessage(uint32_t eid, uint8_t dlc, bool isExtended) {
m_frame.IDE = CAN_IDE_STD; m_frame.IDE = isExtended ? CAN_IDE_EXT : CAN_IDE_STD;
m_frame.EID = eid; m_frame.EID = eid;
m_frame.RTR = CAN_RTR_DATA; m_frame.RTR = CAN_RTR_DATA;
m_frame.DLC = dlc; m_frame.DLC = dlc;
@ -12,7 +12,7 @@ CanTxMessage::CanTxMessage(uint32_t eid, uint8_t dlc) {
CanTxMessage::~CanTxMessage() { CanTxMessage::~CanTxMessage() {
// 100 ms timeout // 100 ms timeout
canTransmit(&CAND1, CAN_ANY_MAILBOX, &m_frame, TIME_MS2I(100)); canTransmitTimeout(&CAND1, CAN_ANY_MAILBOX, &m_frame, TIME_IMMEDIATE);
} }
uint8_t& CanTxMessage::operator[](size_t index) { uint8_t& CanTxMessage::operator[](size_t index) {

View File

@ -18,7 +18,7 @@ public:
/** /**
* Create a new CAN message, with the specified extended ID. * Create a new CAN message, with the specified extended ID.
*/ */
explicit CanTxMessage(uint32_t eid, uint8_t dlc = 8); explicit CanTxMessage(uint32_t eid, uint8_t dlc = 8, bool isExtended = false);
/** /**
* Destruction of an instance of CanTxMessage will transmit the message over the wire. * Destruction of an instance of CanTxMessage will transmit the message over the wire.