can't get vTaskSuspend running

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

can't get vTaskSuspend running

Postby jumjum123 » Tue Oct 25, 2016 11:14 am

Trying to supend a task always results in panic. Any idea what I'm doing wrong ?

Code: Select all

TaskHandle_t handleTest = NULL;
static void test(void *data){
  vTaskDelay(10000 / portTICK_PERIOD_MS);
  ESP_LOGE("Test","will suspend now");
  vTaskSuspend(handleTest);
  ESP_LOGE("Test","just suspended");
}
int app_main(void)
{ system_init();
  xTaskCreatePinnedToCore(&test,"Test",2000,NULL,30,&handleTest,0);
  return 0;
}

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: can't get vTaskSuspend running

Postby ESP_igrr » Tue Oct 25, 2016 3:53 pm

It panics because this function hasn't been tested:

https://github.com/espressif/esp-idf/bl ... ks.c#L1312

You can disable this behavior in menuconfig, in FreeRTOS options. Note that the function may still not work because it hasn't received test coverage yet.

Out of curiosity, what use case do you have for suspending a task?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: can't get vTaskSuspend running

Postby kolban » Tue Oct 25, 2016 4:05 pm

In deep reading of the RTOS docs, I read somewhere that a task, once created, is not meant to end. When I read that it sounded "daft" but that's what I remember reading.

That said, I have been able to end a task and the way to do that is to call

vTaskDelete(NULL);

as the last thing one does before ending the task. If one does NOT do that, then we do indeed crash when the task ends. Bottom line (for me) is to always end a FreeRTOS task with a vTaskDelete(NULL) because if you don't it crashes.

Try adding that to your code and see if that makes a change.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

Re: can't get vTaskSuspend running

Postby jumjum123 » Tue Nov 01, 2016 11:32 pm

Thanks for the feedback.
After changing the flag in menuconfig, I got suspend and resume running.
At least in my first Q&U testcase (Q&U is :? Quick&Ugly )

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 80 guests