-
Notifications
You must be signed in to change notification settings - Fork 1
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
Autogain delays crowd out other events and lead to connection losses #7
Comments
At the time I coded this, I did not know of a way to call things on a regular basis inside tasmota to check for passed waiting intervals. I dont like delays either, so I'm prepared to change that. Do you have the refactored code for review somewhere? Whatever works, but a pull request would be ideal... |
OK, so I haven't gotten around to breaking it out into a proper pull request, but here is an example from a sketch I'm currently working on (a lighting controller for an IKEA VÄXER hydroponic growing unit). I'll commit that into a separate repository as soon as it's presentable. The basic idea is the following: control the sensor through a state machine, which is a routine called regularly from
The debugging macros are those from Joao Lopes' Anyway, that gets you the idea. This is not too beautiful yet and I suspect some of the variables can be done away with. Ideally I'd wrap this into a class (and other state machines for reading other sensors into other classes with a consistent interface). |
Looks like a good way to handle this in general. Problem for tasmota is, afaik the handler can't be called often. |
Really? I've never looked at Tasmota in detail, but it must have a finer-grained loop internally, otherwise it would be impossible to drive things like displays.
I'll take a look at Tasmota and maybe I can port part of my hydroponic control system's code to it. There are some other things that might be possibly useful, e.g. some user interface code.
I've also started to put together an alternative backend for Tsl2561 to use the Brzo I2C library, which on ESP8266 is much faster than Wire.h and gives better I2C signals. I'll produce a pull request at some point over the next two weeks.
…On Febr. 2 2019, at 6:15 am, joba-1 ***@***.***> wrote:
Looks like a good way to handle this in general.
Problem for tasmota is, afaik the handler can't be called often.
There is only a coarse 1-second-interval interface.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub ***@***.***/0?redirect=https%3A%2F%2Fgithub.com%2Fjoba-1%2FJoba_Tsl2561%2Fissues%2F7%23issuecomment-459911445&recipient=cmVwbHkrMDIxNmYxOGJmYTVlYzk3ZmQ5Yzk4ODkxMDFjZDFiYTVlODliMGFiYjA5M2RiYmYyOTJjZjAwMDAwMDAxMTg2Y2EzMDQ5MmExNjljZTE3YmJlMjA3QHJlcGx5LmdpdGh1Yi5jb20%3D), or mute the thread ***@***.***/1?redirect=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAhbxiwLHCG9auY_00tsrl0JeHWNRyOE1ks5vJNiEgaJpZM4Z7CJz&recipient=cmVwbHkrMDIxNmYxOGJmYTVlYzk3ZmQ5Yzk4ODkxMDFjZDFiYTVlODliMGFiYjA5M2RiYmYyOTJjZjAwMDAwMDAxMTg2Y2EzMDQ5MmExNjljZTE3YmJlMjA3QHJlcGx5LmdpdGh1Yi5jb20%3D).
|
tasmota now has a 50ms hook for drivers. I plan to use this. Not ready, but if you want to have a look: branch async-autogain |
When it's dark, the autogain readout can take several seconds. During this time the system is busy mostly in the following section of code:
The problem is that
delay()
is not very well-behaved, so that other code that depends on regular calls to maintain connections and event loops is being crowded out. Whiledelay()
does the basics such as feeding watchdogs, a typical problem example is MQTT using thePubSubClient
library (as outlined in this article). I regularly see lost MQTT connections and missed messages when it's dark because the system cannot respond to them.I see two main ways out of this:
autoGain()
routine into a state machine. I call it regularly from the mainloop()
and it maintains timers internally so that there is no use ofdelay()
and no lockups at all. That's a rather heavyweight solution, though.delay()
functions that makes the necessary callbacks.The text was updated successfully, but these errors were encountered: