DCB

Communications-Device Control Block

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

typedef struct tagDCB {

BYTE Id;

WORD BaudRate;

BYTE ByteSize;

BYTE Parity;

BYTE StopBits;

WORD RlsTimeout;

WORD CtsTimeout;

WORD DsrTimeout;

BYTE fBinary: 1;

BYTE fRtsDisable: 1;

BYTE fParity: 1;

BYTE fOutxCtsFlow: 1;

BYTE fOutxDsrFlow: 1;

BYTE fDummy: 2;

BYTE fDtrDisable: 1;

BYTE fOutX: 1;

BYTE fInX: 1;

BYTE fPeChar: 1;

BYTE fNull: 1;

BYTE fChEvt: 1;

BYTE fDtrflow: 1;

BYTE fRtsflow: 1;

BYTE fDummy2: 1;

char XonChar;

char XoffChar;

WORD XonLim;

WORD XoffLim;

char PeChar;

char EofChar;

char EvtChar;

WORD TxDelay;

} DCB;

The DCB structure has the following fields:

Field Description  
Id Specifies the communication device. This value is set by the device driver. If the most significant bit is set, then the DCB structure is for a parallel device.  
BaudRate Specifies the baud rate at which the communications device operates.  
ByteSize Specifies the number of bits in the characters transmitted and received. The ByteSize field can be any number from 4 to 8.  
Parity Specifies the parity scheme to be used. The Parity field can be any one of the following values:  
  Value Meaning
  EVENPARITY Even
  MARKPARITY Mark
  NOPARITY No parity
  ODDPARITY Odd
  SPACEPARITY Space
StopBits Specifies the number of stop bits to be used. The StopBits field 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 receive-line-signal-detect (RLSD) 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 clear-to-send (CTS) signal.  
DsrTimeout Specifies the maximum amount of time (in milliseconds) the device should wait for the data-set-ready (DSR) signal.  
fBinary: 1 Specifies binary mode. In nonbinary mode, the EofChar character is recognized on input and remembered as the end of data.  
fRtsDisable: 1 Specifies whether or not the request-to-send (RTS) signal is disabled. If the fRtsDisable field is set, RTS is not used and remains low. If fRtsDisable is clear, RTS is sent when the device is opened and turned off when the device is closed.  
fParity: 1 Specifies whether parity checking is enabled. If the fParity field is set, parity checking is performed and errors are reported.  
fOutxCtsFlow: 1 Specifies that clear-to-send (CTS) signal is to be monitored for output flow control. If the fOutxCtsFlow field is set and CTS is turned off, output is suspended until CTS is again sent.  
fOutxDsrFlow: 1 Specifies that the data-set-ready (DSR) signal is to be monitored for output flow control. If the fOutxDsrFlow field is set and DSR is turned off, output is suspended until DSR is again sent.  
fDummy: 2 Reserved.  
fDtrDisable: 1 Specifies whether the data-terminal-ready (DTR) signal is disabled. If the fDtrDisable field is set, DTR is not used and remains low. If fDtrDisable is clear, DTR is sent when the device is opened and turned off when the device is closed.  
fOutX: 1 Specifies that XON/XOFF flow control is used during transmission. If the fOutX field is set, transmission stops when the XoffChar character is received, and starts again when the XonChar character is received.  
fInX: 1 Specifies that XON/XOFF flow control is used during reception. If the fInX field is set, the XonChar character is sent when the receive queue comes within XoffLim characters of being full, and the XonChar character is sent when the receive queue comes within XonLim characters of being empty.  
fPeChar: 1 Specifies that characters received with parity errors are to be replaced with the character specified by the fPeChar field. The fParity field must be set for the replacement to occur.  
fNull: 1 Specifies that received null characters are to be discarded.  
fChEvt: 1 Specifies that reception of the EvtChar character is to be flagged as an event.  
fDtrflow: 1 Specifies that the data-terminal-ready (DTR) signal is to be used for receive flow control. If the fDtrflow field is set, DTR is turned off when the receive queue comes within XoffLim characters of being full, and sent when the receive queue comes within XonLim characters of being empty.  
fRtsflow: 1 Specifies that the ready-to-send (RTS) signal is to be used for receive flow control. If the fRtsflow field is set, RTS is turned off when the receive queue comes within XoffLim characters of being full, and sent when the receive queue comes within XonLim characters of being empty.  
fdummy2: 1 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 receive queue before the XON character is sent.  
XoffLim Specifies the maximum number of characters allowed in the receive queue before the XOFF character is sent. The XoffLim value is subtracted from the size of the receive 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

The BuildCommDCB, GetCommState, and SetCommState functions in Chapter 4, “Functions Directory.”