Created
August 3, 2022 16:12
-
-
Save kristofgilicze/57e4cad4c5029f6faece20acc4fef735 to your computer and use it in GitHub Desktop.
Calculate NMEA checksum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_nmea_checksum(sentence: str) -> bool: | |
checksum = 0 | |
payload = sentence.raw.split("*")[0][1:] | |
for byte in payload: | |
checksum ^= ord(byte) | |
return checksum == sentence.checksum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment