-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconsole_examples_util.py
More file actions
41 lines (33 loc) · 1.5 KB
/
Copy pathconsole_examples_util.py
File metadata and controls
41 lines (33 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from __future__ import absolute_import, division, print_function
from builtins import * # @UnusedWildImport
from mcculw import ul
from mcculw.enums import InterfaceType
def config_first_detected_device(board_num, dev_id_list=None):
"""Adds the first available device to the UL. If a types_list is specified,
the first available device in the types list will be add to the UL.
Parameters
----------
board_num : int
The board number to assign to the board when configuring the device.
dev_id_list : list[int], optional
A list of product IDs used to filter the results. Default is None.
See UL documentation for device IDs.
"""
ul.ignore_instacal()
devices = ul.get_daq_device_inventory(InterfaceType.ANY)
if not devices:
raise Exception('Error: No DAQ devices found')
print('Found', len(devices), 'DAQ device(s):')
for device in devices:
print(' ', device.product_name, ' (', device.unique_id, ') - ',
'Device ID = ', device.product_id, sep='')
device = devices[0]
if dev_id_list:
device = next((device for device in devices
if device.product_id in dev_id_list), None)
if not device:
err_str = 'Error: No DAQ device found in device ID list: '
err_str += ','.join(str(dev_id) for dev_id in dev_id_list)
raise Exception(err_str)
# Add the first DAQ device to the UL with the specified board number
ul.create_daq_device(board_num, device)