Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,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 5.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[63,967 views]  

Use 'screen' as a serial terminal emulator | 20 comments | Create New Account
Click here to return to the 'Use 'screen' as a serial terminal emulator' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Use 'screen' as a serial terminal emulator
Authored by: adrianm on Tue, Nov 14 2006 at 7:50AM PST
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 Tue, Nov 14 2006 at 4:00PM PST
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 Tue, Nov 14 2006 at 8:14AM PST
Or just use QuickTerm

[ Reply to This | # ]
Working with QuickTerm ?
Authored by: loup_blanc on Sat, Apr 21 2007 at 6:58AM PDT
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: bboy on Tue, Nov 14 2006 at 8:29AM PST
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: bboy on Tue, Nov 14 2006 at 9:17AM PST
"Shell" out. See what I did there? Heh - oh dear.

[ Reply to This | # ]
Use 'screen' as a serial terminal emulator
Authored by: wallybear on Tue, Nov 14 2006 at 8:58AM PST
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 Wed, Nov 15 2006 at 7:41PM PST
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 Tue, Nov 14 2006 at 4:14PM PST

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 Wed, Nov 15 2006 at 12:25PM PST
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 Tue, Nov 14 2006 at 4:28PM PST
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 Tue, Nov 14 2006 at 10:21PM PST
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 Tue, Nov 14 2006 at 5:16PM PST
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 Wed, Nov 15 2006 at 8:14AM PST
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 Wed, Nov 15 2006 at 9:10AM PST
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 Sun, Mar 18 2007 at 5:53PM PDT
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



[ Reply to This | # ]

Use 'screen' as a serial terminal emulator
Authored by: wcontello on Mon, Mar 19 2007 at 9:55AM PDT
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 Mon, Mar 19 2007 at 6:03PM PDT
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 Thu, Feb 26 2009 at 10:37AM PST
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 Sun, Jul 26 2009 at 11:38AM PDT
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 | # ]