Source code for lab_driver.scan_instruments
from logging import getLogger
from platform import system
import pyvisa
logger = getLogger(__name__)
[docs]
def scan_instruments() -> list:
"""Scanning the VISA bus for instruments
:return: List of all detected instruments
"""
if system() == "Linux":
rm = pyvisa.ResourceManager("/usr/lib/librsvisa.so@ivi")
else:
rm = pyvisa.ResourceManager()
obj_inst = rm.list_resources()
logger.debug(f"\nUsing VISA driver: {rm}")
logger.debug("Available devices")
logger.debug("--------------------------------------")
out_dev_adr = list()
for idx, inst_name in enumerate(obj_inst):
out_dev_adr.append(inst_name)
logger.debug(f"{idx}: {inst_name}")
rm.close()
assert out_dev_adr != [], "No instruments found!"
return out_dev_adr