wjwwood / serial

Cross-platform, Serial Port library written in C++
http://wjwwood.github.com/serial/
MIT License
2.13k stars 1.04k forks source link

Fix Unix ioctl call and exception text in waitForChange #224

Open rhulme opened 4 years ago

rhulme commented 4 years ago

ioctl call TIOCMIWAIT expects the flags as an immediate parameter, not a pointer.

wjwwood commented 3 years ago

@rhulme can you point to any documentation on this? I can't find anything specific about this. The only thing I can find is this on the ioctl man page:

The third argument is an untyped pointer to memory. It's traditionally char argp (from the days before void was valid C), and will be so named for this discussion.

-- https://man7.org/linux/man-pages/man2/ioctl.2.html

rhulme commented 3 years ago

@rhulme can you point to any documentation on this? I can't find anything specific about this. The only thing I can find is this on the ioctl man page:

The third argument is an untyped pointer to memory. It's traditionally char argp (from the days before void was valid C), and will be so named for this discussion.

-- https://man7.org/linux/man-pages/man2/ioctl.2.html

@wjwwood : ioctl is a variadic function. It's up to the function itself to decide how many parameters it expects after the fixed parameters (in this case two) and what type they are. So the same way printf decides how to interpret the parameters that come after the format string.

As ioctl is a general-purpose interface for pretty much any kind of driver, the number and meaning of the parameters will vary from driver to driver (or at least between classes of driver).

The commands and parameters for the TTY class are described here:

https://man7.org/linux/man-pages/man4/tty_ioctl.4.html

TIOCMIWAIT Argument: int arg

rhulme commented 1 year ago

Just pinging this as the PR is still marked as "awaiting feedback" but I provided feedback in June 2021.