osMessageQueuePut blocks indefinitely when used within an ISR
STM32CubeIDE 1.17.0, using FreeRTOS (CMSISRTOS-2) on a NUCLEO-F446RE board. I am trying to call `osMessageQueuePut(...)` from an ISR (CAN RX0 Interrupt) and find my program hangs indefinitely at that call.
// Globals
const osMessageQueueAttr_t canMsgQueueAttr = {
.name = "CanMsgQueue"
};
osMessageQueueId_t canMsgQueue = nullptr;
// Create the queue
canMsgQueue = osMessageQueueNew(10, 256, &canMsgQueueAttr);
// CAN RX0 callback
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) {
char buf[128];
snprintf((char*)buf, sizeof(buf), "Got message");
osMessageQueuePut(canMsgQueue, buf, 0U, 0U); // Stuck forever
}
I'm following this documentation:
There is a note:
> May be called from Interrupt Service Routines if the parameter timeout is set to 0.
And that is what I have done. Otherwise it returns `-4`, which is consistent with the documentation:
> osErrorParameter: parameter mq_id is NULL or invalid, non-zero timeout specified in an ISR.
Feels like I'm missing something very basic - With a value of `0` I would expect it to return instantly even if it failed.
