Read data from Serial Command

brianrpsgt1 brianlong at cox.net
Sat Oct 11 00:38:39 CEST 2008


Gave that a shot....  what is happening is that the script is
hanging.  Does that mean that the write function is not making it
through, thus there is nothing to return?



Grant Edwards wrote:
> 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