From 5b8d1638610bd403d011477cd6bcf38fa55c7240 Mon Sep 17 00:00:00 2001 From: Joshua Shireman Date: Sun, 6 Aug 2017 14:57:33 -0400 Subject: [PATCH] fix(windows): Add option to disable RTS (#1277) * Add option to disable RTS on Windows * Add support for XON / XOFF on Windows. This is probably not feature complete in terms of missing the XonChar, XoffChar, XonLim fields of DCB, but I am not as familiar with this aspect of serial comms. BREAKING CHANGE: We previously hard coded to have RTS On for windows at all times. --- src/serialport_win.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/serialport_win.cpp b/src/serialport_win.cpp index f6be1d86b..9213bae60 100644 --- a/src/serialport_win.cpp +++ b/src/serialport_win.cpp @@ -89,11 +89,28 @@ void EIO_Open(uv_work_t* req) { dcb.Parity = NOPARITY; dcb.ByteSize = 8; dcb.StopBits = ONESTOPBIT; - dcb.fInX = FALSE; - dcb.fOutX = FALSE; + + dcb.fOutxDsrFlow = FALSE; dcb.fOutxCtsFlow = FALSE; - dcb.fRtsControl = RTS_CONTROL_ENABLE; + + if (data->xon) { + dcb.fOutX = TRUE; + } else { + dcb.fOutX = FALSE; + } + + if (data->xoff) { + dcb.fInX = TRUE; + } else { + dcb.fInX = FALSE; + } + + if (data->rtscts) { + dcb.fRtsControl = RTS_CONTROL_ENABLE; + } else { + dcb.fRtsControl = RTS_CONTROL_DISABLE; + } dcb.fBinary = true; dcb.BaudRate = data->baudRate;