Hi to all! I’m struggling with something and maybe some of you can help-
I’m trying to send a data structure to a Queue from an ISR and then reading it in a task to process it, but only some of the data is being received.
The data structure is this one;
struct DatosCANQ
{
CAN_RxHeaderTypeDef CAN_RxHeaderQ;
uint8_t CAN_RxBufQ[8];
};
The queue initialization:
osMessageQDef(CAN1Queue, 16, sizeof(struct DatosCANQ));
In the IT file I’m defining the data structure again, since “extern struct DatosCANQ” isn’t working properly for some reason
struct DatosCANQit
{
CAN_RxHeaderTypeDef CAN_RxHeaderQ;
uint8_t CAN_RxBufQ[8];
}CANRcv;
Then in the IRQ handler I’m doing this:
CAN_Status=HAL_CAN_GetRxMessage(&hcan1,CAN_RX_FIFO0,&CANRcv.CAN_RxHeaderQ,CANRcv.CAN_RxBufQ);
if(CAN_Status==HAL_OK)
{
xQueueSendFromISR(CAN1QueueHandle, (void *)&CANRcv, &xHigherPriorityTaskWoken);
}
The ISR is firing properly (checked)
Then in the reading task I define the structure (yet once more for the same issue)
struct DatosCANQt
{
CAN_RxHeaderTypeDef CAN_RxHeaderQ;
uint8_t CAN_RxBufQ[8];
}StrCAN;
And then:
for( ; ; )
{
xStatus=xQueueReceive(CAN1QueueHandle,&StrCAN,portMAX_DELAY);
if(xStatus==pdPASS)
{
memset(DirectCANBufMob1,0,sizeof(DirectCANBufMob1));
sprintf(DirectCANBufMob1,"%X,%02X%02X%02X%02X%02X%02X%02X%02X-",StrCAN.CAN_RxHeaderQ.StdId,StrCAN.CAN_RxBufQ[7],StrCAN.CAN_RxBufQ[6],StrCAN.CAN_RxBufQ[5],StrCAN.CAN_RxBufQ[4],StrCAN.CAN_RxBufQ[3],StrCAN.CAN_RxBufQ[2],StrCAN.CAN_RxBufQ[1],StrCAN.CAN_RxBufQ[0]);
xQueueGenericSend(UARTQueueHandle,(void *)&pcMessage1,10,queueSEND_TO_BACK);
}
}
The second Queue (UART) is tested and works properly and I’m receiving StrCAN.CAN_RxHeaderQ.StdId without problems, but the data bytes are always 0 even if I delete the sprintf and send some bytes to UART directly
I’ll appreciate any help.
Thanks in advance!