I wonder if and how it's possible to control the RS-232 handshaking lines directly from win32 (the old C-API).
I'd like to interface with an external piece of hardware, and two simple data-lines would be sufficient for my needs.
So - is there a API for win32 that lets me read and write the state of the four status lines? In normal serial communication the handshaking lines are driven by the UART automatically (if hardware handshaking is enabled).
I remember that it was trivial under DOS. One just had to program the UART directly. Has this functionality survived in win32 somehow?
You can control RTS and DTR using SetCommState()
. You can also set things up to have hardware or the driver handle hardware flowcontrol (CTS and/or DSR), or you can set things up using SetCommMask()
so you get events when those signals change.
A decent overview is here: http://msdn.microsoft.com/en-us/library/ms810467.aspx
Note that the Win32 Serial Comm API and/or driver can be finicky, so be prepared to have to do some debugging of what's going on on the wire.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With