Skip to content

Commit 6852d3c

Browse files
committed
Add list_resources
1 parent 83fc5b4 commit 6852d3c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

vxi11/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
__all__ = ["vxi11"]
2828

2929
from .version import __version__
30-
from .vxi11 import Instrument, InterfaceDevice, list_devices
30+
from .vxi11 import Instrument, InterfaceDevice, list_devices, list_resources

vxi11/vxi11.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,25 @@ def list_devices(ip=None, timeout=1):
521521
return hosts
522522

523523

524+
def list_resources(ip=None, timeout=1):
525+
"List resource strings for all detected VXI-11 devices"
526+
527+
res = []
528+
529+
for host in list_devices(ip, timeout):
530+
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
538+
res.append("TCPIP::%s::INSTR" % host)
539+
540+
return res
541+
542+
524543
class Device(object):
525544
"VXI-11 device interface client"
526545
def __init__(self, host, name = None, client_id = None, term_char = None):

0 commit comments

Comments
 (0)