diff --git a/hal/src/main/native/sim/CAN.cpp b/hal/src/main/native/sim/CAN.cpp index d55eafd86f..1e7af7304e 100644 --- a/hal/src/main/native/sim/CAN.cpp +++ b/hal/src/main/native/sim/CAN.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -26,8 +26,16 @@ void HAL_CAN_SendMessage(uint32_t messageID, const uint8_t* data, void HAL_CAN_ReceiveMessage(uint32_t* messageID, uint32_t messageIDMask, uint8_t* data, uint8_t* dataSize, uint32_t* timeStamp, int32_t* status) { + // Use a data size of 42 as call check. Difficult to add check to invoke + // handler + *dataSize = 42; + auto tmpStatus = *status; SimCanData->receiveMessage(messageID, messageIDMask, data, dataSize, timeStamp, status); + // If no handler invoked, return message not found + if (*dataSize == 42 && *status == tmpStatus) { + *status = HAL_ERR_CANSessionMux_MessageNotFound; + } } void HAL_CAN_OpenStreamSession(uint32_t* sessionHandle, uint32_t messageID, uint32_t messageIDMask, uint32_t maxMessages,