How can I set the parity bits when using screen to access a serial port

Long story short, it looks as if screen doesn't support setting those flags. The alternative would be to run stty to set the flags while screen is connected to the port, as you've done. Alternately, you could run kermit or another terminal emulator program inside a conventional screen command-line session, instead of having screen connect directly to the serial port.

The screen source code is at http://git.savannah.gnu.org/cgit/screen.git. It looks like the file of interest is tty.sh. This is shell script which runs during the build process to produce "tty.c". tty.c contains the code for accessing serial ports.

The function SttyMode() appears to be what parses the tty options and sets the tty mode. It appears to me that it handles a small, fixed set of options. "parenb" and "parodd" aren't among them.

It looks like it'd be straightforward for a developer experienced with C to add support for these options, if that's an option for you.


Try sudo screen /dev/ttyUSB2 115200,cs8,parenb,-parodd,-cstopb

From the man page for stty:

  • csN - set character size to N bits, N in [5..8]
  • [-]parenb - generate parity bit in output and expect parity bit in input
  • [-]parodd - set odd parity (even with '-')
  • [-]cstopb - use two stop bits per character (one with '-')