mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
dist/tools/usb-serial/ttys.py: return error on empty list
If no TTY serial (matching the given filters, if any) was found, use the exit code `1`. The idea is that simple shell scripts falling back to alternative variants of a board can be used via ```.sh ttys.py --most-recent --model Fooboard --vendor Footronic || \ ttys.py --most-recent --model Barboard --vendor Bartronic ``` Just adding a regex that would accept both vendors and models would have different semantics: If both a Fooboard and a Barboard are attached, it would pick the most recently connected of both. The shell expression above would always prefer a Fooboard over a Borboard. The use case cheap Arduino clones that replace the ATmega16U2 used as USB UART bridge with cheap single purpose chips. The original ATmega16U2 has the advantage that it provides identification data unique the specific Arduino board, while the clones cannot be told apart from standalone USB UART bridges or Arduino clones of other models. Hence, we want to pick the genuine Arduino board if connected, and only fall back to matching cheap USB UART bridges if no genuine Arduino board is connected.
This commit is contained in:
parent
bf20287229
commit
86b7159e37
5
dist/tools/usb-serial/ttys.py
vendored
5
dist/tools/usb-serial/ttys.py
vendored
@ -176,7 +176,7 @@ def generate_filters(args):
|
||||
Generate filters for use in the filters_match function from the command
|
||||
line arguments
|
||||
"""
|
||||
result = list()
|
||||
result = []
|
||||
if args.serial is not None:
|
||||
result.append(("serial", re.compile(r"^" + re.escape(args.serial)
|
||||
+ r"$")))
|
||||
@ -225,6 +225,9 @@ def print_ttys(args):
|
||||
else:
|
||||
ttys = []
|
||||
|
||||
if len(ttys) == 0:
|
||||
sys.exit(1)
|
||||
|
||||
print_results(args, ttys)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user