예제 #1
0
파일: gps.c 프로젝트: st0ne/up4dar-os
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;
}
예제 #2
0
파일: g726_tests.c 프로젝트: vir/spandsp
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;
}