make dtr configurable and true by default (rts false by default)

This commit is contained in:
Florent
2026-09-15 08:11:00 -04:00
parent f757e2b2f6
commit ec0582df22
2 changed files with 6 additions and 4 deletions
+3 -2
View File
@@ -118,10 +118,11 @@ class MeshCore:
auto_reconnect: bool = False,
max_reconnect_attempts: int = 3,
cx_dly: float = 0.1,
rts = True
rts = False,
dtr = True
) -> "MeshCore":
"""Create and connect a MeshCore instance using serial connection"""
connection = SerialConnection(port, baudrate, cx_dly=cx_dly, rts=rts)
connection = SerialConnection(port, baudrate, cx_dly=cx_dly, rts=rts, dtr=dtr)
mc = cls(
connection,
+3 -2
View File
@@ -11,7 +11,7 @@ logger = logging.getLogger("meshcore")
class SerialConnection:
def __init__(self, port, baudrate, cx_dly=0.2, rts=True):
def __init__(self, port, baudrate, cx_dly=0.2, rts=False, dtr=True):
self.port = port
self.baudrate = baudrate
self.transport = None
@@ -22,6 +22,7 @@ class SerialConnection:
self._connected_event = asyncio.Event()
self._background_tasks: set[asyncio.Task] = set()
self.rts = rts
self.dtr = dtr
self.frame_expected_size = 0
self.inframe = b""
@@ -42,7 +43,7 @@ class SerialConnection:
self.cx.transport = transport
logger.debug('port opened')
if isinstance(transport, serial_asyncio.SerialTransport) and transport.serial:
transport.serial.dtr = False # Deassert DTR to avoid serial-open reset/handshake issues
transport.serial.dtr = self.cx.dtr # DTR should be deasserted on heltec_v2 to avoid serial-open reset/handshake issues
transport.serial.rts = self.cx.rts
self.cx._connected_event.set()