Skip to content

Commit af50c0a

Browse files
committed
Initial implementation of list_devices
1 parent e3e8c5e commit af50c0a

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-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
30+
from .vxi11 import Instrument, InterfaceDevice, list_devices

vxi11/vxi11.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,29 @@ def device_abort(self, link):
498498
self.unpacker.unpack_device_error)
499499

500500

501+
def list_devices(ip=None, timeout=1):
502+
"Detect VXI-11 devices on network"
503+
504+
if ip is None:
505+
ip = ['255.255.255.255']
506+
507+
if type(ip) is str:
508+
ip = [ip]
509+
510+
hosts = []
511+
512+
for addr in ip:
513+
pmap = rpc.BroadcastUDPPortMapperClient(addr)
514+
pmap.set_timeout(timeout)
515+
resp = pmap.get_port((DEVICE_CORE_PROG, DEVICE_CORE_VERS, rpc.IPPROTO_TCP, 0))
516+
517+
l = [r[1][0] for r in resp if r[0] > 0]
518+
519+
hosts.extend(l)
520+
521+
return hosts
522+
523+
501524
class Device(object):
502525
"VXI-11 device interface client"
503526
def __init__(self, host, name = None, client_id = None, term_char = None):

0 commit comments

Comments
 (0)