Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial.availableForWrite function #798

m-mcgowan opened this issue Jan 6, 2016 · 2 comments · Fixed by #812


Copy link

commented Jan 6, 2016

We can check if the TX buffer is full or not to allow applications to implement flow control.

@m-mcgowan m-mcgowan added this to the 0.4.9 milestone Jan 6, 2016


This comment has been minimized.

Copy link

commented Jan 6, 2016

👍 Thanks for filing this!


This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2016

Currently, the hardware serial devices corrupt data if fed too quickly. I feel the default should be to block until the buffer is emptied, so the application doesn't have to concern itself with how fast it writes data by default. For most, having the correct data output is more important than writing it quickly and getting corrupted data. For cases where performance is critical, a new method. blockOnOverrun(false) can be called to disable blocking, and revert to the current non-blocking behavior that overruns the buffer.

The USB serial device write function includes a delay as a simple form of flow control. Instead, it should check if the buffer would overrun and block, similarly to Serial1. One additional point is that the buffer is not emptied if no USB host is connected, so the method should block only when a host is connected. This can be detected by checking the established linerate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.