DCB structure in Serial Communication
Typedef struct _ DCB
{
// DCB
DWORD dcblength; // sizeof (DCB)
DWORD baudrate; // current baud rate
// Specify the current baud rate
DWORD fbinary: 1; // binary mode, no EOF check
// Specify whether the binary mode is allowed,
// Windows 95 must be true
DWORD fparity: 1; // enable parity checking
// Specify whether the parity check is allowed
DWORD foutxctsflow: 1; // CTS output flow control
// Specify whether CTS is used to detect sending control.
// If it is true, CTS is off and sending will be suspended.
DWORD foutxdsrflow: 1; // DSR output flow control
// Specify whether CTS is used to detect sending control.
// If it is true, CTS is off and sending will be suspended.
DWORD fdtrcontrol: 2; // DTR Flow Control Type
// The dtr_control_disable Value Sets DTR to off, and the dtr_control_enable Value Sets DTR to on. dtr_control_handshake allows DTR to "Shake hands", DWORD fdsrsensiti.pdf: 1; // when the value of DSR sensiti.pdf is true, the bytes received when the value of DSR is off are ignored.
DWORD ftxcontinueonxoff: 1; // xoff continues TX
// Specify that when the receiving buffer is full and the driver has been sent
// Whether to stop sending when xoffchar is sent.
// True: when the receiving buffer receives the xofflim byte that is full in the buffer and the driver has sent the xoffchar character to abort the receiving byte, the sending continues.
// False: when the receiving buffer receives the byte xonchar that indicates that the buffer is empty and the driver sends the xonchar to resume sending, the sending continues.
DWORD foutx: 1; // Xon/xoff Out Flow Control
// If it is set to true, the message is stopped after xoffchar is received.
// After receiving xonchar, it will start again
DWORD finx: 1; // Xon/xoff in Flow Control
// When the value is true, after the receiving buffer receives xofflim, which indicates that the buffer is full, xoffchar is sent out.
// After the receiving buffer receives the xonlim that indicates the buffer is empty, the xonchar is sent out.
DWORD ferrorchar: 1; // enable error replacement
// When this value is true and fparity is true, use the characters specified by the errorchar member to replace the receiving characters for parity errors.
DWORD fnull: 1; // enable null Stripping
// When the value is true, the null (0 value) bytes are removed during receiving.
DWORD frtscontrol: 2; // RTS Flow Control
Rts_control_disable
Rts_control_enable
Rts_control_handshake,
// When the receiving buffer is less than half full, the RTS is on.
// When the receiving buffer exceeds 3/4 full, the RTS is off.
When rts_control_toggle,
// When the receiving buffer still has the remaining bytes, the RTS is on; otherwise, the default value is off.
DWORD fabortonerror: 1; // abort reads/writes on Error
// If the value is true, the read and write operations are aborted when an error occurs.
DWORD fdummy2: 17; // Reserved
// Unused
Word wreserved; // not currently used
// Not used, must be 0
Word xonlim; // transmit Xon threshold
// Specify the minimum number of bytes allowed in the buffer before the Xon character is sent
Word xofflim; // transmit xoff threshold
// Specify the minimum number of bytes allowed in the buffer before the xoff character is sent
Byte bytesize; // number of bits/byte, 4-8
// Specify the data bit currently used by the port
Byte parity; // 0-4 = No, odd, even, Mark, space
// The parity method currently used by the specified port, which may be:
Evenparity, markparity, noparity, oddparity
Byte stopbits; // 0, 1, 2 = 1, 1.5, 2
// Specify the number of Stop bits currently used by the port, which may be:
// Onestopbit, one5stopbits, twostopbits
Char xonchar; // Tx and Rx Xon character
// Specify the value of Xon for sending and receiving characters
Char xoffchar; // Tx and Rx xoff character
// Specify the xoff value for sending and receiving characters
Char errorchar; // error replacement character
// This character is used to replace the value when an error occurs in the received parity.
Char eofchar; // end of input character
// When the binary mode is not used, this character can be used to indicate the end of the data
Char evtchar; // encoded ed event character
// When this character is received, an event is generated.
Word wreserved1; // reserved; do not use not used
} DCB;