1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

21 Commits

Author SHA1 Message Date
Dylan Laduranty
1007f020ea dist/tools/usb-serial/find-tty.sh: call ttys.py with its path
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-07-13 16:43:57 +02:00
Dylan Laduranty
3b85c56646 dist/tools/usb-serial/list-ttys.sh: call ttys.py with its path
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-07-13 16:36:12 +02:00
Marian Buschsieweke
6192c620c8
dist/tools/usb-serial: Fix handling of None while quoting
This fixes:

    Traceback (most recent call last):
      File "/home/maribu/Repos/software/RIOT/master/dist/tools/usb-serial/ttys.py", line 259, in <module>
        print_ttys(sys.argv)
      File "/home/maribu/Repos/software/RIOT/master/dist/tools/usb-serial/ttys.py", line 255, in print_ttys
        print_results(args, ttys)
      File "/home/maribu/Repos/software/RIOT/master/dist/tools/usb-serial/ttys.py", line 189, in print_results
        if item.rfind(args.format_sep) >= 0:
           ^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'rfind'

Which occurs while testing whether a string requires special quoting
if an attribute is None.
2023-06-21 22:13:21 +02:00
Alain Péteut
25df307ea1 dist/tools: Use /usr/bin/env to lookup Python.
Fixes some Python scripts which didn't use `/usr/bin/env`.
2023-04-10 14:39:42 +02:00
Marian Buschsieweke
48a02d60e2
dist/tools/usb-serial/ttys.py: Allow combining simple formats
For scripts it can be useful to output not only one, but multiple
formats (e.g. to obtain both path and serial of a TTY). The script
now support passing multiple formats.

Note that only simple formats can be combined, as the JSON and markdown
table won't mix well with any other format.
2023-02-24 16:49:44 +01:00
Marian Buschsieweke
2cc70027b0
dist/tools/usb-serial: Clean up legacy scripts
Refactor the old bash scripts to use `ttys.py` instead and update the
documentation.
2023-01-06 15:52:09 +01:00
Marian Buschsieweke
86b7159e37
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.
2022-12-09 13:00:54 +01:00
Marian Buschsieweke
572a713f22
dist/tools/usb-serial: fix exception on missing entries
For some TTY interfaces no DB entry exists, which is reflected by
having a `None` in `tty[key]`. Trying to match a regex against `None`
in turn resulted then in an exception.

This fixes the issue by treating a filter applied on a non-existing
entry as not matching.
2022-12-05 11:02:36 +01:00
Marian Buschsieweke
dc6e8e51d7
dist/tools/usb-serial/ttys.py: improve error handling
Do not throw an exception when called with `--most-recent` but no
matching serial was found.
2022-08-29 16:37:28 +02:00
Marian Buschsieweke
22aed458d5
dist/tools/usb-serial/ttys.py: add --iface-num
This is useful when a debugger provides multiple serial interfaces, e.g.
one to control the debugger and one as UART bridge.
2022-06-03 19:59:30 +02:00
Marian Buschsieweke
f0068a7c96
dist/tools/usb-serial/ttys.py: clean up unused function
The shorten() function was previously used to fit in overlong entries
into the table. But since it is no longer used, it can be dropped.
2022-06-03 19:59:30 +02:00
Marian Buschsieweke
d61e28fe27
dist/tools/usb-serial/ttys.py: Add regex support
Use regular expressions instead of matching literal strings for all
attributes instead of the serial number to be more flexible.

The idea is to aid users when multiple boards are connected to a machine
but each of a different type. If a board would define filter arguments
for dist/tools/usb-serial/ttys.py it could be possible to detect the
right TTY automatically, without user-side modifications. However,
some boards present different model names depending on the firmware
version of the programmer. Support for regular expressions can provide
the flexibility needed to just match all revisions and variants of a
board.
2022-03-28 10:57:00 +02:00
Marian Buschsieweke
b296ade6b2
dist/tools/usb-serial: Add ttys.py
- Provide a new tool to list and filter TTYs
- Change `Makefile.include` to use `$(RIOTTOOLS)/usb-serial/ttys.py`
  instead of `$(Q)$(RIOTTOOLS)/usb-serial/list-ttys.sh` to implement
  `make list-ttys`
- Extend `makefiles/tools/serial.inc.mk` to allow using the most recent
  port by passing `MOST_RECENT_PORT=1` as environment variable or
  parameter to make

Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: Koen Zandberg <koen@bergzand.net>
2022-03-09 15:40:36 +01:00
cb660898b3
usb-serial/list-ttys: Resolve shellcheck issues 2020-10-30 16:13:05 +01:00
6acb523d35
list-ttys: Add punctuation between name and serial 2019-09-30 18:28:32 +02:00
Juan Carrano
7f1357b721 tools/usb-serial: do not advise people to export PORT.
The example in the tool documentation contains several things that are
wrong:

- exports PORT.
- Defines the port using :=.
- Defines PORT instead of PORT_LINUX, PORT_DARWIN
- ifeq-based logic (which will force an evaluation).

I have not tested the new example script.
2019-06-03 16:31:31 +02:00
Gaëtan Harter
1087e49379
dist/tools/usb-serial: use RIOTTOOLS variable 2018-06-28 14:05:33 +02:00
Ian Martin
b1946e6715 dist: tools: let find-tty.sh return all matches, not just the first 2016-05-18 15:33:01 -04:00
Thomas Eichinger
72ee60b9d5 scripts: remove hardcoding of bash hashbang
For host systems like FreeBSD, bash binary is found in a different path.
2015-11-25 16:20:56 +01:00
Ludwig Knüpfer
eda6328e21 documentation: update my name (Ortmann -> Knüpfer) 2015-09-27 18:58:30 +02:00
Joakim Gebart
086825bfa3 dist: Add tools for finding USB serial adapters on Linux.
These tools can be used to find the corresponding TTY device node of
attached USB serial adapter devices.
2015-02-09 19:43:18 +01:00