Skip to content

Commit ec78f62

Browse files
authored
Merge pull request #763 from meshtastic/revert-753-fix-rtsdtr-windows
Revert "Work around RTS/DTR serial reset issues on Windows"
2 parents ee0f73a + dfc9547 commit ec78f62

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

meshtastic/serial_interface.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ def __init__(self, devPath: Optional[str]=None, debugOut=None, noProto: bool=Fal
4646

4747
logging.debug(f"Connecting to {self.devPath}")
4848

49-
# set port to None to prevent automatically opening
50-
self.stream = serial.Serial(
51-
port=None, baudrate=115200, exclusive=True, timeout=0.5, write_timeout=0
52-
)
53-
54-
# first we need to clear HUPCL (UNIX) or clear RTS/DTR (Windows) so the device will not reboot based on RTS and/or DTR
49+
# first we need to set the HUPCL so the device will not reboot based on RTS and/or DTR
5550
# see https://github.com/pyserial/pyserial/issues/124
5651
if platform.system() != "Windows":
5752
with open(self.devPath, encoding="utf8") as f:
@@ -60,14 +55,10 @@ def __init__(self, devPath: Optional[str]=None, debugOut=None, noProto: bool=Fal
6055
termios.tcsetattr(f, termios.TCSAFLUSH, attrs)
6156
f.close()
6257
time.sleep(0.1)
63-
else:
64-
self.stream.rts = 0
65-
self.stream.dtr = 0
66-
67-
# set proper port and open now that we've worked-around RTS/DTR issues
68-
self.stream.port = self.devPath
69-
self.stream.open()
7058

59+
self.stream = serial.Serial(
60+
self.devPath, 115200, exclusive=True, timeout=0.5, write_timeout=0
61+
)
7162
self.stream.flush() # type: ignore[attr-defined]
7263
time.sleep(0.1)
7364

0 commit comments

Comments
 (0)