USB Console adapter on Mac Book Pro

As some of you know, I recently jumped off the Windows band wagon and purchased a Mac Book Pro.  I like it, but it’s taking some getting used to.  Recently I wanted to use it to configure a Cisco device via console and realized I didn’t even know where to start.  For Macs being ‘really’ easy, it’s not super clear what happens when you plug in a device that the Mac doesn’t have a driver for.  So I turned to Google, below is what I came up with that seemed to work for me. 

Finding the right driver
This was actually the hardest part.  I’m sure we’ve all seen the very popular USB to COM adapter that looks like this…

image

While they may be branded under many names, I believe they are ,for the most part, all manufactured using Aten hardware.  Mine was the ‘UC-232A’ model.  After trying to get the driver right from Aten and having it not work, I did some googling and came across this site…

http://phaq.phunsites.net/2010/12/13/getting-aten-uc-232a-usb-to-serial-dongle-to-work-on-os-x-snow-leopard/

Apparently finding the right driver is a problem that others are having as well.  At any rate, this guy had a link to a set of drivers that worked for me…

http://phaq.phunsites.net/files/2010/12/osx-pl2303-0.4.1-failberg.pkg_.zip

Download those drivers to your Mac book and install.  Once I did that, I was able to see the device from the terminal…

image

You can see the first time I ran the command I didn’t have the device plugged in.  Once I plugged it in, the USB to COM adapter showed up as a valid TTY device (PL2303-00003014). 

Using the adapter for a terminal session
So now that you have the device installed, how do you actually connect to a a console device?  After more googling, I came across a terminal app called ‘Screen’.  The screen app is what I’ll be using as a terminal emulator to connect to the device console ports.  Once your adapter shows up, connecting is pretty straight forward…

image

All you do is pass the device to the screen app as a parameter and specify your the baud rate.  When you run that you should get kicked to a blank white screen.  Bang, bang the enter key a couple of times and you should be on your device…

image

To exit screen, press ‘CTRL – A’ followed by the letter ‘k’.  This will bring up a message at the bottom of the window that looks like this…

image

Hit ‘y’ and you’ll be dumped back out to the terminal.  Pretty simple right?  After using this for awhile, and not being careful about closing my sessions, I eventually ran into this error…

image

followed by…

image

Pretty obvious here that I forgot to actually close the session to the device.  But if you don’t know what you’re doing a *nix box, this can be frustrating.  Basically, this means that there’s still a copy of screen running that’s holding onto the device you are trying to use (the com adapter).  To fix this, run this series of commands…

 image

Here we run ‘ps’ to tell us about running processes.  From that output, we find the screen app, and then determine it’s process number (far left number).  Then we simply kill the process with the kill command.  Once you do that, you should be back in business!

Making a program out of it
During my googling, I found some people that had made a script to run the app based on some menu input.  This makes things slightly easier so I thought I’d give it a go.  Here’s what I came up with by hacing pieces of other peoples scripts together…

First thing to do is open the AppleScript editor.  This should open a new untitled project.  Paste this code into the window…

set serialDevices to (do shell script “ls /dev/tty.*”)
set theDeviceList to (paragraphs of serialDevices) as list
set theDevice to (choose from list theDeviceList)
set baudList to {1200, 2400, 4800, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
set baudRate to (choose from list baudList default items {9600})
tell application “Terminal”
do script “screen ” & theDevice & ” ” & baudRate
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

Should look something like this…

image

Then hit the ‘Compile’ button on the menu bar.  This will make it look pretty…

image

Next thing to do is to export the code as an application.  To do this, click on the ‘File’ menu option and select export…

image

On the export menu, give the script a name, and change the file format to ‘Application’.  This will allow you to launch the script as an app…

image

Once you save it, quit the AppleScript editor and double click on the application you just created, you should get a series of prompts that look like this…

image

image

After you pick your device and baud rate, you should see a terminal window launch.  Click on it and hit enter a couple of times…

image

All set!  Just a easier way to select the device you want to use as well as pick the baud rate.  Keep in mind that the same rules apply.  ‘CTRL-A’ plus ‘k’ to quit the session.  A nice free way to use my existing adapter on my Mac!

Leave a Reply

Your email address will not be published. Required fields are marked *