mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-03 23:47:08 +00:00
tool/create_packet_log: report parsing error and continue
This commit is contained in:
parent
8c90079180
commit
9aa76d51a0
@ -104,41 +104,48 @@ if len(sys.argv) > 2:
|
|||||||
with open (outfile, 'wb') as fout:
|
with open (outfile, 'wb') as fout:
|
||||||
with open (infile, 'rt') as fin:
|
with open (infile, 'rt') as fin:
|
||||||
packet_counter = 0
|
packet_counter = 0
|
||||||
|
line_conter = 0
|
||||||
for line in fin:
|
for line in fin:
|
||||||
timestamp = None
|
try:
|
||||||
# strip newlines
|
line_conter += 1
|
||||||
line = line.strip("\n\r")
|
timestamp = None
|
||||||
# skip empyt lines
|
# strip newlines
|
||||||
if len(line) == 0:
|
line = line.strip("\n\r")
|
||||||
continue
|
# skip empyt lines
|
||||||
parts = re.match('\[(.*)\] (.*)', line)
|
if len(line) == 0:
|
||||||
if parts and len(parts.groups()) == 2:
|
continue
|
||||||
(timestamp, line) = parts.groups()
|
parts = re.match('\[(.*)\] (.*)', line)
|
||||||
rest = chop(line,'CMD => ')
|
if parts and len(parts.groups()) == 2:
|
||||||
if rest:
|
(timestamp, line) = parts.groups()
|
||||||
handleHexPacket(fout, timestamp, 0, rest)
|
rest = chop(line,'CMD => ')
|
||||||
continue
|
if rest:
|
||||||
rest = chop(line,'EVT <= ')
|
handleHexPacket(fout, timestamp, 0, rest)
|
||||||
if rest:
|
continue
|
||||||
handleHexPacket(fout, timestamp, 1, rest)
|
rest = chop(line,'EVT <= ')
|
||||||
continue
|
if rest:
|
||||||
rest = chop(line,'ACL => ')
|
handleHexPacket(fout, timestamp, 1, rest)
|
||||||
if rest:
|
continue
|
||||||
handleHexPacket(fout, timestamp, 2, rest)
|
rest = chop(line,'ACL => ')
|
||||||
continue
|
if rest:
|
||||||
rest = chop(line,'ACL <= ')
|
handleHexPacket(fout, timestamp, 2, rest)
|
||||||
if rest:
|
continue
|
||||||
handleHexPacket(fout, timestamp, 3, rest)
|
rest = chop(line,'ACL <= ')
|
||||||
continue
|
if rest:
|
||||||
rest = chop(line,'SCO => ')
|
handleHexPacket(fout, timestamp, 3, rest)
|
||||||
if rest:
|
continue
|
||||||
handleHexPacket(fout, timestamp, 8, rest)
|
rest = chop(line,'SCO => ')
|
||||||
continue
|
if rest:
|
||||||
rest = chop(line,'SCO <= ')
|
handleHexPacket(fout, timestamp, 8, rest)
|
||||||
if rest:
|
continue
|
||||||
handleHexPacket(fout, timestamp, 9, rest)
|
rest = chop(line,'SCO <= ')
|
||||||
continue
|
if rest:
|
||||||
rest = chop(line,'LOG -- ')
|
handleHexPacket(fout, timestamp, 9, rest)
|
||||||
if rest:
|
continue
|
||||||
line = rest
|
rest = chop(line,'LOG -- ')
|
||||||
dumpPacket(fout, timestamp, 0xfc, line.encode('ascii'))
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user