Skip to content

Commit

Permalink
Fix list_resources by attempting to connect as an instrument first,
Browse files Browse the repository at this point in the history
then if that fails attempt to connect as a controller and scan for
GPIB devices
  • Loading branch information
alexforencich committed Oct 16, 2017
1 parent e29fd45 commit cc4671d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions vxi11/vxi11.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,20 @@ def list_resources(ip=None, timeout=1):

for host in list_devices(ip, timeout):
try:
# try connecting as a GPIB interface
intf_dev = InterfaceDevice(host)
# enumerate connected devices
devs = intf_dev.find_listeners()
res.extend(['TCPIP::%s::gpib0,%d::INSTR' % (host, d) for d in devs])
except:
# if that fails, just list the host
# try connecting as an instrument
instr = Instrument(host)
instr.open()
res.append("TCPIP::%s::INSTR" % host)
except:
try:
# try connecting as a GPIB interface
intf_dev = InterfaceDevice(host)
# enumerate connected devices
devs = intf_dev.find_listeners()
res.extend(['TCPIP::%s::gpib0,%d::INSTR' % (host, d) for d in devs])
except:
# if that fails, just list the host
res.append("TCPIP::%s::INSTR" % host)

return res

Expand Down

0 comments on commit cc4671d

Please sign in to comment.