DCB

2.x

typedef struct tagDCB        /* dcb                             */
{
    BYTE Id;                 /* internal device identifier      */
    UINT BaudRate;           /* baud rate                       */
    BYTE ByteSize;           /* number of bits/byte, 4-8        */
    BYTE Parity;             /* 0-4=none,odd,even,mark,space    */
    BYTE StopBits;           /* 0,1,2 = 1, 1.5, 2               */
    UINT RlsTimeout;         /* timeout for RLSD to be set      */
    UINT CtsTimeout;         /* timeout for CTS to be set       */
    UINT DsrTimeout;         /* timeout for DSR to be set       */

    UINT fBinary        :1;  /* binary mode (skip EOF check)    */
    UINT fRtsDisable    :1;  /* don't assert RTS at init time   */
    UINT fParity        :1;  /* enable parity checking          */
    UINT fOutxCtsFlow   :1;  /* CTS handshaking on output       */
    UINT fOutxDsrFlow   :1;  /* DSR handshaking on output       */
    UINT fDummy         :2;  /* reserved                        */
    UINT fDtrDisable    :1;  /* don't assert DTR at init time   */

    UINT fOutX          :1;  /* enable output XON/XOFF          */
    UINT fInX           :1;  /* enable input XON/XOFF           */
    UINT fPeChar        :1;  /* enable parity err replacement   */
    UINT fNull          :1;  /* enable null stripping           */
    UINT fChEvt         :1;  /* enable Rx character event       */
    UINT fDtrflow       :1;  /* DTR handshake on input          */
    UINT fRtsflow       :1;  /* RTS handshake on input          */
    UINT fDummy2        :1;

    char XonChar;            /* Tx and Rx XON character         */
    char XoffChar;           /* Tx and Rx XOFF character        */
    UINT XonLim;             /* transmit XON threshold          */
    UINT XoffLim;            /* transmit XOFF threshold         */
    char PeChar;             /* parity error replacement char   */
    char EofChar;            /* end of Input character          */
    char EvtChar;            /* received event character        */
    UINT TxDelay;            /* amount of time between chars    */
} DCB;

The DCB structure defines the control setting for a serial communications device.

Members

Id

Specifies the communication device. This value is set by the device driver. If the most significant bit is set, the DCB structure is for a parallel device.

BaudRate

Specifies the baud rate at which the communications device operates. If the value of the high-order byte is equal to 0xFF, the low-order byte specifies a baud-rate index. The index can be one of the following values:

CBR_110 CBR_4400 CBR_9200 CBR_8400 CBR_6000 CBR_28000 CBR_9600 CBR_14400 CBR_19200 CBR_38400 CBR_56000 CBR_128000 CBR_256000

If the high-order byte is not equal to 0xFF, this parameter specifies the actual baud rate.

ByteSize

Specifies the number of bits in the characters transmitted and received. This member can be any number from 4 through 8.

Parity

Specifies the parity scheme to be used. This member can be any one of the following values:

Value Meaning

EVENPARITY Even
MARKPARITY Mark
NOPARITY No parity
ODDPARITY Odd

StopBits

Specifies the number of stop bits to be used. This member can be any one of the following values:

Value Meaning

ONESTOPBIT 1 stop bit
ONE5STOPBITS 1.5 stop bits
TWOSTOPBITS 2 stop bits

RlsTimeout

Specifies the maximum amount of time, in milliseconds, the device should wait for the RLSD (receive-line-signal-detect) signal. RLSD is also known as the carrier-detect (CD) signal.

CtsTimeout

Specifies the maximum amount of time, in milliseconds, the device should wait for the CTS (clear-to-send) signal.

DsrTimeout

Specifies the maximum amount of time, in milliseconds, the device should wait for the DSR (data-set-ready) signal.

fBinary

Specifies binary mode. In nonbinary mode, the EofChar character is recognized on input and remembered as the end of data.

fRtsDisable

Specifies whether or not the RTS (request-to-send) signal is disabled. If this member is set, RTS is not used and remains low. If this member is clear, RTS is sent when the device is opened and turned off when the device is closed.

fParity

Specifies whether parity checking is enabled. If this member is set, parity checking is performed and errors are reported.

fOutxCtsFlow

Specifies that CTS (clear-to-send) signal is to be monitored for output flow control. If this member is set and CTS is turned off, output is suspended until CTS is again sent.

fOutxDsrFlow

Specifies that the DSR (data-set-ready) signal is to be monitored for output flow control. If this member is set and DSR is turned off, output is suspended until DSR is again sent.

fDummy

Reserved.

fDtrDisable

Specifies whether the DTR (data-terminal-ready) signal is disabled. If this member is set, DTR is not used and remains low. If this member is clear, DTR is sent when the device is opened and turned off when the device is closed.

fOutX

Specifies that XON/XOFF flow control is used during transmission. If this member is set, transmission stops when the XoffChar character is received and starts again when the XonChar character is received.

fInX

Specifies that XON/XOFF flow control is used during reception. If this member is set, the XonChar character is sent when the reception queue comes within XoffLim characters of being full and the XonChar character is sent when the reception queue comes within XonLim characters of being empty.

fPeChar

Specifies that characters received with parity errors are to be replaced with the character specified by this member. This member must be set for the replacement to occur.

fNull

Specifies that received null characters are to be discarded.

fChEvt

Specifies that reception of the EvtChar character is to be flagged as an event.

fDtrflow

Specifies that the DTR (data-terminal-ready) signal is to be used for reception flow control. If this member is set, DTR is turned off when the reception queue comes within XoffLim characters of being full and sent when the reception queue comes within XonLim characters of being empty.

fRtsflow

Specifies that the RTS (ready-to-send) signal is to be used for reception flow control. If this member is set, RTS is turned off when the reception queue comes within XoffLim characters of being full, and sent when the reception queue comes within XonLim characters of being empty.

fDummy2

Reserved.

XonChar

Specifies the value of the XON character for both transmission and reception.

XoffChar

Specifies the value of the XOFF character for both transmission and reception.

XonLim

Specifies the minimum number of characters allowed in the reception queue before the XON character is sent.

XoffLim

Specifies the maximum number of characters allowed in the reception queue before the XOFF character is sent. The value of the XoffLim member is subtracted from the size of the reception queue, in bytes, to calculate the maximum number of characters allowed.

PeChar

Specifies the value of the character used to replace characters received with a parity error.

EofChar

Specifies the value of the character used to signal the end of data.

EvtChar

Specifies the value of the character used to signal an event.

TxDelay

Not currently used.

See Also

BuildCommDCB, GetCommState, SetCommState