cancel
Showing results for 
Search instead for 
Did you mean: 

RTOS. osMailQId bug.

NorfLoud
Associate III

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:0693W000003OqkkQAC.jpg

What am I doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

Note use of malloc in a thread.

Mr. Nadler to the rescue?

-- pa

View solution in original post

1 REPLY 1
Pavel A.
Evangelist III

Note use of malloc in a thread.

Mr. Nadler to the rescue?

-- pa