pexpect baudrate and mode settings
bryce.bolton at gmail.com
Thu Sep 21 08:08:24 CEST 2006
I've written a short script in pexpect to open the serial port and get 100
bytes. The script does receive a string of garbage, but not the good text
seen when I open a minicom terminal and look at ttyS0.
I know that the baud rate is wrong, and the other settings (such as 8N1) are
unknown to me and may also be wrong.
Question: In Linux, how do I set the baud rate = 19200, 8N1 in pexpect
scenario? (this example is close to the pexpect documentation, but I used
the fdpexpect.fdspawn extension because pexpect.spawn didn't work.
fd = os.open("/dev/ttyS0", os.O_RDWR|os.O_NONBLOCK|os.O_NOCTTY )
m = fdpexpect.fdspawn(fd) # Note integer fd is used instead of usual string.
m.send("+++") # Escape sequence
m.send("ATZ0\r") # Reset modem to profile 0
string1 = m.read(100)
print "%s" % string1
Would the baudrate setup be similiar under windows? Any examples out there?
In short, setting of critical parameters is unclear under pexpect's
documentation, but may be obvious to those more familiar with os.open or
other filesystem internals.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list