This commit is contained in:
geeksville
2020-09-16 10:06:03 -07:00
parent 653c31e1dc
commit 3d9b9bc627
2 changed files with 22 additions and 9 deletions

View File

@@ -128,6 +128,7 @@ import sys
import traceback
import time
import base64
import platform
from . import mesh_pb2
from . import util
from pubsub import pub
@@ -515,7 +516,12 @@ class StreamInterface(MeshInterface):
# rts=False Needed to prevent TBEAMs resetting on OSX, because rts is connected to reset
self.stream.port = devPath
self.stream.rts = False
# OS-X seems to have a bug in its serial driver. It ignores that we asked for no RTSCTS
# control and will always drive RTS either high or low (rather than letting the CP102 leave
# it as an open-collector floating pin). Since it is going to drive it anyways we want to make
# sure it is driven low, so that the TBEAM won't reset
if platform.system() == 'Darwin':
self.stream.rts = False
self.stream.open()
self._rxThread = threading.Thread(target=self.__reader, args=())
@@ -584,14 +590,14 @@ class StreamInterface(MeshInterface):
elif ptr == 1: # looking for START2
if c != START2:
self.rfBuf = empty # failed to find start2
self._rxBuf = empty # failed to find start2
elif ptr >= HEADER_LEN: # we've at least got a header
# big endian length follos header
packetlen = (self._rxBuf[2] << 8) + self._rxBuf[3]
if ptr == HEADER_LEN: # we _just_ finished reading the header, validate length
if packetlen > MAX_TO_FROM_RADIO_SIZE:
self.rfBuf = empty # length ws out out bounds, restart
self._rxBuf = empty # length ws out out bounds, restart
if len(self._rxBuf) != 0 and ptr + 1 == packetlen + HEADER_LEN:
try:
@@ -609,7 +615,8 @@ class StreamInterface(MeshInterface):
f"Meshtastic serial port disconnected, disconnecting... {ex}")
finally:
logging.debug("reader is exiting")
self.stream.rts = True # Return RTS high, so that the reset button still works
if platform.system() == 'Darwin':
self.stream.rts = True # Return RTS high, so that the reset button still works
self.stream.close()
self._disconnected()</code></pre>
</details>
@@ -1278,7 +1285,12 @@ debugOut {stream} &ndash; If a stream is provided, any debug serial output from
# rts=False Needed to prevent TBEAMs resetting on OSX, because rts is connected to reset
self.stream.port = devPath
self.stream.rts = False
# OS-X seems to have a bug in its serial driver. It ignores that we asked for no RTSCTS
# control and will always drive RTS either high or low (rather than letting the CP102 leave
# it as an open-collector floating pin). Since it is going to drive it anyways we want to make
# sure it is driven low, so that the TBEAM won&#39;t reset
if platform.system() == &#39;Darwin&#39;:
self.stream.rts = False
self.stream.open()
self._rxThread = threading.Thread(target=self.__reader, args=())
@@ -1347,14 +1359,14 @@ debugOut {stream} &ndash; If a stream is provided, any debug serial output from
elif ptr == 1: # looking for START2
if c != START2:
self.rfBuf = empty # failed to find start2
self._rxBuf = empty # failed to find start2
elif ptr &gt;= HEADER_LEN: # we&#39;ve at least got a header
# big endian length follos header
packetlen = (self._rxBuf[2] &lt;&lt; 8) + self._rxBuf[3]
if ptr == HEADER_LEN: # we _just_ finished reading the header, validate length
if packetlen &gt; MAX_TO_FROM_RADIO_SIZE:
self.rfBuf = empty # length ws out out bounds, restart
self._rxBuf = empty # length ws out out bounds, restart
if len(self._rxBuf) != 0 and ptr + 1 == packetlen + HEADER_LEN:
try:
@@ -1372,7 +1384,8 @@ debugOut {stream} &ndash; If a stream is provided, any debug serial output from
f&#34;Meshtastic serial port disconnected, disconnecting... {ex}&#34;)
finally:
logging.debug(&#34;reader is exiting&#34;)
self.stream.rts = True # Return RTS high, so that the reset button still works
if platform.system() == &#39;Darwin&#39;:
self.stream.rts = True # Return RTS high, so that the reset button still works
self.stream.close()
self._disconnected()</code></pre>
</details>

View File

@@ -12,7 +12,7 @@ with open("README.md", "r") as fh:
# This call to setup() does all the work
setup(
name="meshtastic",
version="1.0.9",
version="1.0.10",
description="Python API & client shell for talking to Meshtastic devices",
long_description=long_description,
long_description_content_type="text/markdown",