def get_device_list(*device_ids): """Get the contents of the device list which match the supplied device IDs. Parameters ---------- device_ids : :class:`int` A sequence of device ID's. Returns ------- :class:`list` of :class:`str` A list of device serial numbers for the specified device ID(s). Raises ------ :exc:`.ThorlabsError` If there was an error getting the device list. """ n = MotionControl.SERIAL_NUMBER_BUFFER_SIZE buffer = create_string_buffer(n) ids = (c_int * len(device_ids))(*device_ids) if len(device_ids) == 0: ret = device_manager().TLI_GetDeviceListExt(buffer, n) else: ret = device_manager().TLI_GetDeviceListByTypesExt( buffer, n, ids, len(device_ids)) if ret != 0: raise ThorlabsError( 'Error getting device list for {}'.format(device_ids)) return [sn for sn in buffer.value.decode().split(',') if sn]
def get_device_info(serial_number): """Get the device information from a USB port. The device info is read from the USB port not from the device itself. Parameters ---------- serial_number : :class:`str` The serial number of the device. Returns ------- :class:`.structs.TLI_DeviceInfo` A DeviceInfo structure. Raises ------ :exc:`.ThorlabsError` If there was an error getting the device information. """ info = TLI_DeviceInfo() ret = device_manager().TLI_GetDeviceInfo( str(serial_number).encode(), byref(info)) if ret == 0: raise ThorlabsError( 'Error getting device info for {}'.format(serial_number)) return info
def build_device_list(): """Build the device list. This function builds an internal collection of all devices found on a USB port that are not currently open. Note ---- If a device is open, it will not appear in the list until the device has been closed. Raises ------ :exc:`.ThorlabsError` If the device list cannot be built. """ ret = device_manager().TLI_BuildDeviceList() if ret != 0: raise ThorlabsError('Error building device list') return ret