Multiplex different TTYs with a single instance of screen

gnu-screenserial portterminalterminal-multiplexertty

I use screen to connect to devices via RS232 with a USB-serial dongle. Currently, I use this command to invoke screen (where 115200 is my baud-rate):

screen /dev/ttyUSB0 115200

Usually, I have more than one device (/dev/ttyUSB0 and /dev/ttyUSB1). Sometimes their baud-rate differs. Currently, I open a new terminal emulator and run screen for each instance, but that kind of defeats the purpose of screen. Can I access both devices in a single instance of screen?

I'm thinking this would involve launching screen with no arguments and then attaching the session to a TTY with a specified baud-rate after it is created, but I don't see a command to change TTYs within a session. I know tmux can do that, but I'd rather stick with screen.

Best Answer

Once you've launched screen, you can use its internal screen command to attach windows to additional terminal devices. Type C-a: to get the prompt, then use

screen /dev/ttyUSB1 ######

where ###### is this device's baud-rate. You can also put these commands in your .screenrc to attach the devices automatically when you start screen, or you could bind a keystroke to this command to get a shortcut.

See the Window Types section of the screen manual.

Related Question