static int gps_chksum_ok ( const char * s ) { uint8_t chksum = 0; uint8_t chk; while (*s) { if (*s == '*') { int k; k = hex_get (s[1]); if (k < 0) return 0; chk = k << 4; k = hex_get (s[2]); if (k < 0) return 0; chk = chk | k; if (s[3] != 0) return 0; if (chk == chksum) return 1; return 0; } chksum = chksum ^ (*s); s++; } return 0; }
static int get_vector(FILE *file, uint8_t vec[]) { char buf[132 + 1]; char *s; int i; int value; while (fgets(buf, 133, file)) { s = buf; i = 0; while ((value = hex_get(s)) >= 0) { vec[i++] = value; s += 2; } return i; } return 0; }