How to see the contents of osMessageQueue through an interrupt point?
Hi Community,
I'm using the STM32U5A9-DK development board and trying to get the UART messages to show up on the screen.
Using osMessageQueue to pass messages between the main and the Model.
But I'm experiencing the problem described in this post , and I've found that the breakpoints don't work in the callback function.
I'm not sure if the message is being put into the queue correctly.
Has anyone else experienced a similar problem or know how to solve it?
This is my code:
Default Task:
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN defaultTask */
extern UART_HandleTypeDef huart1;
extern char RxData[256]; // received data from UART
HAL_UART_Transmit(&huart1, "UART1 ready...\n", 15, 0xffff);
char cmd[42] = "send_string \"Hello\"\n"
"\n";
HAL_UART_Transmit(&huart1, cmd, sizeof(cmd), 0xffff);
HAL_Delay(50);
/* Infinite loop */
for(;;)
{
HAL_UARTEx_ReceiveToIdle_IT(&huart1, RxData, 256);
osDelay(1);
}
/* USER CODE END defaultTask */
}
Callback function:
extern osMessageQueueId_t uartQueueHandle;
char RxData[256]; // received data from UART
char DataBuffer[256]; // store full message
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
memcpy(DataBuffer, RxData, Size+1);
HAL_UART_Transmit(&huart1, (uint8_t *)DataBuffer, Size, 0xffff);
if (osMessageQueueGetSpace(uartQueueHandle)>0)
{
osMessageQueuePut(uartQueueHandle, DataBuffer, 0 ,0);
}
HAL_Delay(100);
}
Model.c
#include <gui/model/Model.hpp>
#include <gui/model/ModelListener.hpp>
#include "cmsis_os2.h"
#include <cstring>
#include <stm32u5xx.h>
extern osMessageQueueId_t uartQueueHandle;
Model::Model() : modelListener(0)
{
}
char string[256];
char RData[256];
extern UART_HandleTypeDef huart1;
void Model::tick()
{
if(osMessageQueueGet(uartQueueHandle, &string, 0, 0xffff) == osOK)
{
strncpy(RData, string, sizeof(string));
modelListener -> uart_Data(RData);
}
}
