From d02d30a2161afb3381db9fecbc8fcb3532040e98 Mon Sep 17 00:00:00 2001 From: Mark Blakeney Date: Thu, 25 Apr 2024 10:30:38 +1000 Subject: [PATCH] mpremote: Do not list bogus devices. Signed-off-by: Mark Blakeney --- tools/mpremote/mpremote/commands.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/mpremote/mpremote/commands.py b/tools/mpremote/mpremote/commands.py index aae612765b..abf26aa1b1 100644 --- a/tools/mpremote/mpremote/commands.py +++ b/tools/mpremote/mpremote/commands.py @@ -20,16 +20,17 @@ def do_connect(state, args=None): if dev == "list": # List attached devices. for p in sorted(serial.tools.list_ports.comports()): - print( - "{} {} {:04x}:{:04x} {} {}".format( - p.device, - p.serial_number, - p.vid if isinstance(p.vid, int) else 0, - p.pid if isinstance(p.pid, int) else 0, - p.manufacturer, - p.product, + if p.serial_number is not None: + print( + "{} {} {:04x}:{:04x} {} {}".format( + p.device, + p.serial_number, + p.vid if isinstance(p.vid, int) else 0, + p.pid if isinstance(p.pid, int) else 0, + p.manufacturer, + p.product, + ) ) - ) # Don't do implicit REPL command. state.did_action() elif dev == "auto":