硬汉嵌入式论坛

 找回密码
 立即注册
查看: 1538|回复: 2
收起左侧

xQueueReceive接收任务数据卡到prvidletask空闲任务里

[复制链接]

2

主题

2

回帖

8

积分

新手上路

积分
8
发表于 2024-8-22 21:43:47 | 显示全部楼层 |阅读模式
用stm32cubemx创建的rtos工程,用队列处理两个任务发送过来的数据,好发送到云端,在检查第三个任务(实则没有,应该退出上传数据)的时候因为进太多次临界区(?),内存/堆栈都没有溢出,程序就卡在
if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( UBaseType_t ) 1 )
{
   taskYIELD();
}

里面,程序的优先级应该是没问题的,在f4跑成功过,移植到f1上就出现这样的问题,不过数据是接收到了,也试过检测队列剩余任务个数主动退出,仍然卡在相同位置,有大佬遇到同样的情况吗

回复

使用道具 举报

2

主题

2

回帖

8

积分

新手上路

积分
8
 楼主| 发表于 2024-8-22 23:02:56 | 显示全部楼层
任务执行一次就卡死了,static void MQTT_Platform(void *para) {      /*send the message to MQTT servicer*/     printf("enter MQTT_Platform successfully\r\n");     char data_buffer[1024] = {0}; // data buffer Initialization     msg.payload = data_buffer;     msg.qos = QOS0;     while (1)     {         platform_mutex_lock(&G_xTaskMutex);         // waitting for ping message         xEventGroupWaitBits((EventGroupHandle_t)Event_Handle,                             (EventBits_t)PING_MODE1|PING_MODE2, // add event signal in here                             (BaseType_t)pdTRUE,                   // clear the signal when complete once upload                             (BaseType_t)pdTRUE,                             (TickType_t)portMAX_DELAY);          if (xQueueReceive(G_xMessageQueueToMQTT, data_buffer + strlen(data_buffer), 10))         {             printf("number is %d\r\n",(int*)uxQueueMessagesWaiting(G_xMessageQueueToMQTT));             printf("remained memory size :%d\r\n",(int*)uxTaskGetStackHighWaterMark(G_xQueuePlatform));             while (xQueueReceive(G_xMessageQueueToMQTT, data_buffer + strlen(data_buffer), 10))             {                 printf("state is %d\r\n",(int*)xTaskGetSchedulerState());             }             msg.payloadlen = strlen(msg.payload);             mqtt_publish(client, "mcu_test", &msg);      // publish the message to mqtt server             memset(data_buffer, 0, sizeof(data_buffer)); // reset data buffer             platform_mutex_unlock(&G_xTaskMutex);             printf("send data to MQTT server successfully\r\n");             vTaskDelay(pdMS_TO_TICKS(1000));         }         else         {             printf("No data received\r\n");             platform_mutex_unlock(&G_xTaskMutex);             vTaskDelay(1000);         }     } }
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117512
QQ
发表于 2024-8-23 09:05:56 | 显示全部楼层
这个没有好办法,只能逐一排查是那个任务的,所有任务创建都注释掉,逐一开启排查哪部分程序导致。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-8-12 02:45 , Processed in 0.171816 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表