From 84bd336c60b65a94957ab92620edb0cf71b6780b Mon Sep 17 00:00:00 2001 From: Sebastian Renner Date: Wed, 10 Jul 2019 15:02:05 +0200 Subject: [PATCH] Encoding is fun! --- templates/blackpill/middleware.py | 13 +++++++------ test.py | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/templates/blackpill/middleware.py b/templates/blackpill/middleware.py index 22ea859..5d077a3 100755 --- a/templates/blackpill/middleware.py +++ b/templates/blackpill/middleware.py @@ -6,6 +6,8 @@ import struct import serial from subprocess import Popen, PIPE, run +ser = serial.Serial('/dev/ttyUSB0', 115200) + def flash(): run("JLinkExe flash.jlink", shell=True, check=True) @@ -20,7 +22,7 @@ def read(channel, l): raise Exception("could not read %d bytes of data (got %d)" % (l, len(data))) return data -def write(channel, data, direction): +def write(channel, data): if channel == 'ser': l = ser.write(data) elif channel == 'std': @@ -32,18 +34,17 @@ def write(channel, data, direction): def obtain(channel): l = read(channel, 4) - print(l) + l = str.encode(l) (l, ) = struct.unpack("