CSerial icon indicating copy to clipboard operation
CSerial copied to clipboard

Add ability to block on reads

Open ApparentWindDirection opened this issue 9 months ago • 1 comments

It would be useful to be able to block on reads with or without a user-defined timeout. This is a basic feature available in other serial libraries and, as far as I know, it is available both in Unix and Windows APIs.

ApparentWindDirection avatar Mar 13 '25 10:03 ApparentWindDirection

This is an intentional design decision. The idea is that you can integrate this within your main loop by using the get_poll_handle function to get a file descriptor(on *nix) or a HANDLE(on Windows) that you wait on.

Part of the issue as well is that if you care about the state of the control lines(e.g. CTS, DTR) then there are some cross-platform issues. Windows can wait until the lines change, *nix must be polled. See here for an example.

A utility function to wait until bytes come in would not be too difficult to implement though, so if you have an example of what you're looking for a PR would be helpful.

rm5248 avatar Mar 13 '25 14:03 rm5248