From c0232c15511f753c2d7b63d1c48c02ffe3b4e722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 19 Feb 2021 17:41:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Display=20vid/uid=20on=20USB=20p?= =?UTF-8?q?orts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/comm/TODO.md | 2 ++ src/octoprint/comm/protocol/__init__.py | 2 +- src/octoprint/comm/transport/serialtransport.py | 11 ++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/octoprint/comm/TODO.md b/src/octoprint/comm/TODO.md index 22f080271..d7aecfcb9 100644 --- a/src/octoprint/comm/TODO.md +++ b/src/octoprint/comm/TODO.md @@ -2,12 +2,14 @@ * firmware info propagation & FirmwareCheck * auto connect on start + * any chance to match by vid/pid (#4023) * save and connect * keep connection settings after disconnect, currently they revert to default * Settings API for transport/protocol settings * UI for connection profiles * UI for transport/protocol settings * SerialTransport: + * Auto detection (relies on protocol, which makes this somewhat tricky) * RepRapProtocol: TBC diff --git a/src/octoprint/comm/protocol/__init__.py b/src/octoprint/comm/protocol/__init__.py index 403025faa..b36363496 100644 --- a/src/octoprint/comm/protocol/__init__.py +++ b/src/octoprint/comm/protocol/__init__.py @@ -231,7 +231,7 @@ class Protocol(ListenerAware, TransportListener, ProtocolErrorStatsListener): return [] def __init__(self, *args, **kwargs): - super(Protocol, self).__init__() + super().__init__() self._logger = logging.getLogger(__name__) self._connection_logger = logging.getLogger("CONNECTION") diff --git a/src/octoprint/comm/transport/serialtransport.py b/src/octoprint/comm/transport/serialtransport.py index 1a6c8aa76..28d394c0e 100644 --- a/src/octoprint/comm/transport/serialtransport.py +++ b/src/octoprint/comm/transport/serialtransport.py @@ -131,9 +131,18 @@ class SerialTransport(Transport): def get_available_serial_ports(cls): from serial.tools.list_ports import comports + def port_title(port): + if port.vid and port.pid: + # usb + return "{desc} [{vid:04x}:{pid:04x}]".format( + desc=port.description, vid=port.vid, pid=port.pid + ) + else: + return port.description + port_values = [Value(None, title="Auto detect")] + sorted( [ - Value(port.device, title=port.description) + Value(port.device, title=port_title(port)) for port in comports() if port.device not in cls.ignored_ports ],