2020-08-10 06:08 AM
I got an interesting bug when working with the queue (STM32CubeMX 5.6.1 + lib 1.25 in STM32F407VGT6):
typedef struct
{
uint8_t* data;
uint16_t len;
} message_t;
uint8_t str[] = "hello\n";
for(;;)
{
message_t* message;
if ((message = osMailAlloc(ComOutputQueue, 0)) == NULL)
{
// no action
}
else
{
message->len = 6;
message->data = malloc(6);
if (message->data == NULL)
{
osMailFree(ComOutputQueue, message);
}
for (uint16_t i = 0; i < 6; i++)
{
message->data[i] = str[i];
}
osMailPut(ComOutputQueue, message);
CDC_Transmit_FS((uint8_t*)str, 6);
osDelay(30);
CDC_Transmit_FS(message->data, message->len);
}
osDelay(30);
}
The ComOutputQueue is declared and initialized.
Result:
What am I doing wrong?
Solved! Go to Solution.
2020-08-10 04:41 PM
2020-08-10 04:41 PM