def __ubx_checksum(prefix_and_payload):
    """
    Calculates a UBX binary packet checksum.
    Algorithm comes from the u-blox M8 Receiver Description manual section "UBX Checksum"
    This is an implementation of the 8-Bit Fletcher Algorithm,
        so there may be a standard library for this.
    """
    checksum_a = 0
    checksum_b = 0
    for byte in prefix_and_payload:
        checksum_a = checksum_a + byte
        checksum_b = checksum_a + checksum_b
    checksum_a %= 256
    checksum_b %= 256
    return bytearray((checksum_a, checksum_b))