Permalink
Browse files

Python 2 and 3 bytes buffer from hex. I don't like it, but it should …

…work.
  • Loading branch information...
1 parent 6f29d3a commit 2457f10ba6bf3a78a3adb64e78464cf5366a2df8 @rvalles committed Aug 13, 2016
Showing with 5 additions and 2 deletions.
  1. +5 −2 brntool.py
View
7 brntool.py
@@ -36,12 +36,15 @@ def memreadblock(ser,addr,size):
pass
ser.write(str(size).encode())
ser.write('\r'.encode())
- buf=''
+ buf=b''
m = False
while not m:
m = lineregex.match(ser.readline().decode().strip())
while m:
- buf+=''.join([chr(int(x, 16)) for x in m.group(1)[1:].split(' ')])
+ if sys.version_info >= (3, 0):
+ buf+=bytes(m.group(1)[1:].split(' '))
+ else:
+ buf+=''.join([chr(int(x, 16)) for x in m.group(1)[1:].split(' ')])
m = lineregex.match(ser.readline().decode().strip())
return buf
def memreadblock2file(ser,fd,addr,size):

0 comments on commit 2457f10

Please sign in to comment.