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

makefiles/tools/serial.inc.mk: Improve MOST_RECENT_PORT=1 handling

When `stdio_cdc_acm` is used, prefer selecting the USB devices with
vendor `RIOT-os.org` and model `$(BOARD)` and only fall back
to `$(TTY_BOARD_FILTER)` if no such TTY was found.

This makes it possible to add a TTY board filter matching only an
integrated USB to UART bridge, but still do the right thing when
the user explicitly uses `stdio_cdc_acm` instead of the default
`stdio_uart`.
This commit is contained in:
Marian Buschsieweke 2024-01-17 21:48:13 +01:00
parent f22fc0080b
commit 93aa9e1e0d
No known key found for this signature in database
GPG Key ID: 77AA882EC78084E6

View File

@ -1,12 +1,16 @@
# Select the most recently attached tty interface
ifeq (1,$(MOST_RECENT_PORT))
ifneq (,$(filter stdio_cdc_acm,$(USEMODULE)))
TTY_BOARD_FILTER ?= --model $(BOARD) --vendor 'RIOT-os\.org'
TTY_SELECT_CMD ?= $(RIOTTOOLS)/usb-serial/ttys.py \
--most-recent \
--format path serial \
--model '$(BOARD)' --vendor 'RIOT-os\.org'
else
TTY_SELECT_CMD ?= $(RIOTTOOLS)/usb-serial/ttys.py \
--most-recent \
--format path serial \
$(TTY_BOARD_FILTER)
endif
TTY_SELECT_CMD ?= $(RIOTTOOLS)/usb-serial/ttys.py \
--most-recent \
--format path serial \
$(TTY_BOARD_FILTER)
TTY_DETECTED := $(shell $(TTY_SELECT_CMD) || echo 'no-tty-detected no-serial-detected')
PORT_DETECTED := $(firstword $(TTY_DETECTED))
PORT_SERIAL_DETECTED := $(lastword $(TTY_DETECTED))