PlatformIO Community

Xqueuereceive crashing

Hi forum… I am working with esp32 and platformio using freertos OS.

I have already worked with queues but now I am getting a crash of the system calling
this

 if (xQueueReceive(report_queue_from_uart_to_wifi,(void *) &report_struct_receive, 0) == pdPASS)

Here all the code…

Definition of the struct

typedef struct report_t
{
    uint16_t machine_id;
    uint16_t report_id;
    tm init_time;
    tm end_time;
    uint16_t duration;
} report_t;

where tm is defined in file time.h in the folowing way …

struct tm
{
  int	tm_sec;
  int	tm_min;
  int	tm_hour;
  int	tm_mday;
  int	tm_mon;
  int	tm_year;
  int	tm_wday;
  int	tm_yday;
  int	tm_isdst;
#ifdef __TM_GMTOFF
  long	__TM_GMTOFF;
#endif
#ifdef __TM_ZONE
  const char *__TM_ZONE;
#endif
};

Creation of the struct variable

report_t report_struct;
UBaseType_t queue_lenght = 10;         /*optimal value to be defined*/

Creation of the queue

/**
 * @brief  Function to create the queue for exchanging data between Wifi and uart task
 * @param  None
 * @retval None
 */
void Create_queue_for_exchange_reports_between_uart_and_wifi(void)
{
  report_queue_from_uart_to_wifi = xQueueCreate(queue_lenght, sizeof(report_t));
}
/**

Sending the struct to the queue it is crashing the fw too

    if (xQueueSend(report_queue_from_uart_to_wifi, (void *)&report_struct, 0) == pdPASS)
      {
        /*to do cleaning the structure*/
      }

