I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /dev/tty.usbserial .

When i do this everything seems to be hunky-dory:

stty -f /dev/cu.usbserial
speed 9600 baud;
lflags: -icanon -isig -iexten -echo
iflags: -icrnl -ixon -ixany -imaxbel -brkint
oflags: -opost -onlcr -oxtabs
cflags: cs8 -parenb

Everything also works when I use the serial port tool to talk to it.

If I run this piece of code while the above mentioned serial port tool, everthing also works. But as soon as I disconnect the tool the connection gets lost.


import serial

ser = serial.Serial('/dev/cu.usbserial', 9600, timeout=10) 
ser.write("<ID01><PA> \r\n") 
read_chars =
print read_chars


So the question is, what magicks do I need to perform to start talking to the serial port without the serial port tool? Is that a permissions problem? Also, what's the difference between /dev/cu.usbserial and /dev/tty.usbserial?

+1  A: 

You don't happen to see any serial numbers after them do you? Such as:


My other through was maybe there is a permissions issue of python talking to the serial port. Do you know what user your python instance is running under? And maybe what roles it has?

Nick Berardi

I suppose in a C program you could just open the serial device with an open syscall and read() / write() to that. My Python-fu however is weak, and I don't know if this would transfer.


Nope, no serial numbers. The thing is, the problem persists even with sudo-running the python script, and the only thing that makes it go through if I open the connection in the gui tool that I mentioned.


have you tried watching the traffic between the GUI and the serial port to see if there is some kind of special command being sent across? Also just curious, Phython is sending ASCII and not UTF-8 or something else right? The reason I ask is because I noticed you quote changes for the strings and in some languages that actually is the difference between ASCII and UTF-8.

Nick Berardi
+3  A: 

/dev/cu.xxxxx is the "callout" device, it's what you use when you establish a connection to the serial device and start talking to it. /dev/tty.xxxxx is the "dialin" device, used for monitoring a port for incoming calls for e.g. a fax listener.

Kevin Ballard

Just last week I wrote a small Python utility to help me debug an embedded C app by reading debug information off a USB-Serial dongle, so I'd like to think that I understand PySerial pretty well. Some additional information might help diagnose the problem:

  • What USB-Serial driver are you using?
  • Are you certain that you've configured all of the serial options (baud rate, flow control, parity, stop bits, etc.) correctly before attemtping to open the serial connection from Python?
  • What version of PySerial are you using?