Read data from Serial Command
Grant Edwards
grante at visi.com
Fri Oct 10 17:57:24 EDT 2008
On 2008-10-10, brianrpsgt1 <brianlong at cox.net> wrote:
> Thanks for the message
>
> What exactly is happening is that the return is "None" for the command
> that I am sending. If I connect through Hyperterminal and execute the
> 'sh nw enc' command, it returns 'WEP'
It looks to me like you're never reading from the serial port.
All you're calling is write().
Also, are you sure that the device doesn't expect commands to
be termined by carriage returns?
>> > import serial
>> > import time
>> >
>> > s = serial.Serial(port=1, timeout=None, baudrate=9600)
>> > print s
>> > time.sleep(5)
>> > print "Enter CFG"
>> > s.write('CFG')
>> > print "Change baud"
>> > s.baudrate=115200
>> > print s
>> > time.sleep(5)
>> > print "New line"
>> > s.write('\n')
>> >
>> >
>> > time.sleep(2)
>> > print "Show Encryption Setting"
>> > nw = s.write('sh nw enc')
>> > time.sleep(1)
Try changing that to
s.write('sh nw enc')
time.sleep(1)
nw = s.read(1024)
>> > print nw
>> > s.close()
There are plenty of example programs at:
http://pyserial.svn.sourceforge.net/viewvc/pyserial/trunk/pyserial/examples/
--
Grant Edwards grante Yow!
at BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-BI-
visi.com
More information about the Python-list
mailing list