mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 19:54:57 +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 {
|
typedef enum {
|
||||||
parity_none = 0,
|
parity_none = 0,
|
||||||
parity_odd = 1,
|
parity_odd = 1,
|
||||||
parity_even = 2
|
parity_even = 2,
|
||||||
|
parity_mark = 3,
|
||||||
|
parity_space = 4
|
||||||
} parity_t;
|
} parity_t;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@ -369,6 +369,11 @@ Serial::SerialImpl::reconfigurePort ()
|
|||||||
options.c_cflag |= (PARENB);
|
options.c_cflag |= (PARENB);
|
||||||
} else if (parity_ == parity_odd) {
|
} else if (parity_ == parity_odd) {
|
||||||
options.c_cflag |= (PARENB | PARODD);
|
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 {
|
} else {
|
||||||
throw invalid_argument ("invalid parity");
|
throw invalid_argument ("invalid parity");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -216,6 +216,10 @@ Serial::SerialImpl::reconfigurePort ()
|
|||||||
dcbSerialParams.Parity = EVENPARITY;
|
dcbSerialParams.Parity = EVENPARITY;
|
||||||
} else if (parity_ == parity_odd) {
|
} else if (parity_ == parity_odd) {
|
||||||
dcbSerialParams.Parity = ODDPARITY;
|
dcbSerialParams.Parity = ODDPARITY;
|
||||||
|
} else if (parity_ == parity_mark) {
|
||||||
|
dcbSerialParams.Parity = MARKPARITY;
|
||||||
|
} else if (parity_ == parity_space) {
|
||||||
|
dcbSerialParams.Parity = SPACEPARITY;
|
||||||
} else {
|
} else {
|
||||||
throw invalid_argument ("invalid parity");
|
throw invalid_argument ("invalid parity");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user