jplitza / esphome_components

Custom-made components that I use for ESPHome.
GNU General Public License v3.0
11 stars 12 forks source link

Blocking call "readBytesUntil()" #3

Closed dannerph closed 2 years ago

dannerph commented 3 years ago

According to the documentation, "readBytesUntil()" is a blocking call. In order to push the responsiveness to the maximum (e.g., for multiple meters, web server enabled, ...), it should be replaced. Its logic could be kept the same.

I will have a look on this issue in the upcoming days.

jplitza commented 2 years ago

Closed by #6 if I'm not mistaken

dannerph commented 2 years ago

kind of: To give the process handle back to the main loop, if instead of while woud be required here: https://github.com/jplitza/esphome_components/blob/master/components/obis/obis.cpp#L29

However, I tested it and "while" is working a lot more stable (I guess some other loops might take too long so that there might be a buffer overflow on uart read - not checked in detail)

In the current implementation, it only return the loop if a full lines is read. in case of an error (no '\n') it might never return, which might lead to a Wifi crash on the esp8266 (the ESP32 is running wifi on the second core as far as I know)