Tuesday, February 9, 2010

Serial Console on OSX

April 13, 2008 by Greg Ferro · 9 Comments 

Serial Communication in OSX Terminal

I knew it had to be possible to view serial data in the OSX terminal window. Finally, a little googling told me what I needed to know. Here’s how to read and send serial data from the terminal in OSX. (just like hyperterminal on windows)

I bought a USB Serial port that had MAC drivers. Check before you buy it that it has drivers. Not all USB Serial have MAC support. I assume that you have installed the correct drivers from here.

First, open Terminal (Applications/Utilities/Terminal). Next, type

ls /dev/tty.*

to get a list of your serial lines. Pick the one that you want to open. For example, my list looks like this:

gf:dev gf$ ls -al tty.*
crw-rw-rw- 1 root wheel 18, 4 Jan 25 07:32 tty.Bluetooth-Modem
crw-rw-rw- 1 root wheel 18, 8 Jan 25 07:32 tty.Bluetooth-PDA-Sync
crw-rw-rw- 1 root wheel 18, 10 Jan 25 09:20 tty.PL2303-0000103D
crw-rw-rw- 1 root wheel 18, 0 Jan 25 07:32 tty.SerialPort-1
gf:dev gf$

And I know /dev/tty.PL2303-0000103D is the USB-to-serial adaptor becuase it’s connected, if you unplug it the tty.PL2303-0000103D stops being listed.

Knowing the serial port, you can just type screen portname datarate to show the serial data on the screen. In my case, it was:

screen /dev/tty.PL2303-0000103D 9600

To quit the screen app, type control-A, then control-\.

Postscript

I don’t think that this is very complete, but it worked for me and might help you to get your USB serial working. Please let me know if there anything I can add to complete this piece.

Update 2008/12/28: A reader has pointed out this article is based on a similar article at http://www.tigoe.net/pcomp/resources/archives/avr/000749.shtml. I must have copied some of the text and then mistakenly believed it was my own. Apologies for this mistake.

Please rate this post:

  Why Rate Posts?
1 Star - It\\\'s Crud2 Stars - It\\\'s Tosh3 Stars - Something\\\'s missing4 Stars - Needs works5 Stars - Good Enough6 Stars - Good7 Stars - Excellent8 Stars - Brilliant9 Stars - Astonishing10 Stars - Awesomely Godlike? (No Ratings Yet)
Loading ... Loading ...

Comments

9 Responses to “Serial Console on OSX”
  1. Brandon says:

    I bought the keyspan serial adapter and it had a CD with MAC drivers. Installed it, plugged in the keyspan to a switch and fired up Zterm. Zterm gave me a drop down of options on how to connect. Key was one of the options. I chose it and was connected. I too stumbled around for a few days before i got it working.

    Brandon

  2. Greg Ferro says:

    I am sure that some people know how to do this, but for me, I had to work at it a little bit. There are some days when I just wish my first job was with *nix, my life would have been much simpler.

  3. John says:

    Note that the short form of “Macintosh” is not a TLA.

    • Greg Ferro says:

      It would seem that I owe an apology as I must have taken at least some part of this article from http://www.tigoe.net/pcomp/resources/archives/avr/000749.shtml.

      If I try to remember I think I found a few references around the internet and had some notes that I had captured. I use a text editor and will cut/paste these notes. I must have forgotten or missed recording where I found those notes and when I later read the notes figured I must have written it – the author has the same tone as I do.

      I have made a note in main article referencing the original post. Thanks for pointing it out, it wasn’t deliberate.

  4. Gary Smith says:

    The PL2303 chipset based units are reasonably well supported under OSX since 10.4 now, and most USB serial leads are PL2303 based. There’s drivers available from Prolific, the manufacturers of the chipset and also an open source available through Sourceforge. However, there still seems to be an ongoing issue with sending breaks through the cable in that they get, er, broken. But otherwise, if you’re looking for a cable then try to ensure it’s PL2303 based.

    Cheers,

    Gary Smith

  5. gok says:

    Using this, how could we send a break?, any key combination?

Trackbacks

Check out what others are saying about this post...
  1. [...] tip: Serial Communication in OSX Terminal; Serial Com­mu­nic­a­tion in OSX Terminal; Openmoko USB serial with screen. Tagged with: mac leave a comment « Little [...]



Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!