Skip to content

Commit

Permalink
make dfreader more robust against corrupt log files
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasgubler committed Feb 18, 2014
1 parent 3e6e248 commit 12a64b2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pymavlink/DFReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,15 @@ def _parse_next(self):
return None

hdr = self.data[self.offset:self.offset+3]
if (ord(hdr[0]) != self.HEAD1 or ord(hdr[1]) != self.HEAD2):
return None
while (ord(hdr[0]) != self.HEAD1 or ord(hdr[1]) != self.HEAD2):
print "(message corrupt)"
# message corrupt, find next correct message
if (self.remaining >= 3):
self.offset += 1
self.remaining -= 1
hdr = self.data[self.offset:self.offset+3]
else:
return None
msg_type = ord(hdr[2])

self.offset += 3
Expand Down

0 comments on commit 12a64b2

Please sign in to comment.