Skip to content

Commit

Permalink
tool/create_packet_log: report parsing error and continue
Browse files Browse the repository at this point in the history
  • Loading branch information
mringwal committed Mar 14, 2018
1 parent 8c90079 commit 9aa76d5
Showing 1 changed file with 44 additions and 37 deletions.
81 changes: 44 additions & 37 deletions tool/create_packet_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,41 104,48 @@ def handleHexPacket(fout, timestamp, type, text):
with open (outfile, 'wb') as fout:
with open (infile, 'rt') as fin:
packet_counter = 0
line_conter = 0
for line in fin:
timestamp = None
# strip newlines
line = line.strip("\n\r")
# skip empyt lines
if len(line) == 0:
continue
parts = re.match('\[(.*)\] (.*)', line)
if parts and len(parts.groups()) == 2:
(timestamp, line) = parts.groups()
rest = chop(line,'CMD => ')
if rest:
handleHexPacket(fout, timestamp, 0, rest)
continue
rest = chop(line,'EVT <= ')
if rest:
handleHexPacket(fout, timestamp, 1, rest)
continue
rest = chop(line,'ACL => ')
if rest:
handleHexPacket(fout, timestamp, 2, rest)
continue
rest = chop(line,'ACL <= ')
if rest:
handleHexPacket(fout, timestamp, 3, rest)
continue
rest = chop(line,'SCO => ')
if rest:
handleHexPacket(fout, timestamp, 8, rest)
continue
rest = chop(line,'SCO <= ')
if rest:
handleHexPacket(fout, timestamp, 9, rest)
continue
rest = chop(line,'LOG -- ')
if rest:
line = rest
dumpPacket(fout, timestamp, 0xfc, line.encode('ascii'))
try:
line_conter = 1
timestamp = None
# strip newlines
line = line.strip("\n\r")
# skip empyt lines
if len(line) == 0:
continue
parts = re.match('\[(.*)\] (.*)', line)
if parts and len(parts.groups()) == 2:
(timestamp, line) = parts.groups()
rest = chop(line,'CMD => ')
if rest:
handleHexPacket(fout, timestamp, 0, rest)
continue
rest = chop(line,'EVT <= ')
if rest:
handleHexPacket(fout, timestamp, 1, rest)
continue
rest = chop(line,'ACL => ')
if rest:
handleHexPacket(fout, timestamp, 2, rest)
continue
rest = chop(line,'ACL <= ')
if rest:
handleHexPacket(fout, timestamp, 3, rest)
continue
rest = chop(line,'SCO => ')
if rest:
handleHexPacket(fout, timestamp, 8, rest)
continue
rest = chop(line,'SCO <= ')
if rest:
handleHexPacket(fout, timestamp, 9, rest)
continue
rest = chop(line,'LOG -- ')
if rest:
line = rest
dumpPacket(fout, timestamp, 0xfc, line.encode('ascii'))
except:
print("Error in line %u: '%s'" % (line_conter, line))

print("\nPacket Log: %s" % outfile)

0 comments on commit 9aa76d5

Please sign in to comment.