The problem is also in receiving.

   if (xQueueReceive(report_queue_from_uart_to_wifi, (void *)&report_struct_receive, 0) == pdPASS)
      {

where the struct is defined in this way

report_t report_struct_receive;

What is wrong ?

Thanks a lot for your help

Per ESP32 Arduino: Using structs as items in FreeRTOS queues - techtutorialsx the individual pieces of code look fine.

Do you call Create_queue_for_exchange_reports_between_uart_and_wifi() before any task could access it (i.e. before either the receiver or sender task is created)? Also you always use timeout = 0 instead of waiting with e.g. portMAX_DELAY, is that wanted? Could we see the whole code?

1 Like

Hi max…

I am sure that the creation of the queue is made first because I have other queues that I use in the same way but instead of passing a struct I am passing an array … I can change the timeout but why it should affect the system in this way? I can share yes

task.cpp

include "task_module.h"
#include <captive_portal.h>
#include <gpioa_module.h>
#include <modbus_mng.h>
#include <ethernet_module.h>
#include <machine.h>
#include <webserver_mng.h>

static const uint32_t STACK_SIZE_MQTT_TASK = 17000;      /*optimal value to be defined*/
static const uint32_t STACK_SIZE_SERIAL_TASK = 4000;     /*optimal value to be defined*/
static const uint32_t STACK_SIZE_ETHERNET_TASK = 1000;   /*optimal value to be defined*/
static const uint32_t STACK_SIZE_GPIOA_TASK = 5000;      /*optimal value to be defined*/
static const uint32_t STACK_SIZE_WEBSERVER_TASK = 20000; /*optimal value to be defined*/

static const uint16_t SERIAL_TASK_DELAY = 10;   /*optimal value to be defined*/
static const uint16_t MQTT_TASK_DELAY = 100;    /*optimal value to be defined*/
static const uint16_t ETHERNET_TASK_DELAY = 10; /*optimal value to be defined*/
static const uint16_t GPIOA_TASK_DELAY = 1000;  /*optimal value to be defined*/
static const uint32_t WEBSERVER_DELAY = 500;    /*500 is fine for running single webpage*/

UBaseType_t Mqtt_priority = 1;      /*optimal value to be defined*/
UBaseType_t Serial_priority = 1;    /*optimal value to be defined*/
UBaseType_t Ethernet_priority = 1;  /*optimal value to be defined*/
UBaseType_t Gpioa_priority = 1;     /*optimal value to be defined*/
UBaseType_t Webserver_priority = 1; /*optimal value to be defined*/

TaskHandle_t Mqtt_handle = NULL;      /*for handling the task1 from outside the task*/
TaskHandle_t Serial_handle = NULL;    /*for handling the task2 from outside the task*/
TaskHandle_t Ethernet_handle = NULL;  /*for handling the task3 from outside the task*/
TaskHandle_t Gpioa_handle = NULL;     /*for handling the task4 from outside the task*/
TaskHandle_t Webserver_handle = NULL; /*for handling the task4 from outside the task*/

QueueHandle_t alarms_queue_from_uart_to_wifi;
QueueHandle_t logs_queue_from_uart_to_wifi;
QueueHandle_t state_queue_from_uart_to_wifi;
QueueHandle_t physics_queue_from_uart_to_wifi;
QueueHandle_t report_queue_from_uart_to_wifi;

QueueHandle_t commands_queue_from_uart_to_wifi;
QueueHandle_t config_queue_from_uart_to_wifi;
QueueHandle_t program_upload_queue_from_uart_to_wifi;

UBaseType_t queue_lenght = 10;         /*optimal value to be defined*/
UBaseType_t queue_lenght_commands = 1; /*optimal value to be defined*/

report_t report_struct;

/**
 * @brief  Function to create the queue for exchanging data between Wifi and uart task
 * @param  None
 * @retval None
 */
void Create_queue_for_exchange_alarms_between_uart_and_wifi(void)
{
  alarms_queue_from_uart_to_wifi = xQueueCreate(queue_lenght, NUM_REGISTERS_ALARMS * sizeof(uint16_t));
}
/**
 * @brief  Function to create the queue for exchanging data between Wifi and uart task
 * @param  None
 * @retval None
 */
void Create_queue_for_exchange_log_between_uart_and_wifi(void)
{
  logs_queue_from_uart_to_wifi = xQueueCreate(queue_lenght, NUM_REGISTERS_LOG * sizeof(uint16_t));
}
/**
 * @brief  Function to create the queue for exchanging data between Wifi and uart task
 * @param  None
 * @retval None
 */
void Create_queue_for_exchange_state_between_uart_and_wifi(void)
{
  state_queue_from_uart_to_wifi = xQueueCreate(queue_lenght, NUM_REGISTERS_MACHINE_STATE * sizeof(uint16_t));
}
/**
 * @brief  Function to create the queue for exchanging data between Wifi and uart task
 * @param  None
 * @retval None
 */
void Create_queue_for_exchange_physics_between_uart_and_wifi(void)
{
  physics_queue_from_uart_to_wifi = xQueueCreate(queue_lenght, NUM_REGISTERS_PHYSICAL_VALUES * sizeof(uint16_t));
}
/**
 * @brief  Function to create the queue for exchanging data between Wifi and uart task
 * @param  None
 * @retval None
 */
void Create_queue_for_exchange_reports_between_uart_and_wifi(void)
{
  report_queue_from_uart_to_wifi = xQueueCreate(1, sizeof(report_t));
}
/**
 * @brief  Function to create the queue for exchanging data between Wifi and uart task
 * @param  None
 * @retval None
 */
void Create_queue_for_exchange_commands_between_wifi_and_uart(void)
{
  commands_queue_from_uart_to_wifi = xQueueCreate(queue_lenght_commands, NUM_REGISTERS_COMMANDS * sizeof(uint16_t));
}
/**
 * @brief  Function to create the queue for exchanging data between Wifi and uart task
 * @param  None
 * @retval None
 */
void Create_queue_for_exchange_config_between_wifi_and_uart(void)
{
  config_queue_from_uart_to_wifi = xQueueCreate(queue_lenght, 1 * sizeof(uint16_t));
}
/**
 * @brief  Function to create the queue for exchanging data between Wifi and uart task
 * @param  None
 * @retval None
 */
void Create_queue_for_exchange_program_upload_between_wifi_and_uart(void)
{
  program_upload_queue_from_uart_to_wifi = xQueueCreate(queue_lenght, 1 * sizeof(uint16_t));
}
/**
 * @brief  Function to execute the creation of the first task
 * @param  None
 * @retval None
 */
void First_task_creation(void)
{
  xTaskCreate(Mqtt_task, "Wifi", STACK_SIZE_MQTT_TASK, NULL, Mqtt_priority, &Mqtt_handle);
  /*Block the task from running*/
  vTaskSuspend(Mqtt_handle);
}
/**
 * @brief  Function to execute the creation of the second task
 * @param  None
 * @retval None
 */
void Second_task_creation(void)
{
  xTaskCreate(Communication_with_serial_task, "Uart", STACK_SIZE_SERIAL_TASK, NULL, Serial_priority, &Serial_handle);
  /*Block the task from running*/
  vTaskSuspend(Serial_handle);
}

/**
 * @brief  Function to execute the creation of the fourth task
 * @param  None
 * @retval None
 */
void Third_task_creation(void)
{
  xTaskCreate(Communication_with_ethernet_task, "ETH", STACK_SIZE_ETHERNET_TASK, NULL, Ethernet_priority, &Ethernet_handle);
  /*Block the task from running*/
  vTaskSuspend(Ethernet_handle);
}
/**
 * @brief  Function to execute the creation of the fifth task
 * @param  None
 * @retval None
 */
void Fourth_task_creation(void)
{
  xTaskCreate(Input_Output_analog_task, "GPIOA", STACK_SIZE_GPIOA_TASK, NULL, Gpioa_priority, &Gpioa_handle);
  /*Block the task from running*/
  vTaskSuspend(Gpioa_handle);
}
/**
 * @brief  Function to execute the creation of the sixth task
 * @param  None
 * @retval None
 */
void Seventh_task_creation(void)
{
  xTaskCreate(Webserver_task, "WEBSERVER", STACK_SIZE_WEBSERVER_TASK, NULL, Webserver_priority, &Webserver_handle);
  /*Block the task from running*/
  vTaskSuspend(Webserver_handle);
}
/**
 * @brief  Function to execute the wifi task. Responsible for the captive portal and transmitting/receiving the data with Mqtt over wifi
 * @param  None
 * @retval None
 */
void Mqtt_task(void *parameters)
{
  int result_captive_portal_config = 0;

  /*start of the captive portal or wifi network connection*/
  result_captive_portal_config = setup_captive_and_wifi();

  if (result_captive_portal_config == 1)
  {
    setup_google_IOT_mqtt();
    set_current_event(EVENT_OK_CREDENTIALS);
  }

  for (;;)
  {
    if (result_captive_portal_config == 1)
    {
      loop_google_IOT_mqtt();
    }
    vTaskDelay(MQTT_TASK_DELAY / portTICK_PERIOD_MS); /*tells at the scheduler to suspende the task for X ms*/
  }
}
/**
 * @brief  Function to execute the uart task. Responsible to communicate with external mcu with a specific frame protocol over uart
 * @param  None
 * @retval None
 */
void Communication_with_serial_task(void *parameters)
{
  Init_modbus_registers();

  for (;;)
  {
    Serial_task();

    vTaskDelay(SERIAL_TASK_DELAY / portTICK_PERIOD_MS);
  }
}
/**
 * @brief  Function to execute the ethernet task
 * @param  None
 * @retval None
 */
void Communication_with_ethernet_task(void *parameters)
{
  Ethernet_Init();

  for (;;)
  {
    Ethernet_Task();

    vTaskDelay(ETHERNET_TASK_DELAY / portTICK_PERIOD_MS);
  }
}
/**
 * @brief  Function to handle the Input Output and Analog signals directly connected with the board
 * @param  None
 * @retval None
 */
void Input_Output_analog_task(void *parameters)
{
  gpioa_init();

  for (;;)
  {
    vTaskDelay(GPIOA_TASK_DELAY / portTICK_PERIOD_MS);
  }
}
/**
 * @brief  Function to execute the webserver task (for OTA update and log)
 * @param  None
 * @retval None
 */
void Webserver_task(void *parameters)
{
  uint8_t http_id_request_from_webserver = 0;
  /*init of the ble task with properties*/
  web_portal_init();

  for (;;)
  {
    http_id_request_from_webserver = get_event_on_web_portal();
    set_current_state_on_web_portal(get_current_state());

    switch (http_id_request_from_webserver)
    {
    case HTTP_REQUEST_GO_TO_MAINTENANCE:
      set_current_event(EVENT_HTTP_REQUEST_GO_MAINTENANCE);
      break;
    case HTTP_REQUEST_GO_TO_NORMAL:
      set_current_event(EVENT_HTTP_REQUEST_GO_TO_NORMAL);
      break;
    case HTTP_REQUEST_GO_TO_INIT:
      set_current_event(EVENT_HTTP_REQUEST_GO_TO_INIT);
      break;
    default:
      // default statements
      break;
    }

    reset_event_on_web_portal();

    vTaskDelay(WEBSERVER_DELAY / portTICK_PERIOD_MS);
  }
}

and the place where I have the crash and I try to receive the struct


#include "mqtt_mng.h"
#include <ArduinoJson.h>
#include <gpioa_module.h>
#include <Json_payload_format.h>
#include <Arduino.h>
#include "task_module.h"
#include <webserver_mng.h>
#include <modbus_mng.h>

uint32_t counter_ticks_wifi_task = 0;
static uint32_t refresh_time = 20;
static uint32_t refresh_esp32_status = 350; /*550 delay of wifi task more or less every 1 minute*/
bool first_config_received_flag = false;
static uint16_t commands_array[NUM_REGISTERS_COMMANDS] = {0};
EspStatus_t Status_Iot;
static uint8_t flag_first_time_connected_cloud = 0;

report_t report_struct_receive;

/**
 * @brief Function for initializing of the structure containing the status of the iot board
 * @param *cmd pointer to the status structure
 * @retval none
 */
void init_iot_status_structure(EspStatus_t *status)
{
  status->broker_connection = 0;
  status->wifi_ethernet_selected = 0;
  status->status_wifi_ethernet = 0;
  status->command_to_apply = 0;
  status->receipe_to_apply = 0;
  status->update_to_apply = 0;
  status->number_of_registers = 0;
}
/**
 * @brief Function for indicating that the connection with the broker is working
 * @param *status pointer to the status structure
 * @retval none
 */
void set_broker_connection_is_active(EspStatus_t *status)
{
  status->broker_connection = 1;
}
/**
 * @brief Function for indicating that the connection with the broker is not working
 * @param *status pointer to the status structure
 * @retval none
 */
void set_broker_connection_is_not_active(EspStatus_t *status)
{
  status->broker_connection = 0;
}
/**
 * @brief Function for indicating that the connection is made with the ethernet cable
 * @param *status pointer to the status structure
 * @retval none
 */
void set_ethernet_connection_is_selected(EspStatus_t *status)
{
  status->wifi_ethernet_selected = 1;
}
/**
 * @brief Function for indicating that the connection is made with the wifi
 * @param *status pointer to the status structure
 * @retval none
 */
void set_wifi_connection_is_selected(EspStatus_t *status)
{
  status->wifi_ethernet_selected = 0;
}
/**
 * @brief Function for setting the status of the wifi and the ethernet
 * @param *status pointer to the status structure
 * @param status_connection
 * @retval none
 */
void set_status_wifi_and_ethernet(EspStatus_t *status, bool status_connection)
{
  status->status_wifi_ethernet = status_connection;
}
/**
 * @brief Function for indicating that there is a command to apply
 * @param *status pointer to the status structure
 * @retval none
 */
void set_commands_to_apply(EspStatus_t *status)
{
  status->command_to_apply = 1;
}
/**
 * @brief Function for indicating that there is no more a command to apply
 * @param *status pointer to the status structure
 * @retval none
 */
void reset_commands_to_apply(EspStatus_t *status)
{
  status->command_to_apply = 0;
}
/**
 * @brief Function for indicating that there is a receipe to apply
 * @param *status pointer to the status structure
 * @retval none
 */
void set_receipe_to_apply(EspStatus_t *status)
{
  status->receipe_to_apply = 1;
}
/**
 * @brief Function for indicating that there is no more a receipe to apply
 * @param *status pointer to the status structure
 * @retval none
 */
void reset_receipe_to_apply(EspStatus_t *status)
{
  status->receipe_to_apply = 0;
}
/**
 * @brief Function for indicating that there is an update to apply
 * @param *status pointer to the status structure
 * @retval none
 */
void set_update_to_apply(EspStatus_t *status)
{
  status->update_to_apply = 1;
}
/**
 * @brief Function for indicating that there is no more an update to apply
 * @param *status pointer to the status structure
 * @retval none
 */
void reset_update_to_apply(EspStatus_t *status)
{
  status->update_to_apply = 0;
}
/**
 * @brief Function for indicating the number of registers to write
 * @param *status pointer to the status structure
 * @retval none
 */
void set_registers_to_use(EspStatus_t *status, uint8_t number_of_registers_to_use)
{
  status->number_of_registers = number_of_registers_to_use;
}
/**
 * @brief Function to reset the number of registers to write
 * @param *status pointer to the status structure
 * @retval none
 */
void reset_registers_to_use(EspStatus_t *status)
{
  status->number_of_registers = 0;
}
/**
 * @brief  Function to wait for new messages from the broker
 * @param  None
 * @retval None
 */
void setup_google_IOT_mqtt(void)
{
  Serial.begin(115200);

  init_iot_status_structure(&Status_Iot);

  /*relocate the following functions where they really need*/
  set_broker_connection_is_active(&Status_Iot);
  set_wifi_connection_is_selected(&Status_Iot);
  set_status_wifi_and_ethernet(&Status_Iot, true);
  set_commands_to_apply(&Status_Iot);

  setupCloudIoT();
}

/**
 * @brief  Function to wait for new messages from the broker
 * @param  None
 * @retval None
 */
void loop_google_IOT_mqtt(void)
{

  static uint16_t array_logs_from_queue[NUM_REGISTERS_LOG] = {0};
  static uint16_t array_alarms_from_queue[NUM_REGISTERS_ALARMS] = {0};
  static uint16_t machine_status_value_from_queue[NUM_REGISTERS_MACHINE_STATE] = {0};
  static uint16_t physical_value_from_queue[NUM_REGISTERS_PHYSICAL_VALUES] = {0};

  // Serial.println("Transmitted");
  mqtt->loop();
  // the delay fixes some issues with WiFi stability
  delay(10);

  if (!mqttClient->connected())
  {
    connect();
  }
  /**
   * @brief The board begin to transmit only if a config message is received.
   *
   * Important note: it seems that a delay is necessary between two consecutive publish action,
   * otherwhise the message is not transmited.
   * To be evaluated and investigated.
   *
   */
  if (first_config_received_flag == true)
  {
    ++counter_ticks_wifi_task;

    /*physical values topic transmitted only if modbus message is arrived*/
    if (xQueueReceive(physics_queue_from_uart_to_wifi, &physical_value_from_queue, 0) == pdPASS)
    {
      physical_values_message(physical_value_from_queue);
      Serial.println("Transmitted physics");

      delay(10);
    }

    /*alarm topic transmitted only if modbus message is arrived*/
    if (xQueueReceive(alarms_queue_from_uart_to_wifi, &array_alarms_from_queue, 0) == pdPASS)
    {
      alarms_message(array_alarms_from_queue);
      Serial.println("Transmitted alarm");

      delay(10);
    }
    /*log topic transmitted only if modbus message is arrived*/
    if (xQueueReceive(logs_queue_from_uart_to_wifi, &array_logs_from_queue, 0) == pdPASS)
    {
      log_message(array_logs_from_queue);
      Serial.println("Transmitted log");

      delay(10);
    }
    /*machine status topic transmitted only if modbus message is arrived*/
    if (xQueueReceive(state_queue_from_uart_to_wifi, &machine_status_value_from_queue, 0) == pdPASS)
    {
      machine_state_message(machine_status_value_from_queue);
      Serial.println("Transmitted machine status");

      delay(10);
    }
    /*report topic transmitted only if modbus message is arrived*/
    if (xQueueReceive(report_queue_from_uart_to_wifi, (void *)&report_struct_receive, 0) == pdPASS)
    {
      send_report_message(report_struct_receive.machine_id, report_struct_receive.report_id, report_struct_receive.init_time,
                          report_struct_receive.end_time, report_struct_receive.duration);

      Serial.println("Transmitted report topic");

      delay(10);
    }

    /*iot status transmitted every refresh_esp32_status  time*/
    if (counter_ticks_wifi_task > refresh_esp32_status)
    {
      status_message();
      Serial.println("Transmitted iot board status");
      counter_ticks_wifi_task = 0;

      delay(10);

      /*iot state transmitted only once*/
      if (flag_first_time_connected_cloud == 0)
      {
        Serial.println("Transmitted iot board state first connection");
        state_message();
        flag_first_time_connected_cloud = 1;

        delay(10);
      }
    }
  }
}
/**
 * @brief  Function for parsing the payload into a numeric value
 * @param  payload
 * @retval id_command
 */
uint16_t Parse_paylod_for_getting_machine_id(String payload)
{
  String first_filter_string = "machineId";
  String second_filter_string = "NumeroRicetta";
  String id_command = payload.substring(payload.indexOf(first_filter_string), payload.indexOf(second_filter_string));
  id_command = id_command.substring(id_command.indexOf(':') + 2, id_command.indexOf(',') - 1);
  return id_command.toInt();
}
/**
 * @brief  Function for parsing the payload into a numeric value
 * @param  payload
 * @retval parameter_command
 */
uint16_t Parse_paylod_for_getting_number_receipe(String payload)
{
  String first_filter_string = "NumeroRicetta";
  String second_filter_string = "ValorePressata";
  String id_command = payload.substring(payload.indexOf(first_filter_string), payload.indexOf(second_filter_string));
  id_command = id_command.substring(id_command.indexOf(':') + 2, id_command.indexOf(',') - 1);
  return id_command.toInt();
}
/**
 * @brief  Function for parsing the payload into a numeric value
 * @param  payload
 * @retval parameter_command
 */
uint16_t Parse_paylod_for_getting_valore_pressata(String payload)
{
  String first_filter_string = "ValorePressata";
  String second_filter_string = "ValoreTaglio";
  String id_command = payload.substring(payload.indexOf(first_filter_string), payload.indexOf(second_filter_string));
  id_command = id_command.substring(id_command.indexOf(':') + 2, id_command.indexOf(',') - 1);
  return id_command.toInt();
}
/**
 * @brief  Function for parsing the payload into a numeric value
 * @param  payload
 * @retval parameter_command
 */
uint16_t Parse_paylod_for_getting_valore_taglio(String payload)
{
  String first_filter_string = "ValoreTaglio";
  String second_filter_string = "ValoreGrammatura";
  String id_command = payload.substring(payload.indexOf(first_filter_string), payload.indexOf(second_filter_string));
  id_command = id_command.substring(id_command.indexOf(':') + 2, id_command.indexOf(',') - 1);
  return id_command.toInt();
}
/**
 * @brief  Function for parsing the payload into a numeric value
 * @param  payload
 * @retval parameter_command
 */
uint16_t Parse_paylod_for_getting_valore_grammatura(String payload)
{
  String first_filter_string = "ValoreGrammatura";
  String id_command = payload.substring(payload.indexOf(first_filter_string), payload.indexOf('}'));
  id_command = id_command.substring(id_command.indexOf(':') + 2, id_command.indexOf(',') - 1);
  return id_command.toInt();
}

/**
 * @brief  Callback function from the messages coming from the server
 * @param  topic
 * @param  payload
 * @retval none
 */
void messageReceived(String &topic, String &payload)
{
  Serial.println("incoming: " + topic + " - " + payload);
  StaticJsonDocument<PROGRAMS_INCOMING_CAPACITY> doc;
  DeserializationError err = deserializeJson(doc, payload);
  if (err)
  {
    Serial.print(F("deserializeJson() failed with code "));
    Serial.println(err.f_str());
  }

  if (topic.endsWith(COMMANDS_SUFFIX))
  {
    const char *command_name = doc["name"];

    if ((strcmp(command_name, MACHINE_RECEIPE_COMMAND) == COMPARE_RESULT_OKAY))
    {

      /*parsing command values*/
      commands_array[0] = Parse_paylod_for_getting_machine_id(payload);
      commands_array[1] = Parse_paylod_for_getting_number_receipe(payload);
      commands_array[2] = Parse_paylod_for_getting_valore_pressata(payload);
      commands_array[3] = Parse_paylod_for_getting_valore_taglio(payload);
      commands_array[4] = Parse_paylod_for_getting_valore_grammatura(payload);

      /*Insert commands commands in the queue*/
      if (xQueueSend(commands_queue_from_uart_to_wifi, &commands_array, 0) == pdPASS)
      {
        Serial.println("command element inserted in the queue!");
        memset(commands_array, 0, NUM_REGISTERS_COMMANDS);
      }
      else
      {
        Serial.println("command queue is full!");
      }
    }

    if ((strcmp(command_name, SET_OUTPUTS_CMD) == COMPARE_RESULT_OKAY))
    {
      Serial.println("entro!");
      set_outputs(doc);
    }
    else if ((strcmp(command_name, PROGRAMS_DOWNLOAD_CMD) == COMPARE_RESULT_OKAY))
    {
      Serial.println("entro!");
      programs_download(doc);
    }
  }
  /**
   * @brief Config topic set the interval between two consecutive state messages.
   *
   */
  else if (topic.endsWith(CONFIG_SUFFIX))
  {
    if ((doc["statusIntervalSecs"]) != NULL)
    {
      refresh_time = static_cast<unsigned long>(doc["statusIntervalSecs"]);
      Serial.println(refresh_time);
      first_config_received_flag = true;
    }
  }
}

The crash appears in row 281

 if (xQueueReceive(report_queue_from_uart_to_wifi, (void *)&report_struct_receive, 0) == pdPASS)

What A stupid
It was missing the call in the main.cpp

Create_queue_for_exchange_reports_between_uart_and_wifi();