Page 1 of 1

How do I suspend a task?

Posted: Tue Nov 16, 2021 4:09 pm
by HyperUniverse
Hi,
I've got this task:

Code: Select all

    xTaskCreate(tx_task, "uart_tx_task", 1024*2, NULL, configMAX_PRIORITIES-1, NULL);
    vTaskDelay(1250 / portTICK_PERIOD_MS);
   
How do I suspend this task whenever I want, and how do I resume it?

Or how do I stop it and restart it agan?
I don't care for it to resume from where it stopped.

I've tried

Code: Select all

vTaskSuspend(tx_task);
but that got the core into a panic attack, and restarted my esp32


Thanks.

Re: How do I suspend a task?

Posted: Tue Nov 16, 2021 4:44 pm
by chegewara

Re: How do I suspend a task?

Posted: Tue Nov 16, 2021 9:37 pm
by HyperUniverse
yeah, that's telling me nothing!

can you verbose, or are you a mute?

Re: How do I suspend a task?

Posted: Tue Nov 16, 2021 9:40 pm
by chegewara
1. you are mean
2. what i can say if you dont understand simplest code from example?
3. good luck

Re: How do I suspend a task?

Posted: Tue Nov 16, 2021 10:47 pm
by HyperUniverse
1. so are you
I'm asking for help and you're pointing me to the clouds
if you don't want to help, then stop poluting the planet by sending bits of energy around the internet just to point out how great you are and how stupid other people are

2. what can I say if you don't understand that not everybody has been born with Einstein's brain, but still some people wish to learn.
you have't got a clue on how to help other people learn

3. thanks

Re: How do I suspend a task?

Posted: Tue Nov 16, 2021 11:22 pm
by WiFive
The answer is right there in the link, there is an example code. If it wasn't obvious to me, I would probably get frustrated but hopefully I wouldn't take out my frustration on other people. Give a man a fish/teach a man to fish is real, so next time maybe it will be more obvious how to find your own answer.

Punchline: You have to store a handle and use it.

Code: Select all

TaskHandle_t xHandle;

     // Create a task, storing the handle.
     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );

     // ...

     // Use the handle to suspend the created task.
     vTaskSuspend( xHandle );

Re: How do I suspend a task?

Posted: Tue Nov 16, 2021 11:29 pm
by HyperUniverse
I wonder why billions of children, teenagers and adults all around the world, still go to the schools, colleges and universities if the information they seek to learn is readily available in books and all over the internet??? :roll: :lol:
why don't the teachers just send home all these children and point to them to the page in the book they need to lear.
it is obviously in there!
all the stupid children have to do is open up the book read and learn

and that's what you're telling me right now - read up and learn on yourself.

Please write a letter to your own government telling them to stop wasting money with schools and teachers, as you've just discovered a new way of teaching everybody by letting them learn on their own.
:lol: :lol: :lol:

can someone very intelligent reply to that? ( . . . I mean reply to my very first post in here)

thank you

Re: How do I suspend a task?

Posted: Tue Nov 16, 2021 11:35 pm
by HyperUniverse
WiFive wrote:
Tue Nov 16, 2021 11:22 pm
Punchline: You have to store a handle and use it.
thanks for a bit of info

what is a handle?
how do I create it?
how do I use it?
what does it mean "to store it"?

why the example provided by the esp-idf in

Code: Select all

xTaskCreate(tx_task, "uart_tx_task", 1024*2, NULL, configMAX_PRIORITIES-1, NULL);
hasn't told us anything about this handle?

thank you

Re: How do I suspend a task?

Posted: Wed Nov 17, 2021 4:23 am
by ESP_Sprite
Admin note: Please chill down here. HyperUniverse: You're talking to friendly people who are willing to help out others here without getting anything back for it (people without an ESP_ prefix are not Espressif employees). In contrast to a school, you are not entitled to a specific grade of 'help', or any help at all for that matter. Others: while it's understandable, please try to keep the antagonism down.

HyperUniverse: A handle generally is some opaque value that you can use to refer to a certain concept. Here, the xTaskCreate gives you a handle/value you can store in a variable; the value represents the task created. While the value itself doesn't have a meaning outside of FreeRTOS context, you can feed it back to FreeRTOS functions to indicate which task you want it to act on. The example doesn't tell you anything about this as the handle is not relevant to the example; it's an example, not extensive documentation. If you want documentation, you'd need to refer to the FreeRTOS documentation referred to earlier.

(Also, on a more private note, running the risk of only fanning the flames: If you're ever willing to get deep into embedded software, taking every quirk of the docs, examples or api to barge into a forum or other place and demanding an explanation isn't going to get you far... like most IT'ish tasks, being able to Google well and being able to piece together an overarching idea of something based on scattered and incomplete bits of information is pretty important. Not saying you're not allowed to do whatever you feel like, simply speaking from experience here.)