parsedump: Support running on both python2 and python3

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2022-12-07 14:31:03 -05:00
parent a42f615881
commit 336cc92a0a
2 changed files with 12 additions and 14 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python
# Script to parse a serial port data dump
#
# Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
@ -23,12 +23,12 @@ def main():
f = open(data_filename, 'rb')
fd = f.fileno()
data = ""
data = bytearray()
while 1:
newdata = os.read(fd, 4096)
if not newdata:
break
data += newdata
data += bytearray(newdata)
while 1:
l = mp.check_packet(data)
if l == 0:
@ -37,7 +37,7 @@ def main():
logging.error("Invalid data")
data = data[-l:]
continue
msgs = mp.dump(bytearray(data[:l]))
msgs = mp.dump(data[:l])
sys.stdout.write('\n'.join(msgs[1:]) + '\n')
data = data[l:]