I need help with xQueueReceice, my problem is that xQueueReceice return an value empty.
my code
struct xDataMensagem
{
String xData;
}xMensagem;
void xTaskRecives(void * pvParameters){
String myData = “02,1234.567”;
while (true){
xMensagem.xData = myData;
if (xQueueSend(xDataQueue,(void * ) & xMensagem,portMAX_DELAY)){
Serial.println(“enviado”);
}
vTaskDelay(pdMS_TO_TICKS(5000));
}
}
void xTaskTreadsData(void * pvParameters){
String myString = “”;
struct xDataMensagem xMensagem_;
while (true){
if (xDataQueue != NULL){ if (xQueueReceive(xDataQueue, &xMensagem_, portMAX_DELAY))
{
** myString = xMensagem_.xData;
Serial.println(myString); //print data recived
xMensagem_.xData = “”; // clear flag
}
}
vTaskDelay(pdMS_TO_TICKS(10));
}
the function that is failing is in bold
But the value of returned of xQueueReceive is empty, why??
the variable xMensagem_ wouldn’t it be a copy of the one sent?
creates a queue of POINTERS to xMensagem. This can be used to send messages by reference / pointer. If you want to send messages by value (as supposed by your xQueueSend/xQueueReceive calls) use sizeof( xMensagem ) and ensure that xMensagem is a POD type as Richard mentioned. Maybe reread the API docs (see the links) for further details.