Read data from Serial Command

B

brianrpsgt1

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. 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()

Thanks

B
 
B

brianrpsgt1

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.
 
B

brianrpsgt1

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?
 
B

brianrpsgt1

Again, what is weird is that all works fine in Hyperterminal, but not
with the Python script.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top