new Parameter --debuglib for only meshtastic debug, more termios fixes for windows tests

(cherry picked from commit 4fc4d41d3d29998bb7b697bf412be5c1449ea950)
This commit is contained in:
shukari
2025-08-19 11:06:03 +02:00
parent cbf7b9befe
commit 52eb112b95
5 changed files with 51 additions and 58 deletions

View File

@@ -2,7 +2,7 @@
"""
# pylint: disable=R0917
import logging
import platform
import sys
import time
from typing import List, Optional
@@ -14,10 +14,6 @@ from meshtastic.stream_interface import StreamInterface
logger = logging.getLogger(__name__)
if platform.system() != "Windows":
import termios
class SerialInterface(StreamInterface):
"""Interface class for meshtastic devices over a serial link"""
@@ -48,15 +44,7 @@ class SerialInterface(StreamInterface):
logger.debug(f"Connecting to {self.devPath}")
# first we need to set the HUPCL so the device will not reboot based on RTS and/or DTR
# see https://github.com/pyserial/pyserial/issues/124
if platform.system() != "Windows":
with open(self.devPath, encoding="utf8") as f:
attrs = termios.tcgetattr(f)
attrs[2] = attrs[2] & ~termios.HUPCL
termios.tcsetattr(f, termios.TCSAFLUSH, attrs)
f.close()
time.sleep(0.1)
self._set_hupcl_with_termios()
self.stream = serial.Serial(
self.devPath, 115200, exclusive=True, timeout=0.5, write_timeout=0
@@ -68,6 +56,22 @@ class SerialInterface(StreamInterface):
self, debugOut=debugOut, noProto=noProto, connectNow=connectNow, noNodes=noNodes
)
def _set_hupcl_with_termios(self):
"""first we need to set the HUPCL so the device will not reboot based on RTS and/or DTR
see https://github.com/pyserial/pyserial/issues/124
"""
if sys.platform == "win32":
return
with open(self.devPath, encoding="utf8") as f:
import termios # pylint: disable=C0415,E0401
attrs = termios.tcgetattr(f)
attrs[2] = attrs[2] & ~termios.HUPCL
termios.tcsetattr(f, termios.TCSAFLUSH, attrs)
f.close()
time.sleep(0.1)
def __repr__(self):
rep = f"SerialInterface(devPath={self.devPath!r}"
if hasattr(self, 'debugOut') and self.debugOut is not None: