Skip to content

Commit

Permalink
Merge pull request mavlink#171 from thomasgubler/dfreader
Browse files Browse the repository at this point in the history
make dfreader more robust against corrupt log files
  • Loading branch information
LorenzMeier committed Feb 23, 2014
2 parents 1311db7 + 90837ca commit 7f39df8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pymavlink/DFReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,14 @@ 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):
# 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 7f39df8

Please sign in to comment.