1
0
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:
achronop 2014-12-07 21:33:53 +02:00
parent c19a5a3cc9
commit b376f85fb0
3 changed files with 12 additions and 1 deletions

View File

@ -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;
/*!

View File

@ -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");
}

View File

@ -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");
}