kopia lustrzana https://github.com/rs1729/RS
C34 Fletcher16
rodzic
25fccbd4df
commit
b47193868d
11
c34/c34.txt
11
c34/c34.txt
|
@ -13,9 +13,8 @@ Datenpaket besteht aus 8 byte:
|
||||||
header 2 byte 00FF
|
header 2 byte 00FF
|
||||||
pck_id 1 byte N
|
pck_id 1 byte N
|
||||||
data 4 byte val (big endian)
|
data 4 byte val (big endian)
|
||||||
chksum 2 byte Summe ueber byte[0]=pck_id,byte[1]=data[0],...,byte[4]=data[3]
|
chksum 2 byte Fletcher16 (hier: byte2 1's-complement am Ende)
|
||||||
byte1: (sum_i byte[i]) & 0xFF
|
|
||||||
byte2: (-1 - sum_i byte[i]*(5-i)) & 0xFF = ~(sum_i byte[i]*(5-i)) & 0xFF
|
|
||||||
|
|
||||||
Telemetrie pck_id N:
|
Telemetrie pck_id N:
|
||||||
0x14: date: 0x00027173 = 160115 -> 2015-01-16
|
0x14: date: 0x00027173 = 160115 -> 2015-01-16
|
||||||
|
@ -29,7 +28,7 @@ GPS-lat/lon wie NMEA mit Faktor 1e4
|
||||||
|
|
||||||
|
|
||||||
Checksum:
|
Checksum:
|
||||||
2 byte
|
2 byte, Summe ueber byte[0]=pck_id,byte[1]=data[0],...,byte[4]=data[3]
|
||||||
byte1: (sum_i byte[i]) & 0xFF
|
byte1: (sum_i byte[i]) & 0xFF
|
||||||
byte2: (-1 - sum_i byte[i]*(5-i)) & 0xFF = ~(sum_i byte[i]*(5-i)) & 0xFF
|
byte2: (-1 - sum_i byte[i]*(5-i)) & 0xFF = ~(sum_i byte[i]*(5-i)) & 0xFF
|
||||||
|
|
||||||
|
@ -44,6 +43,10 @@ FrameID 0x15 (time):
|
||||||
00FF 15 0001E605 01C2
|
00FF 15 0001E605 01C2
|
||||||
00FF 15 0001E606 02C1
|
00FF 15 0001E606 02C1
|
||||||
|
|
||||||
|
-> Fletcher16:
|
||||||
|
5*byte[0]+4*byte[1]+3*byte[2]+2*byte[3]+1*byte[4]
|
||||||
|
= byte[0] + (byte[0]+byte[1]) + (byte[0]+byte[1]+byte[2]) + (byte[0]+byte[1]+byte[2]+byte[3]) + (byte[0]+byte[1]+byte[2]+byte[3]+byte[4])
|
||||||
|
|
||||||
|
|
||||||
PTU-Data: float32?
|
PTU-Data: float32?
|
||||||
|
|
||||||
|
|
14
c34/c34dft.c
14
c34/c34dft.c
|
@ -306,6 +306,7 @@ void printGPX() {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Chechsum Fletcher16
|
||||||
unsigned check2(ui8_t *bytes, int len) {
|
unsigned check2(ui8_t *bytes, int len) {
|
||||||
int sum1, sum2;
|
int sum1, sum2;
|
||||||
int i;
|
int i;
|
||||||
|
@ -321,6 +322,19 @@ unsigned check2(ui8_t *bytes, int len) {
|
||||||
|
|
||||||
return sum2 | (sum1<<8);
|
return sum2 | (sum1<<8);
|
||||||
}
|
}
|
||||||
|
/* // equivalent
|
||||||
|
unsigned check16(ui8_t *bytes, int len) {
|
||||||
|
unsigned sum1, sum2;
|
||||||
|
int i;
|
||||||
|
sum1 = sum2 = 0;
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
sum1 = (sum1 + bytes[i]) % 0x100;
|
||||||
|
sum2 = (sum2 + sum1) % 0x100;
|
||||||
|
}
|
||||||
|
sum2 = (~sum2) & 0xFF; // 1's complement
|
||||||
|
return sum2 | (sum1<<8);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
double NMEAll(int ll) { // NMEA GGA,GLL: ll/1e4=(D)DDMM.mmmm
|
double NMEAll(int ll) { // NMEA GGA,GLL: ll/1e4=(D)DDMM.mmmm
|
||||||
int deg = ll / 1000000;
|
int deg = ll / 1000000;
|
||||||
|
|
Ładowanie…
Reference in New Issue