I have an rs232 serial device and am trying to read and write with it using python with pyVISA. I can write my commands using "write", but I If I try to "read" or "ask", I will get a timeout error.
I can read and write for it easily through the term labview or tera, but I cannot read with python.
Here is the python code that doesn't work:
import visa as v
si = v.SerialInstrument("COM1", delay = 0.1)
si.clear()
si.timeout = 3
si.baud_rate = 9600
si.data_bits = 8
si.stop_bits = 1
command = '0'
while command != 'end':
rorw = raw_input('ask, read, or write? >>')
command = raw_input('enter command code >>')
if rorw == 'write':
write1 = si.write(command)
print write1
elif rorw == 'read':
read1 = si.read()
print read1
else:
ask1 = si.ask(command)
print ask
source
share