summaryrefslogtreecommitdiffstatshomepage
path: root/tools/pyboard.py
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-12-22 21:35:28 +1100
committerDamien George <damien@micropython.org>2023-01-13 16:38:34 +1100
commit77002a92bfcef58e01f20428df25793d43231b15 (patch)
tree0d3fe3566c6e325dd22da32579a52963d1545fa3 /tools/pyboard.py
parentfa57ee971bcdffeeadf84dc608bd25dcb6af464f (diff)
downloadmicropython-77002a92bfcef58e01f20428df25793d43231b15.tar.gz
micropython-77002a92bfcef58e01f20428df25793d43231b15.zip
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>
Diffstat (limited to 'tools/pyboard.py')
-rwxr-xr-xtools/pyboard.py7
1 files 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("<H", data)[0]
window_remain = window_size
# Write out the command_bytes data.