Skip to content

Commit

Permalink
tools/mpremote: Add sync byte to response.
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed May 11, 2021
1 parent 275d3c8 commit 6e50615
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/mpremote/src/mpremote/pyboardextended.py
Expand Up @@ -71,11 +71,15 @@ def rd_into(self, buf, n):
def begin(self, type):
micropython.kbd_intr(-1)
buf4 = self.buf4
while self.poller.poll(0):
self.fin.readinto(buf4, 1)
buf4[0] = 0x18
buf4[1] = type
self.fout.write(buf4, 2)
# Wait for sync byte 0x18, but don't get stuck forever
for i in range(30):
self.poller.poll(1000)
self.fin.readinto(buf4, 1)
if buf4[0] == 0x18:
break
def end(self):
micropython.kbd_intr(3)
Expand Down Expand Up @@ -502,6 +506,7 @@ def _check_input(self, blocking):
if c == b"\x18":
# a special command
c = self.orig_serial.read(1)[0]
self.orig_serial.write(b"\x18") # Acknowledge command
PyboardCommand.cmd_table[c](self.cmd)
elif not VT_ENABLED and c == b"\x1b":
# ESC code, ignore these on windows
Expand Down

0 comments on commit 6e50615

Please sign in to comment.