Skip to content

Commit cc4671d

Browse files
committed
Fix list_resources by attempting to connect as an instrument first,
then if that fails attempt to connect as a controller and scan for GPIB devices
1 parent e29fd45 commit cc4671d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

vxi11/vxi11.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -528,14 +528,20 @@ def list_resources(ip=None, timeout=1):
528528

529529
for host in list_devices(ip, timeout):
530530
try:
531-
# try connecting as a GPIB interface
532-
intf_dev = InterfaceDevice(host)
533-
# enumerate connected devices
534-
devs = intf_dev.find_listeners()
535-
res.extend(['TCPIP::%s::gpib0,%d::INSTR' % (host, d) for d in devs])
536-
except:
537-
# if that fails, just list the host
531+
# try connecting as an instrument
532+
instr = Instrument(host)
533+
instr.open()
538534
res.append("TCPIP::%s::INSTR" % host)
535+
except:
536+
try:
537+
# try connecting as a GPIB interface
538+
intf_dev = InterfaceDevice(host)
539+
# enumerate connected devices
540+
devs = intf_dev.find_listeners()
541+
res.extend(['TCPIP::%s::gpib0,%d::INSTR' % (host, d) for d in devs])
542+
except:
543+
# if that fails, just list the host
544+
res.append("TCPIP::%s::INSTR" % host)
539545

540546
return res
541547

0 commit comments

Comments
 (0)