Serial port output buffer size in Windows 7

dreamlayers picture dreamlayers · Oct 24, 2011 · Viewed 8.7k times · Source

Unix serial ports have a large output buffer. Write calls return immediately as long as there's space in the buffer. When there isn't enough space, a blocking write waits until the buffer is emptied to some low level.

In Windows 7 SP1, the built-in 16550 serial port behaves as if there's no output buffer. It seems writes block until the data is output from the port. If there is a buffer, it's even smaller than the 16 bytes set in Device Manager (in Advanced Settings for COM1). The SetupComm function lets me specify recommended sizes for input and output buffers. However, the output buffer size doesn't seem to change any behaviour, and GetCommProperties always sets the dwCurrentTxQueue field to zero. The only thing SetupComm can do is increasing the size of the input buffer.

Answer

Harry Johnston picture Harry Johnston · Oct 25, 2011

The documentation for SetupComm specifically permits the device driver to ignore the requested values.

Your best bet is to use overlapped I/O and handle the buffering yourself.