Skip to content
Snippets Groups Projects
Commit 1e44d5d4 authored by Daniele Nicolodi's avatar Daniele Nicolodi
Browse files

Improve error reporting when no device is found

parent 1e3a35e9
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ import time
import click
import colorama
from .dtdaq import DTDaq
from . import dtdaq
@click.command()
......@@ -18,8 +18,13 @@ from .dtdaq import DTDaq
def main(device, fsampl, channel, gain, filename):
colorama.init()
daq = DTDaq(device.encode('ascii'))
print(f'{daq.name} {daq.version} 0x{daq.hwinfo.serial:X}')
try:
daq = dtdaq.DTDaq(device.encode('ascii'))
print(f'{daq.name} {daq.version} 0x{daq.hwinfo.serial:X}')
except dtdaq.DTDaqError as exc:
if exc.errno == dtdaq.errno.OLCANNOTOPENDRIVER:
return click.echo(f'Error: {exc.message}. Device "{device}" not found.', err=True)
raise
if len(gain) == 1:
gain = list(gain) * len(channel)
......
import click
from .dtdaq import enum_boards
from . import dtdaq
@click.command()
def main():
for board in enum_boards():
print(board.name)
try:
for board in dtdaq.enumerate_devices():
print(board.name)
except dtdaq.DTDaqError as exc:
if exc.errno == dtdaq.errno.OLNOBOARDSINSTALLED:
return print(f'{exc.message}.')
raise
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment