mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-23 04:04:54 +08:00
Fixes to flowcontrol that solve a wierd bug on Linux and fix an oversight on Windows.
This commit is contained in:
parent
95790064d8
commit
2ae490b3ac
@ -83,7 +83,8 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
flowcontrol_none = 0,
|
flowcontrol_none = 0,
|
||||||
flowcontrol_software
|
flowcontrol_software,
|
||||||
|
flowcontrol_hardware
|
||||||
} flowcontrol_t;
|
} flowcontrol_t;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@ -49,7 +49,7 @@ Serial::SerialImpl::SerialImpl (const string &port, unsigned long baudrate,
|
|||||||
bytesize_t bytesize,
|
bytesize_t bytesize,
|
||||||
parity_t parity, stopbits_t stopbits,
|
parity_t parity, stopbits_t stopbits,
|
||||||
flowcontrol_t flowcontrol)
|
flowcontrol_t flowcontrol)
|
||||||
: port_ (port), fd_ (-1), is_open_ (false), xonxoff_ (true), rtscts_ (false),
|
: port_ (port), fd_ (-1), is_open_ (false), xonxoff_ (false), rtscts_ (false),
|
||||||
baudrate_ (baudrate), parity_ (parity),
|
baudrate_ (baudrate), parity_ (parity),
|
||||||
bytesize_ (bytesize), stopbits_ (stopbits), flowcontrol_ (flowcontrol)
|
bytesize_ (bytesize), stopbits_ (stopbits), flowcontrol_ (flowcontrol)
|
||||||
{
|
{
|
||||||
@ -282,6 +282,18 @@ Serial::SerialImpl::reconfigurePort ()
|
|||||||
throw invalid_argument ("invalid parity");
|
throw invalid_argument ("invalid parity");
|
||||||
}
|
}
|
||||||
// setup flow control
|
// setup flow control
|
||||||
|
if (flowcontrol_ == flowcontrol_none) {
|
||||||
|
xonxoff_ = false;
|
||||||
|
rtscts_ = false;
|
||||||
|
}
|
||||||
|
if (flowcontrol_ == flowcontrol_software) {
|
||||||
|
xonxoff_ = true;
|
||||||
|
rtscts_ = false;
|
||||||
|
}
|
||||||
|
if (flowcontrol_ == flowcontrol_hardware) {
|
||||||
|
xonxoff_ = false;
|
||||||
|
rtscts_ = true;
|
||||||
|
}
|
||||||
// xonxoff
|
// xonxoff
|
||||||
#ifdef IXANY
|
#ifdef IXANY
|
||||||
if (xonxoff_)
|
if (xonxoff_)
|
||||||
|
|||||||
@ -213,6 +213,26 @@ Serial::SerialImpl::reconfigurePort ()
|
|||||||
throw invalid_argument ("invalid parity");
|
throw invalid_argument ("invalid parity");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setup flowcontrol
|
||||||
|
if (flowcontrol_ == flowcontrol_none) {
|
||||||
|
dcbSerialParams.fOutxCtsFlow = false;
|
||||||
|
dcbSerialParams.fRtsControl = 0x00;
|
||||||
|
dcbSerialParams.fOutX = false;
|
||||||
|
dcbSerialParams.fInX = false;
|
||||||
|
}
|
||||||
|
if (flowcontrol_ == flowcontrol_software) {
|
||||||
|
dcbSerialParams.fOutxCtsFlow = false;
|
||||||
|
dcbSerialParams.fRtsControl = 0x00;
|
||||||
|
dcbSerialParams.fOutX = true;
|
||||||
|
dcbSerialParams.fInX = true;
|
||||||
|
}
|
||||||
|
if (flowcontrol_ == flowcontrol_hardware) {
|
||||||
|
dcbSerialParams.fOutxCtsFlow = true;
|
||||||
|
dcbSerialParams.fRtsControl = 0x03;
|
||||||
|
dcbSerialParams.fOutX = false;
|
||||||
|
dcbSerialParams.fInX = false;
|
||||||
|
}
|
||||||
|
|
||||||
// activate settings
|
// activate settings
|
||||||
if(!SetCommState(fd_, &dcbSerialParams)){
|
if(!SetCommState(fd_, &dcbSerialParams)){
|
||||||
THROW (IOException, "Error setting serial port settings.");
|
THROW (IOException, "Error setting serial port settings.");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user