def ubx_checksum(packet_data):Usage:
ck_a = 0
ck_b = 0
for i in packet_data[2::]:
ck_a = (ck_a + i) & 0xff
ck_b = (ck_b + ck_a) &0xff
return (ck_a, ck_b)
packet_data = [0xB5, 0x62, 0x06, 0x04, 0x04, 0x00, 0x00, 0x00,0x08, 0x00]Result:
print "0x%x, 0x%x" % ubx_checksum(packet_data)
0x16, 0x74
Brak komentarzy:
Prześlij komentarz