VI_ERROR_TMO (-1073807339)

Mirza Grbic picture Mirza Grbic · Jul 19, 2016 · Viewed 7.7k times · Source

I'm using RS-232 port to communicate with KeithleyInstruments(SCPI Protocol) and have a problem.I can send the write command but when I send a query command it*s show the error below.

import visa
rm = visa.ResourceManager()
inst = rm.list_resources()
print inst
# print inst --> (u'USB0::0x05E6::0x2200::9060025::INSTR', u'ASRL1::INSTR', u'ASRL6::INSTR', u'ASRL7::INSTR', u'ASRL10::INSTR', u'GPIB0::16::INSTR')
keithleyInst= rm.open_resource('ASRL7::INSTR')
print keithleyInst.write("*rst")
print keithleyInst.write(":meas:temp?")
print keithleyInst.query(":meas:temp?")

Error:

pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

Answer

Jeanne Pindar picture Jeanne Pindar · Jul 19, 2016

A query is a write and a read combined, so you only need the query, not the write.

If it still times out after removing the extra write, try setting a really long timeout like:

keithleyInst.timeout = 5000

To give it 5 seconds to respond. You can always shorten this once you've got it working.

If it still doesn't respond, perhaps the instrument is not sending the termination character that VISA expects.

Try communicating with the instrument with a terminal program or National Instruments' Measurement & Automation program to find out for sure what termination character it is sending (if it is sending anything).

You can change the termination character VISA expects by

keithleyInst.read_termination = '\r'

or something similar.