mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-23 04:04:54 +08:00
Add MARK/SPACE parity bit option
This commit is contained in:
parent
c19a5a3cc9
commit
b376f85fb0
@ -66,7 +66,9 @@ typedef enum {
|
||||
typedef enum {
|
||||
parity_none = 0,
|
||||
parity_odd = 1,
|
||||
parity_even = 2
|
||||
parity_even = 2,
|
||||
parity_mark = 3,
|
||||
parity_space = 4
|
||||
} parity_t;
|
||||
|
||||
/*!
|
||||
|
||||
@ -369,6 +369,11 @@ Serial::SerialImpl::reconfigurePort ()
|
||||
options.c_cflag |= (PARENB);
|
||||
} else if (parity_ == parity_odd) {
|
||||
options.c_cflag |= (PARENB | PARODD);
|
||||
} else if (parity_ == parity_mark) {
|
||||
options.c_cflag |= (PARENB | CMSPAR | PARODD);
|
||||
} else if (parity_ == parity_space) {
|
||||
options.c_cflag |= (PARENB | CMSPAR);
|
||||
options.c_cflag &= (tcflag_t) ~(PARODD);
|
||||
} else {
|
||||
throw invalid_argument ("invalid parity");
|
||||
}
|
||||
|
||||
@ -216,6 +216,10 @@ Serial::SerialImpl::reconfigurePort ()
|
||||
dcbSerialParams.Parity = EVENPARITY;
|
||||
} else if (parity_ == parity_odd) {
|
||||
dcbSerialParams.Parity = ODDPARITY;
|
||||
} else if (parity_ == parity_mark) {
|
||||
dcbSerialParams.Parity = MARKPARITY;
|
||||
} else if (parity_ == parity_space) {
|
||||
dcbSerialParams.Parity = SPACEPARITY;
|
||||
} else {
|
||||
throw invalid_argument ("invalid parity");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user