Talking to a usb device (serial terminal)

blaine frikker at gmail.com
Mon Mar 3 10:39:41 EST 2008


Hey everyone,
  We have a usb spectrometer device that we have finally got working
in linux (we were provided linux only drivers).  The device has a
Silicon Instruments cp2101 serial-to-usb chip onboard, and we loaded
the kernel module cp2101.c after taking the device apart to see what
was on the inside.  Using minicom we are able to set a baud rate and
open up a terminal when pointing to the device /dev/ttyusb0 (I
think).  Anyway, I want to be able to talk to our cool device using
python.  I haven't been able to find many resources specifically in
this area, but there are a few package that are vaguely mentioned,
including fcntl and termios.  But the web doesn't seem to have a lot
of documentation on fcntl, particularly information thats from the
past 8 years.

So my question is this - what is the easiest way to interface to this
"serial" device?

I don't imagine a straight read() and write() command to /dev/ttyusb0
is the most efficient (if it even works) especially since we would
need to set a baud rate.  My experience with terminal communication is
pretty limited.

Any advice that can be offered would be awesome. Thanks!
PS: The device that we will be using python on will be an embedded ARM
system.  Currently we are testing using a linux laptop and cross
compiling the kernel over to the embedded device.  The device has
Python 2.4, and does have both the termios and fcntl packages
available.

Python 2.4.2 (#1, Feb 20 2008, 11:07:36)
[GCC 4.1.1] on linux2

uname -a:
Linux gumstix 2.6.21gum #1 Wed Feb 20 02:53:01 EST 2008 armv5tel
unknown

Blaine Booher
University of Cincinnati




More information about the Python-list mailing list