diff --git a/docs/reference/mpremote.rst b/docs/reference/mpremote.rst index bb0686237a..3225fc5f24 100644 --- a/docs/reference/mpremote.rst +++ b/docs/reference/mpremote.rst @@ -19,10 +19,10 @@ The simplest way to use this tool is just by invoking it without any arguments: mpremote -This command automatically detects and connects to the first available serial -device and provides an interactive REPL. Serial ports are opened in exclusive -mode, so running a second (or third, etc) instance of ``mpremote`` will connect -to subsequent serial devices, if any are available. +This command automatically detects and connects to the first available USB +serial device and provides an interactive REPL. Serial ports are opened in +exclusive mode, so running a second (or third, etc) instance of ``mpremote`` +will connect to subsequent serial devices, if any are available. Commands @@ -52,7 +52,7 @@ The full list of supported commands are: ```` may be one of: - ``list``: list available devices - - ``auto``: connect to the first available device + - ``auto``: connect to the first available USB serial port - ``id:``: connect to the device with USB serial number ```` (the second entry in the output from the ``connect list`` command) @@ -186,8 +186,8 @@ Auto connection and soft-reset Connection and disconnection will be done automatically at the start and end of 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. +connection will search for the first available USB serial device. If no action +is specified then the REPL will be entered. Once connected to a device, ``mpremote`` will automatically soft-reset the device if needed. This clears the Python heap and restarts the interpreter, diff --git a/tools/mpremote/README.md b/tools/mpremote/README.md index 7f58788fbe..4eb1b86fb4 100644 --- a/tools/mpremote/README.md +++ b/tools/mpremote/README.md @@ -7,7 +7,7 @@ The simplest way to use this tool is: mpremote -This will automatically connect to the device and provide an interactive REPL. +This will automatically connect to a USB serial port and provide an interactive REPL. The full list of supported commands are: diff --git a/tools/mpremote/mpremote/commands.py b/tools/mpremote/mpremote/commands.py index 3bd8732bd0..d05a27d9f2 100644 --- a/tools/mpremote/mpremote/commands.py +++ b/tools/mpremote/mpremote/commands.py @@ -32,14 +32,15 @@ def do_connect(state, args=None): # Don't do implicit REPL command. state.did_action() elif dev == "auto": - # Auto-detect and auto-connect to the first available device. + # Auto-detect and auto-connect to the first available USB serial port. for p in sorted(serial.tools.list_ports.comports()): - try: - state.pyb = pyboard.PyboardExtended(p.device, baudrate=115200) - return - except pyboard.PyboardError as er: - if not er.args[0].startswith("failed to access"): - raise er + if p.vid is not None and p.pid is not None: + try: + state.pyb = pyboard.PyboardExtended(p.device, baudrate=115200) + return + except pyboard.PyboardError as er: + if not er.args[0].startswith("failed to access"): + raise er raise pyboard.PyboardError("no device found") elif dev.startswith("id:"): # Search for a device with the given serial number.