[python-uk] Pyserial on Raspberry Pi returning just "\x00" ie NULL characters

Stephen Emslie stephenemslie at gmail.com
Mon Jul 2 15:15:43 CEST 2012

I've found strace to be a really valuable tool in debugging arduino serial
communication. Not sure what your problem is, but perhaps inspecting the
serial connection like this could help:

    strace -e trace=read,open,write -p <process_id>

That should print out all read, write, and open calls from your process to
the operating system, which includes reads and writes on the connection to


On Mon, Jul 2, 2012 at 1:45 PM, Michael <sparks.m at gmail.com> wrote:

> Hi,
> Probably a little off topic, but posting here in the hope that someone
> else has tried connecting a Rasp Pi to an arduino using the arduino's
> built in usbserial device. (ie like you would with a "normal" linux
> box).
> Ignoring all the app details, if I have a piece of code that's like this:
> import serial
> ser = serial.Serial("/dev/ttyUSB0", 9600)
> while True:
>    print repr(ser.read())
> Then on a normal linux box, I'm getting back values I'd expect. On the
> raspberrypi, I'm simply getting back "\x00" characters.
> In my actual code, I'm both sending and receiving data. The curious
> oddity here is that I appear to be receiving the correct *number* of
> characters, and appear to also be sending the right number (based on
> the flashing of the RX light on the arduino).
> However, whilst they're the right number of characters, the actual
> characters, being NULLs, are clearly wrong.
> I'm guessing that this is actually nothing to do with python and more
> a driver issue on the Pi, but on the off chance it is a python issue
> or something someone else here has seen before I thought it worth
> posting and asking.
> If anyone's interested, the context of this is using and RFID tag
> reader (plugged into the Pi - which I have working to cause motors to
> spin on another device. The reason for the arduino here rather than
> faffing with the Pi's pins is a) it'd be faff with the Pi's pins b) I
> have an arduino with built in servo control circuits - essentially an
> Arduino duemilanove clone with a motor shield combined c) I had all
> the bits and really didn't expect serial connection to/from the Pi to
> be where I'd get issues!
> Any suggestions (good or bad :), comments or sympathy welcome :-)
> baffled-of-the-north,
> Michael.
> _______________________________________________
> python-uk mailing list
> python-uk at python.org
> http://mail.python.org/mailman/listinfo/python-uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-uk/attachments/20120702/43d9be28/attachment.html>

More information about the python-uk mailing list