Skip to content

Commit fa52f4d

Browse files
Wer-WolfCalcProgrammer1
authored andcommitted
Disable input and output processing on Unix serial ports
Disabling output processing is necessary since otherwise sending a LF character (ASCII 0x0A) will automatically insert a CR character (ASCII 0x0D). Disabling input processing should prevent this when receiving data.
1 parent 0279aaf commit fa52f4d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

serial_port/serial_port.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,13 @@ bool serial_port::serial_open()
318318
options.c_lflag &= ~ECHOE; // Disable erasure
319319
options.c_lflag &= ~ECHONL; // Disable new-line echo
320320
options.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP
321+
options.c_lflag &= ~IEXTEN; // Disable input processing
321322

322323
options.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl
323324
options.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); // Disable any special handling of received bytes
324325

326+
options.c_oflag &= ~OPOST; // Disable output processing;
327+
325328
/*-----------------------------------------*\
326329
| Set the port configuration options |
327330
\*-----------------------------------------*/
@@ -420,7 +423,7 @@ bool serial_port::serial_open()
420423
/*-----------------------------------------*\
421424
| Configure additional parameters |
422425
\*-----------------------------------------*/
423-
options.c_lflag &= ~(ICANON | ISIG | ECHO);
426+
options.c_lflag &= ~(ICANON | IEXTEN | ISIG | ECHO);
424427

425428
options.c_iflag &= ~(INLCR | ICRNL);
426429
options.c_iflag |= IGNPAR | IGNBRK;

0 commit comments

Comments
 (0)