def check_dev(self): # Must use globals since each test is a separate class instance global found_devices global found_uris if not isinstance(self.devicename, list): ds = [self.devicename] else: ds = self.devicename dev_checked = False found_dev = False for d in ds: if d in found_devices: found_dev = found_devices[d] # If device was already found before, update the board interface URI self.uri = found_uris[d] dev_checked = True break if not dev_checked: found_dev, board = iio_scanner.find_device(self.devicename) if found_dev: found_devices[board.name] = found_dev found_uris[board.name] = board.uri self.uri = board.uri else: for d in ds: found_devices[d] = False found_uris[d] = "" return found_dev
def check_dev(name): global dev_checked global found_dev if not dev_checked: found_dev, board = iio_scanner.find_device(name) if found_dev: global URI URI = board.uri dev_checked = True return found_dev