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

Flush write buffer #21

Open
SanderEveraers opened this issue Jan 5, 2022 · 1 comment
Open

Flush write buffer #21

SanderEveraers opened this issue Jan 5, 2022 · 1 comment

Comments

@SanderEveraers
Copy link

Hi,
First of all, thank you for providing this library, it has really helped during my current project.
At this point if my application uses Ser.Write("my string"), it will stay in the write buffer until it is read by the connected device.

If for some reason, it isn't read, the buffer will keep older messages, resulting in unexpected messages when it is read at a later point, or even resulting in a segmentation fault when a buffer overflow occurs.

How can I flush the write buffer before calling Ser.Write("my string")?

@gbmhunter
Copy link
Owner

Hi @SanderEveraers , I did some quick Googling and think that tcflush() and tcdrain() might help? (see https://linux.die.net/man/3/tcdrain). tcflush seems to drop any data that is ready to be transmitted but not sent, whilst tcdrain() doesn't return until all pending data to be sent has been sent.

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