tools/pyboard.py: Fix Python 2 compatibility.

In Python 2, serial.read()[0] a string, not int. Use struct.unpack to do
this instead.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared 2022-12-22 21:35:28 +11:00 committed by Damien George
parent fa57ee971b
commit 77002a92bf
1 changed files with 4 additions and 3 deletions

View File

@ -67,10 +67,11 @@ Or:
"""
import ast
import os
import struct
import sys
import time
import os
import ast
try:
stdout = sys.stdout.buffer
@ -379,7 +380,7 @@ class Pyboard:
def raw_paste_write(self, command_bytes):
# Read initial header, with window size.
data = self.serial.read(2)
window_size = data[0] | data[1] << 8
window_size = struct.unpack("<H", data)[0]
window_remain = window_size
# Write out the command_bytes data.