2020-09-19 16:50:55 -07:00
|
|
|
#include "can_helper.h"
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
CanTxMessage::CanTxMessage(uint32_t eid, uint8_t dlc) {
|
|
|
|
m_frame.IDE = CAN_IDE_STD;
|
|
|
|
m_frame.EID = eid;
|
|
|
|
m_frame.RTR = CAN_RTR_DATA;
|
|
|
|
m_frame.DLC = dlc;
|
|
|
|
memset(m_frame.data8, 0, sizeof(m_frame.data8));
|
|
|
|
}
|
|
|
|
|
|
|
|
CanTxMessage::~CanTxMessage() {
|
|
|
|
// 100 ms timeout
|
2020-09-19 20:32:33 -07:00
|
|
|
canTransmit(&CAND1, CAN_ANY_MAILBOX, &m_frame, TIME_MS2I(100));
|
2020-09-19 16:50:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t& CanTxMessage::operator[](size_t index) {
|
|
|
|
return m_frame.data8[index];
|
2020-12-08 23:16:47 -08:00
|
|
|
}
|