Windows 7 - Configure Serial Port Using DOS commands

Asked By Sushma on 07-Feb-09 10:37 PM
Hi All,

I had developed a USB-Serial driver with WDF architecture. I have a
query regarding congiguring of Serial port using DOS commands. I used
the command "mode COM3:19200,n,8,1" to set baud rate to 19200 from
command prompt. The output is:

Status for device COM3:
Baud:            1200
Parity:          None
Data Bits:       7
Stop Bits:       1
Timeout:         OFF
XON/XOFF:        OFF
CTS handshaking: OFF
DSR handshaking: OFF
DSR sensitivity: OFF
DTR circuit:     ON
RTS circuit:     ON

The baud rate is always set to 1200 even though i use any other baud
rate to set. I had debugged the driver and could see that 19200 is
being received and able to properly handle it. With the native COM
port i could see the configuration was done properly with all baud

With all other terminal applications like hyperterminal or any other
application i was able to configure properly in my driver.

Is there anything additional parameters i need to set in driver when
using DOS commands.

Any help is much appreciated.

Thanks You.


Sushma replied on 07-Feb-09 10:37 PM
I did the following sequence of steps

1. Opened a terminal application like hyperterminal with baud rate say
19200,no parity,8,1.
2. Closed the hyperterminal.
3. I opened a Win32 application which opens COM port using CreatFile()
and then used GetCommState() to retrieve the DCB structure. I observed
that baud rate is set to 1200 in DCB. Default settings are displayed.

I performed same steps for native COM port (COM1). After step #3 the
baud rate was shown as 19200.

I think i'm missing some settings while closing the port. or flushing
out serial port settings when EvtFileClose() is called. or missing
Can any one throw some light on this scenario.

chris.aseltin replied on 07-Feb-09 10:37 PM
There's a serial IOCTL that's sent to your driver to retrieve baud
rate, parity, and other settings.  Are you responding to it properly?
Are you setting the "Information" field of the IRP before you complete
Sushma replied on 07-Feb-09 10:37 PM
The IOCTL related to baud rate, parity are correctly being handled. Im
able to do data transfer by changing the baud rates. Its only after
closing the terminal application i'm not able to retrieve the last set
baud rate and other parameters.

Looks like i need to care of some parameters before/after closing the