You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @araffin , I came across your library and medium article and found it helpful in writing my own binary protocol for arduino. I was wondering why you considered that readBytes is slow compared to checking if serial.available()>size and then using read().
Good question, I think this came from test a colleague did a while ago (already 5 years from now...)
But maybe it has changed or the test is not valid anymore. Feel free to replace that with the readBytes, I would be happy to have a feeback/proper comparison ;).
Hi,
I looked up the code for upto 2012 and based on what I saw, the code for readBytes and timedRead are the same. What might however cause different behaviour is that readBytes calls timedRead n times for n bytes. Each timedRead makes a call to millis (which could be making the difference here).
Your code however waits for the all the bytes to be available in the serial buffer before reading all of them at once.
I haven't made any measurements on a DSO and can't verify this however. I don't even know if readBytes is infact slower, let alone how much slower per byte(microseconds, milliseconds etc). Let me know if you find out more.
Hi @araffin , I came across your library and medium article and found it helpful in writing my own binary protocol for arduino. I was wondering why you considered that readBytes is slow compared to checking if serial.available()>size and then using read().
arduino-robust-serial/arduino-board/slave.cpp
Line 157 in 5d83ec5
The text was updated successfully, but these errors were encountered: