arduino to IDF newbie help managing mulitple apps inline
-
- Posts: 9727
- Joined: Thu Nov 26, 2015 4:08 am
Re: arduino to IDF newbie help managing mulitple apps inline
I think the vTaskDelete(x) discussion is really interesting, but probably not for this thread. Suggest starting a new one if you guys want to discuss any pros/cons.
Re: arduino to IDF newbie help managing mulitple apps inline
To show you why no answer is better than wrong answer here is example, which i hope also can help OP to continue with his project.MicroController wrote: ↑Tue Mar 19, 2024 11:57 amP.S.:
Dear Ché, let's not go there. I'd rather try and find the best solutions for people in a cooperative way than diminishing others. I'm not here to take anything away from anyone. I guess we could come up with excellent ideas by leveraging each other's experience.
In other topic you told me to work with only 1 task (no sense, the idea of FreeRTOS is to use tasks). Here is log from the project i am working on:
Code: Select all
"free memory":[78084,73912,73728,0],
"watermark":{
"BLE_Task":1660,
"LED":120,
"mqtt":2724,
"auxled":356,
"mainled":348,
"main2led":356,
"indiLed":396,
"mainTask":1560,
"count":20},
15:35:28.824 > tasks count: 20
As you can see also there is still over 70kB free ram (worst case i saw is about 50kB).
In short, this project is using:
- wifi - AP and STA, with enterprise and roaming support
- ble
- mqtt
- sntp
- I2C master and slave
- OTA
- and optionally LTE, LORA, UWB, DSRC, and more
Your answer discouraged OP and he wants to abandon project, thats why i think no answer is better than wrong answer.
If you feel insulted then sorry, it was not my intention, but you have to take responsibility for answers and dont discourage people when you have no full knowledge about topic.
-
- Posts: 1703
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: arduino to IDF newbie help managing mulitple apps inline
I don't think I discouraged anyone, but I may have missed something and I appreciate you standing up against what you feel is needlessly discouraging to others.Your answer discouraged OP and he wants to abandon project, thats why i think no answer is better than wrong answer.
Now this is a great topic - I'm sure we could argue for years about the right 'size' or number of tasksIn other topic you told me to work with only 1 task (no sense, the idea of FreeRTOS is to use tasks).
Re: arduino to IDF newbie help managing mulitple apps inline
https://github.com/espressif/esp-idf/bl ... nect.c#L90mtraven wrote: ↑Sat Mar 16, 2024 10:22 pm
PS
on a separate but related note: the NPT example in IDF is EXACTLY what that first app should be. There are notes in there that the “example_connect” function is simplified & should not be used in real work applications. How serious should I take that note? This isn’t a commercial product or anything & the clock is not super critical, can I get away with just using the example as is? I ask because, every time I try to add NTP to a working WIFI init & connect, it refuses to connect. Also, where is the actual code behind "example_connect" ? all I can find is the prototype.
Re: arduino to IDF newbie help managing mulitple apps inline
hey all, FYI I haven't given up, I know I said I might, but I just cant let things go like that.
But I was compiling hard the other night and my system drive gave out on me. So here we are, a couple of days later, back up & running with a new drive.
I haven't had a chance to read all the responses, but I will for sure.
I now understand my multi "app" approach was silly and I'm becoming more familiar with task style programing.
My current predicament is, I wrote a (hopefully) proper wifi connect. Really, I just followed the examples. With a standalone chip, it runs fine*. But my chip has to be plugged into a circuit that drives an LCD. As soon as I do that, the program fails to connect. I know that sets off bells saying there is a problem with my circuit....but my Arduino framework version, with all the same hardware, is able to connect just fine. I'm gonna dig into the verbose logs and track down whatever code the arduino framework uses, I'll see what comes from that. If anyone has any general thoughts, please share.
ps -- another complication, due to library compatibility I've had to roll back to IDF 4.4.7. I dont think I need any help with that, just letting you all know, thats what I gotta use for now.
*by fine,I mean it is able to connect. It still fails exactly 2x before connecting each time, not sure what that is about.
AMENDMENT: in re-testing the hardware, I found the arduino framework did NOT connect to wifi as I thought. It does, however, run espNow and that has been thoroughly tested. Isn't espNow just wifi plus some other stuff? I dont get whats happening, and just seem to be digging myself into a deeper hole.
I just found a recording of a test where I DID successfully connect to wifi, its just not working now...theres been no hardware changes on there.
But I was compiling hard the other night and my system drive gave out on me. So here we are, a couple of days later, back up & running with a new drive.
I haven't had a chance to read all the responses, but I will for sure.
I now understand my multi "app" approach was silly and I'm becoming more familiar with task style programing.
My current predicament is, I wrote a (hopefully) proper wifi connect. Really, I just followed the examples. With a standalone chip, it runs fine*. But my chip has to be plugged into a circuit that drives an LCD. As soon as I do that, the program fails to connect. I know that sets off bells saying there is a problem with my circuit....but my Arduino framework version, with all the same hardware, is able to connect just fine. I'm gonna dig into the verbose logs and track down whatever code the arduino framework uses, I'll see what comes from that. If anyone has any general thoughts, please share.
ps -- another complication, due to library compatibility I've had to roll back to IDF 4.4.7. I dont think I need any help with that, just letting you all know, thats what I gotta use for now.
*by fine,I mean it is able to connect. It still fails exactly 2x before connecting each time, not sure what that is about.
AMENDMENT: in re-testing the hardware, I found the arduino framework did NOT connect to wifi as I thought. It does, however, run espNow and that has been thoroughly tested. Isn't espNow just wifi plus some other stuff? I dont get whats happening, and just seem to be digging myself into a deeper hole.
I just found a recording of a test where I DID successfully connect to wifi, its just not working now...theres been no hardware changes on there.
Last edited by mtraven on Fri Mar 22, 2024 2:01 am, edited 1 time in total.
Re: arduino to IDF newbie help managing mulitple apps inline
could you explain the math on that to me? Its been a point of confusion for me for a while. What are the units of "stack" ? Somewhere I got it in my head that they were bytes, obviously thats wrong...what are they?
Re: arduino to IDF newbie help managing mulitple apps inline
Yes, those are bytes.
I have each task with stack 3-4kB, sometimes even more.
Of course i am assuming that espressif internal tasks have similar stacks.
Dont look at the number here, because its stack watermark (how much bytes i can still use on stack):
I have each task with stack 3-4kB, sometimes even more.
Of course i am assuming that espressif internal tasks have similar stacks.
Dont look at the number here, because its stack watermark (how much bytes i can still use on stack):
Code: Select all
"watermark":{
"BLE_Task":1660,
"LED":120,
"mqtt":2724,
"auxled":356,
"mainled":348,
"main2led":356,
"indiLed":396,
"mainTask":1560,
Re: arduino to IDF newbie help managing mulitple apps inline
man I feel so stupid, I'm still not getting it. How does a stack size of 3000 bytes equal 60kb? Or were you listing the sum of all your tasks?
Re: arduino to IDF newbie help managing mulitple apps inline
Its 20 tasks, each with own stack of 3kB:
20 x 3kB = 60kB
20 x 3kB = 60kB
Re: arduino to IDF newbie help managing mulitple apps inline
ahhhhhh, got it, thanks for your patients. I swear, I'm not a complete idiot! ...but I'm also not a programmer. (farmer/machinist)
So you said you have wifi running on that system, is that happening with only a 3kb stack? Or does the system bite off what it needs at esp_wifi_init() ? Or is what it needs actually memory from the heap? Still working on my understanding of memory & how it all works.
I'm having a bunch of problems with wifi, I should just open a new thread, right?
Who is online
Users browsing this forum: Baidu [Spider] and 106 guests