Skip to content
This repository was archived by the owner on Oct 5, 2021. It is now read-only.

Commit 6aceebf

Browse files
mwmfpistm
authored andcommitted
Fix file open to actually turn on inbound parity checking.
The INPCK bit is an i_flag bit, not a c_flag bit as originally done here. I have no idea what setting INPCK in c_flag does on Linux, but on FreeBSD it caused the test of the c_values after they were set to fail. This fixes that, and presumably the serial interface will now actually check the parity of incoming data. Signed-off-by: Mike Meyer <[email protected]>
1 parent 1791dba commit 6aceebf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

serial_posix.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ static port_err_t serial_setup(serial_t *h, const serial_baud_t baud,
128128

129129
switch (parity) {
130130
case SERIAL_PARITY_NONE: port_parity = 0; break;
131-
case SERIAL_PARITY_EVEN: port_parity = INPCK | PARENB; break;
132-
case SERIAL_PARITY_ODD: port_parity = INPCK | PARENB | PARODD; break;
131+
case SERIAL_PARITY_EVEN: port_parity = PARENB; break;
132+
case SERIAL_PARITY_ODD: port_parity = PARENB | PARODD; break;
133133

134134
default:
135135
return PORT_ERR_UNKNOWN;
@@ -149,6 +149,9 @@ static port_err_t serial_setup(serial_t *h, const serial_baud_t baud,
149149
#else /* __sun */
150150
h->newtio.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR
151151
| IGNCR | ICRNL | IXON);
152+
if (port_parity)
153+
h->newtio.c_iflag |= INPCK;
154+
152155
h->newtio.c_oflag &= ~OPOST;
153156
h->newtio.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
154157
h->newtio.c_cflag &= ~(CSIZE | PARENB);

0 commit comments

Comments
 (0)