From bd68950bbb804cf4695087a6e9e0f43966f681e4 Mon Sep 17 00:00:00 2001 From: Shahar Rosenberg Date: Fri, 29 Mar 2019 16:52:57 +0300 Subject: [PATCH] add an option for ignoring wrong checksum --- pynmea2/nmea.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pynmea2/nmea.py b/pynmea2/nmea.py index b9f5f2e..479ea1c 100644 --- a/pynmea2/nmea.py +++ b/pynmea2/nmea.py @@ -87,7 +87,7 @@ def checksum(nmea_str): return reduce(operator.xor, map(ord, nmea_str), 0) @staticmethod - def parse(line, check=False): + def parse(line, check=False, ignore_wrong_checksum=False): ''' parse(line) @@ -111,7 +111,7 @@ def parse(line, check=False): if checksum: cs1 = int(checksum, 16) cs2 = NMEASentence.checksum(nmea_str) - if cs1 != cs2: + if cs1 != cs2 and not ignore_wrong_checksum: raise ChecksumError( 'checksum does not match: %02X != %02X' % (cs1, cs2), data) elif check: