1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 19:54:57 +08:00

Add initialization params for serial port so that it can be read correctly without having to be initialized by another application.

This commit is contained in:
Kevin Smathers 2017-11-13 13:10:53 -08:00
parent 827c4a784d
commit cb7acae7c6

View File

@ -70,7 +70,7 @@ Serial::SerialImpl::open ()
0,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
FILE_ATTRIBUTE_NORMAL, // FILE_FLAG_OVERLAPPED
0);
if (fd_ == INVALID_HANDLE_VALUE) {
@ -108,6 +108,20 @@ Serial::SerialImpl::reconfigurePort ()
THROW (IOException, "Error getting the serial port state.");
}
// Boilerplate default settings
dcbSerialParams.fBinary = TRUE;
dcbSerialParams.fDtrControl = DTR_CONTROL_ENABLE;
dcbSerialParams.fDsrSensitivity = FALSE;
dcbSerialParams.fTXContinueOnXoff = FALSE;
dcbSerialParams.fOutX = FALSE;
dcbSerialParams.fInX = FALSE;
dcbSerialParams.fErrorChar = FALSE;
dcbSerialParams.fNull = FALSE;
dcbSerialParams.fRtsControl = RTS_CONTROL_ENABLE;
dcbSerialParams.fAbortOnError = FALSE;
dcbSerialParams.fOutxCtsFlow = FALSE;
dcbSerialParams.fOutxDsrFlow = FALSE;
// setup baud rate
switch (baudrate_) {
#ifdef CBR_0