Add support for writing RTR CAN Frames to the CAN API (#1900)

This commit is contained in:
Thad House
2019-09-28 16:49:34 -07:00
committed by Peter Johnson
parent 9f740e5905
commit cb54602d49
8 changed files with 100 additions and 0 deletions

View File

@@ -147,6 +147,27 @@ void HAL_WriteCANPacketRepeating(HAL_CANHandle handle, const uint8_t* data,
can->periodicSends[apiId] = repeatMs;
}
void HAL_WriteCANRTRFrame(HAL_CANHandle handle, int32_t length, int32_t apiId,
int32_t* status) {
auto can = canHandles->Get(handle);
if (!can) {
*status = HAL_HANDLE_ERROR;
return;
}
auto id = CreateCANId(can.get(), apiId);
id |= HAL_CAN_IS_FRAME_REMOTE;
uint8_t data[8];
std::memset(data, 0, sizeof(data));
HAL_CAN_SendMessage(id, data, length, HAL_CAN_SEND_PERIOD_NO_REPEAT, status);
if (*status != 0) {
return;
}
std::scoped_lock lock(can->mapMutex);
can->periodicSends[apiId] = -1;
}
void HAL_StopCANPacketRepeating(HAL_CANHandle handle, int32_t apiId,
int32_t* status) {
auto can = canHandles->Get(handle);