Screen as Serial Terminal

At work we use minicom on our Linux workstations to connect to the serial port of our development hardware. It works fine, but it's very text oriented. It also loses everything in the window if you re-size it. I've sometimes wondered if there are better alternatives, and today someone on one of our internal forums gave me a nice list. Sadly I couldn't find any of the suggestions for our old Red Hat 8 development boxes, except screen.

I've used screen before and it's great. I had no idea it could do serial communication too. Here's the command I used for our environment:


screen /dev/ttyS0 115200,cs8,-ixon,-ixon,istrip

I also have this .screenrc file that someone gave me years ago:


# kill startup message
startup_message off

# define a bigger scrollback, default is 100 lines
defscrollback 1024

# remap CTRL-A to CTRL-]
escape ^]]

# status bar
hardstatus on
hardstatus alwayslastline "%{rk}%H %{gk}%c %{yk}%M%d %{wk}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{wk}%?%+Lw%?"

That gives you better key bindings and a nice colorful stats line at the bottom of the windows.

Advantages over minicom are, you can resize the window and you don't lose anything, you have screen's cool detached mode functionality, and there are a million other little nifty things that screen can do that you might find useful (man screen some rainy afternoon). You might be used to screen keybindings already too. A downside is, with minicom you can run it in an xterm with a scroll bar and use your wheelie mouse to scroll the buffer. That's handy. I can't get screen to do that.

UPDATE: You can scroll with your wheel mouse if you run screen in a recent version of gnome-terminal. See the comments on this entry.

UPDATE 2: There's another way to scroll screen output with your mouse that works exactly like minicom. See comment number 4 below.

Let me just say at this point that I should have already learned from emacs that when dealing with a UNIX program that has been in use since before I first touched a computer, never say that it can't do something, because it totally can.

Comments

piyo said…
Great post about GNU Screen. Obviously you know about the copy mode, because you have the defscrollback option there. I too would like to know how to use the mouse wheel with GNU Screen to activate copy mode.
l0st3d said…
In my ubuntu install, gnome terminal converts mouse wheel movements into arrow key presses, so in screen you can enter copy mode, and use the mouse wheel. It also works for less, and command history.
Bryan said…
Hey, my wheelie mouse *does* work with screen! Thanks for pointing that out. I think that maybe I didn't notice because the text doesn't move when you first start scrolling up, just the cursor. Thanks for pointing that out.
Anonymous said…
Put these in your .screenrc and you can use mouse wheel in xterm. So, please update the misinfo on the blog post.

# tell screen that you term can scroll
termcapinfo xterm ti@:te@
# bind Shift+PgUp/PgDn
bindkey -m "^[[5;2~" stuff ^b
bindkey -m "^[[6;2~" stuff ^f
Bryan said…
That's awesome! I will update the blog entry. Now, getting greedy, do you know of a way to do the same thing but with gnome-terminal instead of xterm? I tried changing the termcap line to gnome-terminal instead of xterm with no luck.
Bryan said…
Ignore my previous comment. It works with gnome-terminal too with just the xterm termcapinfo line. That rocks. Thanks, anonymous!

Popular posts from this blog

SystemVerilog Fork Disable "Gotchas"

'git revert' Is Not Equivalent To 'svn revert'

Git Rebase Explained