Monday, April 23, 2012

Screen Command: Set Baud Rate [ Terminal Communication ]

I need to do router or network switch configuration via a console port such as COM1 (ttyS0 under Linux). How do I use the screen command for a serial terminal emulator network with different baud rates under UNIX or Linux operating systems?

Screen command provides different window types. The first parameter to the screen command defines which type of window is created. If a tty name (e.g. "/dev/ttyS0") is specified as the first parameter to the screen command, then the window is directly connected to this device. An optional parameter is allowed consisting of a comma separated list of flags in the notation as follows:
 
screen /dev/ttySX baud_rate,cs8|cs7,ixon|-ixon,ixoff|-ixoff,istrip|-istrip
 
Where,
  • /dev/ttySX: Linux serial port (e.g., /dev/ttyS0 [COM1] )
  • baud_rate: Usually 300, 1200, 9600 or 19200. This affects transmission as well as receive speed.
  • cs8 or cs7: Specify the transmission of eight (or seven) bits per byte.
  • ixon or -ixon: Enables (or disables) software flow-control (CTRL-S/CTRL-Q) for sending data.
  • ixoff or -ixoff: Enables (or disables) software flow-control for receiving data.
  • istrip or -istrip: Clear (or keep) the eight bit in each received byte.
In this example, I'm connecting to my Soekris based embedded router using /dev/ttyS0 with 19200 baud rate and cs8:
$ screen /dev/ttyS0 19200,cs8
Sample outputs:
Fig.01: Screen command in action
Fig.01: Screen command in action

How Do I See My Serial Port Status and Info?

Simply type CTRL + A + i
Fig.02: Getting terminal info
Fig.02: Getting terminal info

How Do I Exit From the Screen Session?

To close the screen session after you finish the router / switch configuration, press CTRL + A + k. To kill all screen session press CTRL + A + \. See our quick screen command tutorial for more information.

No comments:

Post a Comment