[Schedule Commands] Only schedule commands not running Arduino stack#1838
[Schedule Commands] Only schedule commands not running Arduino stack#1838TD-er wants to merge 2 commits intoletscontrolit:megafrom
Conversation
Since command scheduling may be calling `yield`, move commands to the queue only when called from a callback function.
|
I would like to understand what you did here but I just don't get it. Can you please add a sentence or two to help me out here ? I try to keep up to speed on stability issues ;-) |
|
The old implementation executed the command immediately (without placing it in the queue) when called from the web interface. That would make sense, because then you get the output also shown in the browser. 2 weeks ago, I changed all (back) to run immediately, but that led to reported crashes. Since I'm looking into how the stack(s) work in ESPxx, I found this function to determine if it is called from system stack or Arduino stack. (meaning can you call 'yield' and other functions only available in Arduino stack) Now to what's this PR about... So I will make a test build from this PR, so anyone can test and hopefully not crash the nodes. |
|
I added a fix for SendToHTTP timeouts to this PR. (see #1830 ) The default timeout of Stream is 1000 msec, which may be a little too long. |
|
I also don't get it. I think it is best to discern the ESP8266 from the ESP32 to get things clear. The ESP32 is a different story. But in that context talking about an Arduino and System stack is unclear to me. In that context, each created task (e.g. created by xTaskCreatePinnedToCore()) has its own stack. In this context you get task-to-task communication and one of the methods to isolate code to one environment is to push commands on a queue and let only one tasks handle the commands. Locking should be used when queue handling is involved. |
|
In the ESP32 environment you can also compare the active task with the task that should run the code and decide to run or 'schedule' the code but I rather prefer the previous method mentioned. |
|
You can call code from other stack than from the Arduino stack. When you run code from a callback function, it is not within the scope of setup or loop. This is not ESP32 related. Also don't confuse the idea of the scheduler I am now talking about with the RTOS scheduler. |
|
Did anybody test this PR? |
|
@TD-er: I'm just compiling and flashing a few units with this code... will report if I find issues with it! |
|
unfortunately no luck... sending a comand (event) via controller or on the web-console immediately triggers a software watchdog (see below).... can't currently debug more as I'm remote... however using latest mega-commit from this morning (b1c777e) works without issues (also self compiled)... Free Mem | 15192 (13464 - sendContentBlocking) |
|
@clumsy-stefan do you have an example of such a command? |
|
|
|
Can you give the corresponding rules lines? |
|
sure, sorry: where Task Nr. 5 is labelled "ch1" with a value of "switch" configured as "push button active low" on gpio-1 PS: sorry, I can't get the lines to format correctly in here.. |
|
Hello, Rules: Log file (MQTT enabled): Log file (MQTT disabled): |
|
@artua at first glance it looks to be related to the commands still running from the queue. |
|
@TD-er it is good idea to only schedule network related commands, but before schedule parse strings to change all data to actual at moment of schedule,what do you think? |
|
@uzi18 I am not really sure. If we move it back to how it was (without running via the scheduler), it will cause resets. (no idea why, stack overflow???) |
|
But with the current scheduling the rules are slow and impossible to use in
real case scenarios. For example, the switch with double click or long
click.
…On Thu, Nov 8, 2018 at 12:33 AM Gijs Noorlander ***@***.***> wrote:
@uzi18 <https://github.com/uzi18> I am not really sure.
The main problem I didn't think of when moving the commands to the
scheduler, is that calling a command from within a rule will no longer
guarantee it has been performed.
So the flow of a rule has changed.
If we move it back to how it was (without running via the scheduler), it
will cause resets. (no idea why, stack overflow???)
Also, if we only run network related commands via the scheduler, I don't
know if that will also result in counter-intuitive response, where commands
may not yet be executed.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1838 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGV_3dcyeJWnYjwy3IgvgS872CGJbsdgks5us1-hgaJpZM4XC7Ui>
.
|
|
@artua are you sure they are slow? I would think they are "too fast" since the will trigger simultaneously. |
Hi @Grovkillen |
|
If the commands are part of the scheduler they will trigger almost simultaneously which is not how the rules used to work. They were sequential then. I actually love the new way of handling rules but many users do not grasp that aspect of rules. So we have discussed having both sequential and simultaneous execution of commands. So it's not actually something for this PR but a complete over haul of how the rules engine should work. |
Sorry, I thought you were talking about the speed of double click and longpress. @artua: can you elaborate regarding your experience with doubleclick and longpress? It's useful for me to tweak the parameters. |
|
See my first message.
That’s part of the code to make a short/long press logics. It didn’t work
as expected. The dummy device var didn’t set before processing next line so
the timer didn’t run.
…On Thu, Nov 8, 2018 at 10:57 AM Plebs ***@***.***> wrote:
If the commands are part of the scheduler they will trigger almost
simultaneously which is not how the rules used to work. They were
sequential then.
I actually love the new way of handling rules but many users do not grasp
that aspect of rules. So we have discussed having both sequential and
simultaneous execution of commands. So it's not actually something for this
PR but a complete over haul of how the rules engine should work.
Sorry, I thought you were talking about the speed of double click and
longpress.
@artua <https://github.com/artua>: can you elaborate regarding your
experience with doubleclick and longpress? It's useful for me to tweak the
parameters.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1838 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGV_3b_tFQOGKeiFChar799L5TuCgpJuks5us_HjgaJpZM4XC7Ui>
.
|
I understand. |
|
@TD-er did You checked if you got crash also on ESP32 where more memory is available? |
|
@uzi18 An event has an origin, so we can use that to decide how to execute it. I did notice yesterday, it is hardly doing any checks on UDP data and from there you may also execute commands. |
|
@giig1967g the embedded double/long click works, but I receive two events anyway: But I need to drive two different scenarios separately (short press and long press), so I need to go old way and set the values of Dummy device and then check them on Switch off. But the values checking still broken (I think) because of command queue.. Any ideas how to deal with that new short/long press without setting/checking values? BTW, TaskValueSet seems to be broken, no effect on |
I think it should be: Regarding the longpress, please tell me how you would like it. |
|
On SW1#On=0 do |
|
Ok, now it's working again. Thanks everyone! But I don't think the same can be done with double click.. Any ideas? |
Since command scheduling may be calling
yield, move commands to the queue only when called from a callback function.