Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use 'screen' as a serial terminal emulator Network
I often have to do router configuration via a console port, so I use a Keyspan Serial Adapter to get access. Two problems then present themselves:
  1. ZTerm is a horrible Mac OS X app. It hasn't been updated in five years or so, and isn't a Universal Binary. The developer doesn't seem in any hurry to rectify the situation. It is not worth the shareware fee in its current form.
  2. Minicom requires installation of Fink or MacPorts and is overly complex.
Solution: Use screen, Terminal, and a little AppleScripting.

First, launch Script Editor and type/paste in the following code:
tell application "Terminal"
  do script with command "screen /dev/tty.KeySerial1"
  set number of rows of window 1 to 100
  set number of columns of window 1 to 80
  set background color of window 1 to "black"
  set normal text color of window 1 to "green"
  set custom title of window 1 to "SerialOut"
end tell
Compile and save as an app from within Script Editor, and you have a double-clickable application to launch a serial Terminal session. You may want to customize this slightly -- you can change the screen colors or number of columns or rows. You may also need to customize the screen command with a different device name if you are using something other than the Keyspan Serial Adapter (do an ls tty* of the /dev/ directory to get the right name).

screen uses Control-A to take commands directed to it. So type Control-A followed by Control-\ to exit your screen session. If you fail to do this and exit a Terminal session, you'll leave the screen session alive and the serial resource unavailable until you kill the screen session manually. man screen will show you further commands to send to a screen session.

If anyone can reply with a link to a tutorial on how to wrap an interactive Unix App in Cocoa, that would be the next step -- it would be nice to do this without involving Terminal. If you prefer to use Minicom, you could still use the AppleScript to wrap it into a nice launchable app -- use this older hint to find the right command line commands.
    •    
  • Currently 3.90 / 5
  You rated: 2 / 5 (10 votes cast)
 
[190,439 views]  

Use 'screen' as a serial terminal emulator | 29 comments | Create New Account
Click here to return to the 'Use 'screen' as a serial terminal emulator' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use 'screen' as a serial terminal emulator
Authored by: adrianm on Nov 14, '06 07:50:07AM

Can you not just save all that as terminal profile and then double click it, or select it from the Terminal dock menu? No applescript involved.

---
~/.sig: not found



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: isometry on Nov 14, '06 04:00:45PM
I use the following keyspan.term (string-style plist for readability):

{
    WindowSettings = (
        {
            Columns = 80; 
            CustomTitle = KeySpan1; 
            Rows = 25; 
            SaveLines = "-1"; 
            Shell = "screen -T vt100 /dev/tty.KeySerial1 9600"; 
            ShellExitAction = 1; 
            TermCapString = "xterm-color"; 
            VisualBell = YES; 
            WindowCloseAction = 1; 
        }
    ); 
}
Note that you can control the terminal baud rate and other characteristics with the last argument (see the WINDOW TYPES section of screen(1)).

