diff --git a/docs/reference/mpremote.rst b/docs/reference/mpremote.rst index a48df9953f503..1c941029166d3 100644 --- a/docs/reference/mpremote.rst +++ b/docs/reference/mpremote.rst @@ -179,6 +179,15 @@ the execution of the tool, if such commands are not explicitly given. Automatic connection will search for the first available serial device. If no action is specified then the REPL will be entered. +It is possible to filter the serial devices eligible for auto connection by defining +``autoconnect_regexp`` in ``.config/mpremote/config.py``: + +.. code-block:: python3 + + # regular expression used to filter ports eligible for auto connect: + autoconnect_regexp = '/dev/cu.usbmodem' + + Once connected to a device, ``mpremote`` will automatically soft-reset the device if needed. This clears the Python heap and restarts the interpreter, making sure that subsequent Python code executes in a fresh environment. Auto diff --git a/tools/mpremote/mpremote/main.py b/tools/mpremote/mpremote/main.py index bd98da88248c1..397c28de802e2 100644 --- a/tools/mpremote/mpremote/main.py +++ b/tools/mpremote/mpremote/main.py @@ -239,7 +239,14 @@ def do_connect(args): return None elif dev == "auto": # Auto-detect and auto-connect to the first available device. - for p in sorted(serial.tools.list_ports.comports()): + try: + autoconnect_regexp = load_user_config().__dict__["autoconnect_regexp"] + except KeyError: + if sys.platform == "darwin": + autoconnect_regexp = "/dev/cu.usb" + else: + autoconnect_regexp = "" + for p in sorted(serial.tools.list_ports.grep(autoconnect_regexp)): try: return pyboard.PyboardExtended(p.device, baudrate=115200) except pyboard.PyboardError as er: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy