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("