-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loop and recursion #42
Comments
Recursion is not supported (only one level of "on" statements). Perhaps I should have a view into the script. Flashing the binary doesn't delete the script. If you want to, do this: |
A language, to be "Turing complete" must have 3 structures: sequences, selections (if, or case, - all are equivalents) and iteractions (while or do or for - all are equivalents). The MQTT script is missing iterations. Iterations can ben done also with function recursion, but it looks that script do not allows recursion. So it is important to add some form of iteration:. Why I need it? The problem is at the start: if Sonoff starts at 09:10, I must set the alarm to 10:30:. To do this I must to iterate over the full array, to find the first start time bigger than 09:10: no alternatives, no way. To give you an idea of the application, see https://github.com/msillano/sonoff_watering (work in progress not full finished), This poject is simpler. because it do not need iterations: times are only 2, T1 and T2, but it is very near at the new one. Martin, thanks for your time. p.s. |
Marco, as a computer scientist I was aware, that the language is not "Turing complete". Actually, it was originally never intended to be. A downside of being "Turing complete" is the "Halting problem" or even less, the ability to code arbitrary long loops. I was thinking of small action-response clauses, that cannot block the CPU... For more sophisticated apps I thought using the uMQTTBroker lib with an Arduino sketch would be a generic solution. Nevertheless, I will think about a "while" loop... Cheers, |
Just added a "while do" to the language... ;-) |
hahaha wonderful ! |
Testing a recursive script, Sonoff goes on loop. Using the serial console (PuTTY) I get:
I cannot insert any command !.
I also re-flashed the Sonoff (using last bin files) but it stiil loops :(
Any idea?
I'm trying to do iterations using 'on topic' as recursive function.
So it is possible that the script (wrong) goes in infinite loop, giving a stack error.
But flashing Sonoff don't clear the script?
Best regards
Marco
The text was updated successfully, but these errors were encountered: