Added serial reads to flush spurious output from sensor#3
Added serial reads to flush spurious output from sensor#3gitpeut wants to merge 2 commits intoShaggyDog18:masterfrom
Conversation
Used library to get Winsen ZH07 device. Input and output are the same as the ZH06 . Spurious output from the sensor made sleep, wake and other commands fail unpredictably. Added serial reads to flush such unexpected sensor inputs
|
There is no need to modify the library. You may call a serial "clean up" function, for example: after calling library functions that read from RX when you need it and for the troublesome sensors. The library is universal and works fine for most of existing sensors. Your case is kind of unique and you offered a simple solution to avoid an unpredictable garbage on RX. Having it as a separate function would also reduce your code size (you repeated the same code in multiple function methods). |
|
Thanks for your thoughts. Not sure if the compiler wouldn't inline the one simple loop, but I agree style-wise To me it makes more sense to add the RX_flush function to the library, since _serial is private and no getter is available. As I ran into this issue of spurous data, it's likely others will too in some cases, and I can't think of a scenario where See also my latest commit. Your thoughts? |
Used library to get Winsen ZH07 device working. Input and output are the same as the ZH06 . Spurious output from the sensor made sleep, wake and other commands fail unpredictably. Added serial reads to flush such unexpected sensor inputs