Windows serial port driver bugs/caveats???
Posted on 2002-06-07
I'm getting "interesting" behavior from the Windows serial port driver that I need to resolve. It involves
1. It seems to me that some of the DCB members are ignored during the opening of a COM port with CreateFile.
I am seeing the following behavior:
I call SetDefaultCommConfig( "COM1", &cfg, &dwSize ) with
cfg.dcb.fRtsControl = RTS_CONTROL_ENABLE;
cfg.dcb.fDtrControl = DTR_CONTROL_ENABLE;
and then call CreateFile( "COM1", ... )
However, CreateFile still disables the RTS and DTR lines automatically (sets them to logic 1).
2. Things get weirder once you call a GetCommState( &dcb ) which, even though the DTR line is disabled
(negative voltage read on voltmeter = logic 1, but DTR is active low) reports that
dcb.fDtrControl = DTR_CONTROL_ENABLE
By then calling SetCommState right after that (without modifying anything, ie:
GetCommState( &dcb );
SetCommState( &dcb );
all of a sudden DTR and RTS go active (according to GetCommState RTS == RTS_CONTROL_TOGGLE in spite
of what I tried to set with SetDefaultCommConfig)
Basically what I *NEED* is that when I call CreateFile( "COM1", ... ) the RTS line is NOT dropped to
a negative voltage (logic 1) automatically.
I'd also like some insight into the above-described behavior if anyone has any.
Thank you very much.
PS I'm on WinMe but I'm getting similar behavior from other Win9x based systems.
(A copy of this question is also posted in the MFC section.)