Hi,<br>
<br>
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. <br>
<br>
I know that the baud rate is wrong, and the other settings (such as 8N1) are unknown to me and may also be wrong. <br>
<br>
<br>
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.<br>
<br>
#!/bin/python<br>
import pexpect<br>
import os<br>
import fdpexpect<br>
fd = os.open("/dev/ttyS0", os.O_RDWR|os.O_NONBLOCK|os.O_NOCTTY )<br>
m = fdpexpect.fdspawn(fd) # Note integer fd is used instead of usual string.<br>
m.send("+++") # Escape sequence<br>
m.send("ATZ0\r") # Reset modem to profile 0<br>
string1 = m.read(100)<br>
print "%s" % string1<br>
<br>
<br>
Would the baudrate setup be similiar under windows? Any examples out there?<br>
<br>
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.<br>
<br>
Thanks,<br>
Bryce<br>