Read data from Serial Command

brianrpsgt1 brianlong at cox.net
Fri Oct 10 17:22:28 EDT 2008


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'

I have confirmed that the serial port is correct and open with the
s.isOpen() function.  Also able to successfully connect in
Hypterterminal with the same configuration settings.




Grant Edwards wrote:
> On 2008-10-10, brianrpsgt1 <brianlong at cox.net> wrote:
> > I am new to scripting.  I am trying to read the settings from a serial
> > device using Python.  I have been able to successfully connect to the
> > device and change baud rate settings, ect... with PySerial.  I am
> > trying to send a command to the serial device and capture the returned
> > info, however, it is not working.
>
> It works fine for me.
>
> I'm afraid you're going to have to be a bit more detailed than
> "it is not working".  Are we supposed to guess what it's doing
> and how that differs from what you want it to do?
>
> Do you have the serial cable plugged in?
>
> Is the device to which you're talking powered on?
>
> > Code is below:
> >
> > 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)
> >
> > print nw
> > s.close()
>
> --
> Grant Edwards                   grante             Yow! Well, I'm INVISIBLE
>                                   at               AGAIN ... I might as well
>                                visi.com            pay a visit to the LADIES
>                                                    ROOM ...



More information about the Python-list mailing list