revamp the serial connection to avoid Tbeam reboots

This commit is contained in:
Mike Kinney
2021-12-29 19:24:26 -08:00
parent 047f43534f
commit c70d36d2cd
3 changed files with 32 additions and 42 deletions

View File

@@ -62,7 +62,8 @@ class StreamInterface(MeshInterface):
# because we want to ensure it is looking for START1)
p = bytearray([START2] * 32)
self._writeBytes(p)
time.sleep(0.1) # wait 100ms to give device time to start running
if not self.noProto:
time.sleep(0.1) # wait 100ms to give device time to start running
self._rxThread.start()
@@ -88,6 +89,9 @@ class StreamInterface(MeshInterface):
if self.stream: # ignore writes when stream is closed
self.stream.write(b)
self.stream.flush()
# we sleep here to give the TBeam a chance to work
if not self.noProto:
time.sleep(0.1)
def _readBytes(self, length):
"""Read an array of bytes from our stream"""