[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: jcbeckman on Nov 14, '06 08:14:00AM
Or just use QuickTerm

[ Reply to This | # ]
Working with QuickTerm ?
Authored by: loup_blanc on Apr 21, '07 06:58:25AM

Hello

I am not a programmer. What shall I do when I've setted the port of QuickTerm, and came back to the window "RS-232 Terminal".
I clicked on "Connect". It probably connected but the window is empty, I cannot type anything in it, and anyway I don't know what to type.

I want to use it for our French "minitel". I think it is V33, but not sure.

I use a laptop and MacOs 10.4.9.
My modem is inside :
Modele : MicroDash
Type d'interface : USB
Modulation : V.92
Nom de serie : Euro
Version Matériel : 1.0F
Version du programme interne : APPLE VERSION 2.6.6
Gestionnaire : InternalUSBModem.kext (v2.6.6)
Pays : 3D (France)

Is X11 necessary ? I am not keen on the terminal, so could you give basic explanations.

Thank you.



[ Reply to This | # ]
Cheap alternative to Keyspan
Authored by: Anonymous on Nov 14, '06 08:29:25AM
No need to shell out for Keyspan's admittedly very good drivers. Many USB-serial adapters use the same chip, Prolific Industries' PL-2303 controller. Prolific's own Mac OS X driver is currently not very good; you can't send a break signal via screen in Terminal, for example. However, there's an open-source driver that works better.

I use this with an unbranded PL-2303-equipped adapter bought from eBay for six of our English pounds, compared to thirty-odd for a Keyspan device, and it talks perfectly to my Cisco routers. I haven't tried talking to PDAs or GPS devices though.

[ Reply to This | # ]

Cheap alternative to Keyspan
Authored by: Anonymous on Nov 14, '06 09:17:50AM

"Shell" out. See what I did there? Heh - oh dear.



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: wallybear on Nov 14, '06 08:58:26AM
You can also use C-Kermit 8.0. Unfortunately a binary is not available, we must compile it by ourselves, but it's really easy, as Mac OS X is supported.

Download the source at the following address:

ftp://kermit.columbia.edu/kermit/archives/cku211.zip

Copy it in a folder, then, using terminal:

% cd <the folder you copied it in>
% unzip -a cku211.zip
% make macosx103
% sudo make install

it will compile and install Kermit in the folder /usr/local/bin/kermit; the binary is called wermit.

It's ready! to launch it:
% /usr/local/bin/kermit/wermit

and here it is:

C-Kermit 8.0.211, 10 Apr 2004, for Mac OS X 10.3
Copyright (C) 1985, 2004,
Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/Users/wallybear/) C-Kermit>

Compiling from source give also the chance to tweak compiler settings so to make a PPC, Intel or Universal binary application.

[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: xcgr on Nov 15, '06 07:41:40PM
I last used C-Kermit when Jaguar was out. It worked great. PowerPC binaries for 10.3 and earlier can be found here: http://www.columbia.edu/kermit/ck80binaries.html#apple

[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: quentinsf on Nov 14, '06 04:14:58PM

Wow! Kermit - I haven't used that for at least a decade, but I seem to remember that it was very good... must give it a try...

Anyway, that aside, for those who like minicom, Jeffrey Frey has done a Mac port which can be found at the bottome of his page here:

http://turin.nss.udel.edu/programming/



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: cynikal on Nov 15, '06 12:25:32PM

also the awesome thing about kermit which i've been using recently for a few years is that it lets you send files via xmodem (useful when ur cisco gear pukes on itself), and also kermit is scriptable (useful when you have 50+ apc power strips you have to configure the same way, enter non-interactive script).



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: mtimmsj on Nov 14, '06 04:28:36PM

I'm not saying I'd recommend it, but you could also use tip, 'man tip' for more info.



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: mayo2ca on Nov 14, '06 10:21:24PM

osx unfortunately doesn't come with tip .. i was disappointed quite a bit when I found out



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: cyflea on Nov 14, '06 05:16:10PM
There are quite a few installer packages for minicom that remove the need for fink or darwin(er. mac)ports.

one's at http://turin.nss.udel.edu/programming/



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: plima on Nov 15, '06 08:14:05AM

This is an excellent solution (I've been a regular, frustrated, user of ZTERM). I am, however, unable to configure the serial port settings (I routinely connect to a serial device running 38400/n/8/1) I've tried every combination I can imagine with stty to set the port before starting screen and it is still always stuck at 9600 baud.



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: plima on Nov 15, '06 09:10:23AM

Update: I found on Apple's discussions board the following, which works:

screen -U /dev/tty.KeySerial1 38400

Adjust the script accordingly and it works perfectly!



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: wcontello on Mar 18, '07 05:53:58PM
Here is an addition I made to select the serial port and the baud rate:

set baudList to {1200, 2400, 4800, 4800, 9600, 19200, 38400, 57600, 115200, 230400}

set baudRate to (choose from list baudList default items {38400})

tell application "Terminal"

set serialDevices to (do shell script "ls /dev/cu*")

set theDeviceList to (paragraphs of serialDevices) as list

set theDevice to (choose from list theDeviceList)

do script "screen " & theDevice & " " & baudRate

display dialog "To quit you terminal session type then "

end tell

Edited on Jun 05, '10 09:40:56AM by crarko


[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: wcontello on Mar 19, '07 09:55:03AM

the second to last line should have been:
display dialog "To quit you terminal session type <ctrl-a> then <ctrl-\\>"



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: wcontello on Mar 19, '07 06:03:46PM
The second to last should have read:

    display dialog "To quit you terminal session type then "


[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: erictbar on Feb 26, '09 10:37:49AM

thanks for all your help, especially bboy for the cheaper cable, and wcontello for the AppleScript.

I am currently taking 2 classes that use HyperTerminal, a Cisco test prep class and a basic Telecommunications classes. I've wanted to use my MacBook Pro to use something HyperTerminal related. I have a beta of Windows 7 in Boot Camp and VMWare, and MS got rid of HyperTerminal in Vista. And of course no Mac (except for Xserves) have a serial port.

---
Startup Shortcuts - Shortcuts for debugging your Mac on startup, on your iPhone
http://web.me.com/maxeverde/Startup



[ Reply to This | # ]
Re: Use 'screen'... - now how can I kill it?
Authored by: LABear on Jul 26, '09 11:38:12AM

You wrote: "type Control-A followed by Control-\ to exit your screen session. If you fail to do this and exit a Terminal session, you'll leave the screen session alive and the serial resource unavailable until you kill the screen session manually."

OK, I boo-booed. Now how can I kill the screen session manually?

(I wish I knew Unix better.)

--Gil



[ Reply to This | # ]
Re: Use 'screen'... - now how can I kill it?
Authored by: KYPackrat on Feb 11, '10 12:27:55PM
Look for a process called "SCREEN" using ps. Here's the output of my Terminal:

packrat@laptop% ps auxww | grep -i screen
packrat    327   0.0  0.0  2435108    548   ??  Ss    3:22PM   0:00.01 SCREEN
packrat    326   0.0  0.0  2435108    560 s000  S+    3:22PM   0:00.01 screen
packrat    343   0.0  0.0  2435032    528 s002  S+    3:22PM   0:00.00 grep -i screen
packrat@laptop%

Kill the process associated with SCREEN (i.e. "kill -TERM 327"), and the SCREEN will go away.

You can also reattach to a detached screen by running "screen -rD".

[ Reply to This | # ]

Use 'screen' as a serial terminal emulator
Authored by: Nicholaz on Feb 10, '10 05:06:32AM
Another solution would be using the ZOC Terminal application. I used zterm initially and found it horrible too. ZOC is a lot more modern in every regard and works with a serial/usb adapter.

[ Reply to This | # ]
Preventing screen from entering the background
Authored by: KYPackrat on Feb 11, '10 12:23:32PM

If you want to use screen as an terminal, but don't want it to go into the background when the window dies, you will need to turn off auto-detach.

To do this, edit ~/.screenrc (it probably won't exist) and add the following line:

autodetach off

The next time you start screen, if you kill the window you will kill the session.



[ Reply to This | # ]
So complicated.
Authored by: sudogeek on Apr 13, '10 08:30:56AM

How about simply "cu -l /dev/whatever -s 19200" and that's all it takes.



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: jocamero on May 12, '10 09:45:44PM

Thanks! Working great w/an IOGEAR GU232A USB to Serial adapter which uses the PL2303 chip set.



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: papanugget on Jun 04, '10 12:57:52PM

This is a fantastic thread. Saved me from using Zterm. One problem though. I'd like to be able to scroll up past the top to show more than one page of data. Anyone figure out a way to do that?



[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: papanugget on Jun 05, '10 06:38:24AM
Never mind. A little googling found the answer I was looking for. To turn on the scrollback buffer for SCREEN you have to add one more line to ~/.screenrc
termcapinfo xterm* ti@:te@
More info here: http://stackoverflow.com/questions/1039442/mac-os-x-terminal-apps-buffer-and-screen-command
Edited on Jun 05, '10 06:39:15AM by papanugget


[ Reply to This | # ]
FYI
Authored by: tedw on Jun 05, '10 08:04:34AM

since people are still posting to this 4 year old thread, I think it's useful to point out that iTerm - http://iterm.sourceforge.net/ - is a cocoa terminal editor that is up to date and under continued development (and that's not to mention the Terminal application packaged with os X).



[ Reply to This | # ]
A better replacement
Authored by: watski on Jan 03, '11 05:03:50AM

I found Furrysoft's goSerial rather nice for my AVR hacking projects:

http://www.furrysoft.de/?page=goserial



[ Reply to This | # ]