bolderflight / sbus

Arduino and CMake library for communicating with SBUS receivers and servos.
MIT License
373 stars 132 forks source link

fixed Parse overwritting buf_ #60

Closed H7perus closed 1 year ago

H7perus commented 1 year ago

If Parse() returns true, the while loop will still run once after(I am guessing because there is still data in the serial RX buffer), overwritting the buffer. This is a non issue under normal conditions, as it would just overwrite near identical data. However if the second byte is equal to the header (0x0F), Parse() will assume that second byte to be the footer. This is because the execution branch at the end does not do "prevbyte = currbyte", while still having set currbyte to the current package, hence skipping the header in the evaluation.

H7perus commented 1 year ago

I should note my hardware: Its an ESP32 devboard with an ESP32-WROOM-32. I am not sure this issue appears on other platforms.

flybrianfly commented 1 year ago

Thanks! This helped me find a bug with our timing. I'm not going to pull it, because we solved the problem by altering the Parse method and I still need the Read method to go through all available SBUS packets - sometimes, we have a delay before the code starts and a lot of packets to read through. Thanks again.