ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-tutor
python-tutor
[Tutor] Raw Bits! (Control characters ahoy!)
by Doug Shawhan other posts by this author
Apr 17 2006 2:43PM messages near this date
Re: [Tutor] Python programmer needs to learn Java | Re: [Tutor] Raw Bits! (Control characters ahoy!)
I am in the middle of a project that requires me to send and retrieve
information from a machine connected to a serial port. My problems are
these:

1. I cannot send control characters
2. I cannot read data streaming from the serial port


I have been doing fine with:

os.system("echo '5' > /dev/tty00")
os.system("echo '8' > /dev/tty00")


and the like to the remote machine, but I need to be able to send control
characters the same way to scroll through menus. I have tried pyserial and
pexpect with mixed (mostly horrible) results (not the fault of the module
builders!), thus far the simple act of echoing the strings to the serial
port is the only reliable method I have found.

Reading from the serial port has also been problematic. I find that simply
opening the port /dev/tty00 file and using readlines(), read() or whatever
gives me empty strings or lists. Pbth.

So first: how should I go about adding the hex escape sequences (\x0a and
\x50) to the above strings in their raw form?
second: what method should I use to read a raw stream from the serial port
for a given period?

I have looked carefully at the neat and tidy miniterm.py example in the
pyserial examples directory, and see how one can continuously read via a
thread from the port, but have not been able to replicate it thus far.

Any help whatsoever would be great! I'm beginning to feel a little
lightheaded. Thanks!
Thread:
Doug Shawhan
Hugo González Monteverde
Alan Gauld

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved