Problems with osMessageQueue
Hello.
I'm using the STM32U5A9J-DK development board to work on a project to display UART data on the screen textArea, and I've made sure that there are no problems with the communication between the PC and the STM32 UART, and with the process of Model-Presender-View displaying the data on the screen.
program flow:
UART signal from PC -> main.c program receives it and saves it to CMSIS queue, get the content of queue from Model.cpp -> pass string through ModelListener.
Here is my code:
main.c
char RxData[257]; // received data from UART
char Data[257]; // copy from RxData
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
RxData[Size] = '\0';
strncpy(Data, RxData, Size+1);
if (osMessageQueueGetSpace(uartQueueHandle)>0)
{
osMessageQueuePut(uartQueueHandle, Data, 0 ,0);
HAL_UART_Transmit(&huart1, (Data), Size+1, 10); // print Data array
}
HAL_UARTEx_ReceiveToIdle_IT(&huart1, RxData, 256);
}
After "Data" is put into the Queue, I transmit to PC for display, and then I can receive the full string.
Model.cpp
char String[257];
//char data[257] = "Hello";
void Model::tick()
{
if (osMessageQueueGetCount(uartQueueHandle)>0)
{
if(osMessageQueueGet(uartQueueHandle, String, 0, 0) == osOK)
{
strncpy(RData, String, sizeof(String));
modelListener -> uart_Data(RData);
}
}
}
When I use "String" to receive, then copy it to RData and send it to View to display, the screen will display only 1~2 characters.

Another test I did was to replace "String" with the contents of data[256]. the text was displayed in full without going through the Queue.
I suspect it's a queue problem. Is there any way to display the content stored in the queue?
Here is my Queue setting, and my CubeIDE version is 1.15.0.
uartQueueHandle = osMessageQueueNew (2, sizeof(uint8_t), &uartQueue_attributes);
