I'm using PyVISA on python 2.7 to read a 34465A DMM over TCP. I am able to execute an "*IDN?" query and it returns the correct value, however the "READ?" query simply returns u'\n'. I've tried several variations including using '' vs "", as well as having preceding ':', using "MEAS:..."; no luck. Here is an example of my code:
import visa
import time
rm = visa.ResourceManager()
resources = rm.list_resources()
print "Available resources:"
print resources
print "Getting instrument..."
my_inst = rm.open_resource(resources[1]) # The device is always at [1]
start = time.time()
worked = True
command = "MEAS:VOLT:DC?" # Doesn't work
#command = "READ?" # Doesn't work
try:
print "Got instrument, getting *IDN?..."
print my_inst.query('*IDN?') # Prints correct value
print "Got *IDN?, READ?ing..."
print my_inst.query(command).split()
print "READ? complete attempting, write/read."
print my_inst.write(command)
print "Wrote READ?, reading from inst..."
print my_inst.read().split()
except Exception as e:
worked = False
print e
print "Had an... exceptional time...."
finally:
my_inst.close()
print "Elapsed time:"
print time.time() - start
print "Did it work: {}".format(worked)
I do not use Python. The READ? and MEAS:VOLT:DC? do work and return an ASCII real,64 floating point number. Following is an example when using the default DCV function with the input open:
-> READ?
<- -1.67223359E-05
-> MEAS:VOLT:DC?
<- -4.97292228E-05
These are just noise values. It is your method of implementing this with PyVISA that is the problem. Sorry I can't help with that.