From 77002a92bfcef58e01f20428df25793d43231b15 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 22 Dec 2022 21:35:28 +1100 Subject: [PATCH] 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 --- tools/pyboard.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/pyboard.py b/tools/pyboard.py index 55c00fbca1..73250a7c28 100755 --- a/tools/pyboard.py +++ b/tools/pyboard.py @@ -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("