macOS: do not reset the box on connect

On macOS/Linux the OS asserts DTR and RTS when the port is opened and
pyserial then writes DTR before RTS, passing through RTS=1/DTR=0 - the
USB-Serial-JTAG reset state. Every Connect restarted the box. Drop RTS
before open and DTR right after it on posix; Windows is unchanged.

Verified on macOS 27 / arm64 with box A4:CB:8F:C9:47:3C (fw 1.0.16,
build 3ae273ec): connect keeps the box running, Reset & capture still
restarts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
KrzyszurandClaude Opus 5.5 committed 2026-10-01 00:06:48 +02:00
1 parent 834bad2bce
commit 2b6d43eb45
2 files changed
+53 -4

No files matched your search

+13 -4
View File
@@ -10,6 +10,7 @@ from __future__ import annotations
import enum
import queue
import sys
import threading
import time
from collections.abc import Callable
@@ -92,13 +93,21 @@ class SerialManager:
ser = serial.serial_for_url(
info.device, baudrate=self._baud, timeout=READ_TIMEOUT_S, do_not_open=True
)
# Deassert both lines before open. On USB-Serial-JTAG, RTS=1/DTR=0
# holds the chip in reset and DTR=1 during reset selects download
# mode; pyserial would otherwise assert both on open (Windows).
ser.dtr = False
# On USB-Serial-JTAG, RTS=1/DTR=0 holds the chip in reset and DTR=1
# during reset selects download mode.
# Windows: pyserial applies both lines atomically at open, so
# deassert both beforehand (it would otherwise assert both).
# macOS/Linux: the OS asserts both lines on open and pyserial then
# writes DTR before RTS, passing through RTS=1/DTR=0 and resetting
# the box on every connect. Drop RTS first, then DTR.
posix = sys.platform != "win32"
if not posix:
ser.dtr = False
ser.rts = False
try:
ser.open()
if posix:
ser.dtr = False
except (serial.SerialException, OSError):
return None
self._target.device = info.device # COM number / node may change