#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Board names -> USB serial numbers, for the Python tools. A thin view of the local config (tools/mctools_config.py, ~/.config/meshcore-tools/config.ini): the tools refer to boards by name, and `/dev/serial/by-id` is matched on the serial number -- a ttyACM number changes with every replug and would point a console at a DIFFERENT board. There used to be a table here, and a copy of it in five other places (the shell flashers, the sniffer, the console and a hook). One board reflashed, the copies drifted, and a stale entry aimed a console at the wrong board. Now there is one file, outside the repo. """ from mctools_config import boards, serial_for # noqa: F401 (re-exported) # name -> serial, only boards that have one (a BLE-only node has none) FLEET = {n: b["serial"] for n, b in boards().items() if b.get("serial")} # the same keyed by each alias too (mesh_sniffer takes `--board 0`) FLEET_BARE = dict(FLEET) for _b in boards().values(): for _a in (x.strip() for x in _b.get("aliases", "").split(",")): if _a and _b.get("serial"): FLEET_BARE[_a] = _b["serial"]