tools/mpremote: Add support for rfc2217, serial over TCP.

Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
This commit is contained in:
Jos Verlinde 2023-08-11 13:26:17 +02:00 committed by Damien George
parent 88ecc78eb3
commit 58c2c503a9
2 changed files with 6 additions and 2 deletions

View File

@ -100,6 +100,8 @@ The full list of supported commands are:
command output) command output)
- ``port:<path>``: connect to the device with the given path (the first column - ``port:<path>``: connect to the device with the given path (the first column
from the ``connect list`` command output from the ``connect list`` command output
- ``rfc2217://<host>:<port>``: connect to the device using serial over TCP
(e.g. a networked serial port based on RFC2217)
- any valid device name/path, to connect to that device - any valid device name/path, to connect to that device
**Note:** Instead of using the ``connect`` command, there are several **Note:** Instead of using the ``connect`` command, there are several
@ -109,7 +111,7 @@ The full list of supported commands are:
**Note:** The ``auto`` option will only detect USB serial ports, i.e. a serial **Note:** The ``auto`` option will only detect USB serial ports, i.e. a serial
port that has an associated USB VID/PID (i.e. CDC/ACM or FTDI-style port that has an associated USB VID/PID (i.e. CDC/ACM or FTDI-style
devices). Other types of serial ports devices). Other types of serial ports will not be auto-detected.
.. _mpremote_command_disconnect: .. _mpremote_command_disconnect:

View File

@ -76,7 +76,9 @@ class SerialTransport(Transport):
delayed = False delayed = False
for attempt in range(wait + 1): for attempt in range(wait + 1):
try: try:
if os.name == "nt": if device.startswith("rfc2217://"):
self.serial = serial.serial_for_url(device, **serial_kwargs)
elif os.name == "nt":
self.serial = serial.Serial(**serial_kwargs) self.serial = serial.Serial(**serial_kwargs)
self.serial.port = device self.serial.port = device
portinfo = list(serial.tools.list_ports.grep(device)) # type: ignore portinfo = list(serial.tools.list_ports.grep(device)) # type: ignore