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

[Question] How to check whether Write has completed transmitting the buffer? #143

Open
markandpathak opened this issue Nov 7, 2022 · 1 comment

Comments

@markandpathak
Copy link

markandpathak commented Nov 7, 2022

TL,DR: Does write function block till complete message is transmitted? if not How can we check whether the complete write buffer has been transmitted or not? and if write is pending how may bytes have been sent or remaining?

There are generally two buffers in the Linux based hardware. One is the hardware buffer and other one is the buffer provided by kernel. Certain applications require to perform a task once data is sent and where RTS/CTS lines are not available. i.e controlling transceiver IC through transmit enable line(DE). We have to control DE line through GPIO as board UART port does not have RTS/CTS lines. Immediately changing state of DE line after write call may cause partial transmission if write is nonblocking.

If write function blocks until complete buffer is transmitted then it is not a concern. But if not, how can I ensure complete message delivery? Calculating time delay based on baud-rate is one option but I'm looking for more robust way.

Using library on Linux.

@KiddoV
Copy link

KiddoV commented Apr 8, 2024

Sounds like this method p.Drain() is what you are looking for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants