From b00cea250f71c3d1167eb10f570e3abba6c19186 Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Sat, 15 Feb 2020 16:53:58 +0800 Subject: [PATCH] idf_monitor: fix gdb issue opening large COM port on Windows The GDB uses CreateFile to open COM port on Windows. However this function requires COM path to be `\\.\COMx` to open COM port whose number is larger than 10. Replace the port name from `COM` to `\\.\COM` when on Windows to fix this. --- tools/idf_monitor.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/idf_monitor.py b/tools/idf_monitor.py index 0c1e2bfa01..7ea827856d 100755 --- a/tools/idf_monitor.py +++ b/tools/idf_monitor.py @@ -931,7 +931,13 @@ def main(): args = parser.parse_args() - if args.port.startswith("/dev/tty."): + # GDB uses CreateFile to open COM port, which requires the COM name to be r'\\.\COMx' if the COM + # number is larger than 10 + if os.name == 'nt' and args.port.startswith("COM"): + args.port = args.port.replace('COM', r'\\.\COM') + yellow_print("--- WARNING: GDB cannot open serial ports accessed as COMx") + yellow_print("--- Using %s instead..." % args.port) + elif args.port.startswith("/dev/tty."): args.port = args.port.replace("/dev/tty.", "/dev/cu.") yellow_print("--- WARNING: Serial ports accessed as /dev/tty.* will hang gdb if launched.") yellow_print("--- Using %s instead..." % args.port)