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
I am trying to incorporate USB serial communication into a more complex program that does several operations between serial reads. While working on this, I have noticed a strange issue where any delay before the serial.read() call will cause most incoming bytes to be dropped for some reason. Here's a simple demonstration of a serial echo program:
This program is supposed to read all incoming bytes, and echo them back to the serial port. The issue is, that the delay_ms(100) causes most of the incoming bytes to be ignored.
Example input: ABCDEFGH
Output: AB
If I recreate the same program in C++, everything works as expected:
This version of the program does exactly what it's supposed to do, which is echo back every character read with a 100ms delay.
I assume this is happening due to some internal hidden buffering that exists in the Arduino C++ framework which presumably isn't implemented in the Rust HAL. Is there a way to make this program function the same way it does in C++?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to incorporate USB serial communication into a more complex program that does several operations between serial reads. While working on this, I have noticed a strange issue where any delay before the
serial.read()
call will cause most incoming bytes to be dropped for some reason. Here's a simple demonstration of a serial echo program:This program is supposed to read all incoming bytes, and echo them back to the serial port. The issue is, that the
delay_ms(100)
causes most of the incoming bytes to be ignored.Example input: ABCDEFGH
Output: AB
If I recreate the same program in C++, everything works as expected:
Example input: ABCDEFGH
Output: ABCDEFGH
This version of the program does exactly what it's supposed to do, which is echo back every character read with a 100ms delay.
I assume this is happening due to some internal hidden buffering that exists in the Arduino C++ framework which presumably isn't implemented in the Rust HAL. Is there a way to make this program function the same way it does in C++?
Beta Was this translation helpful? Give feedback.
All reactions