Ejemplo n.º 1
0
enum minmea_sentence_id minmea_sentence_id(const char *sentence, bool strict)
{
    if (!minmea_check(sentence, strict))
        return MINMEA_INVALID;

    char type[6];
    if (!minmea_scan(sentence, "t", type))
        return MINMEA_INVALID;

    if (!strcmp(type+2, "RMC"))
        return MINMEA_SENTENCE_RMC;
    if (!strcmp(type+2, "GGA"))
        return MINMEA_SENTENCE_GGA;
    if (!strcmp(type+2, "GSA"))
        return MINMEA_SENTENCE_GSA;
    if (!strcmp(type+2, "GLL"))
        return MINMEA_SENTENCE_GLL;
    if (!strcmp(type+2, "GST"))
        return MINMEA_SENTENCE_GST;
    if (!strcmp(type+2, "GSV"))
        return MINMEA_SENTENCE_GSV;
    if (!strcmp(type+2, "VTG"))
        return MINMEA_SENTENCE_VTG;

    return MINMEA_UNKNOWN;
}
Ejemplo n.º 2
0
END_TEST

START_TEST(test_minmea_parse_gpgga1)
{
    const char *sentence = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47";
    struct minmea_gpgga frame = {};
    struct minmea_gpgga expected = {
        .time = { 12, 35, 19, 0 },
        .latitude = 4807038,
        .latitude_scale = 1000,
        .longitude = 1131000,
        .longitude_scale = 1000,
        .fix_quality = 1,
        .satellites_tracked = 8,
        .hdop = 9,
        .hdop_scale = 10,
        .altitude = 5454,
        .altitude_scale = 10,
        .altitude_units = 'M',
        .height = 469,
        .height_scale = 10,
        .height_units = 'M',
        .dgps_age = 0,
    };
    ck_assert(minmea_check(sentence) == true);
    ck_assert(minmea_parse_gpgga(&frame, sentence) == true);
    ck_assert(!memcmp(&frame, &expected, sizeof(frame)));
}
Ejemplo n.º 3
0
END_TEST

START_TEST(test_minmea_parse_gprmc1)
{
    const char *sentence = "$GPRMC,081836.75,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E";
    struct minmea_gprmc frame = {};
    struct minmea_gprmc expected = {
        .time = { 8, 18, 36, 750000 },
        .valid = true,
        .latitude = -375165,
        .latitude_scale = 100,
        .longitude = 1450736,
        .longitude_scale = 100,
        .speed = 0,
        .speed_scale = 10,
        .course = 3600,
        .course_scale = 10,
        .date = { 13, 9, 98 },
        .variation = 113,
        .variation_scale = 10,
    };
    ck_assert(minmea_check(sentence) == true);
    ck_assert(minmea_parse_gprmc(&frame, sentence) == true);
    ck_assert(!memcmp(&frame, &expected, sizeof(frame)));
}
Ejemplo n.º 4
0
Archivo: tests.c Proyecto: eketh/minmea
END_TEST

START_TEST(test_minmea_parse_gst1)
{
    const char *sentence = "$GPGST,024603.00,3.2,6.6,4.7,47.3,5.8,5.6,22.0*58";
    struct minmea_sentence_gst frame = {};
    struct minmea_sentence_gst expected = {
        .time = { 2, 46, 3, 0 },
        .rms_deviation = 32,
        .rms_deviation_scale = 10,
        .semi_major_deviation = 66,
        .semi_major_deviation_scale = 10,
        .semi_minor_deviation = 47,
        .semi_minor_deviation_scale = 10,
        .semi_major_orientation = 473,
        .semi_major_orientation_scale = 10,
        .latitude_error_deviation = 58,
        .latitude_error_deviation_scale = 10,
        .longitude_error_deviation = 56,
        .longitude_error_deviation_scale = 10,
        .altitude_error_deviation = 220,
        .altitude_error_deviation_scale = 10,
    };
    ck_assert(minmea_check(sentence) == true);
    ck_assert(minmea_parse_gst(&frame, sentence) == true);
    ck_assert(!memcmp(&frame, &expected, sizeof(frame)));
}
Ejemplo n.º 5
0
END_TEST

START_TEST(test_minmea_parse_gprmc2)
{
    const char *sentence = "$GPRMC,,A,3751.65,N,14507.36,W,,,,,";
    struct minmea_gprmc frame = {};
    struct minmea_gprmc expected = {
        .time = { -1, -1, -1, -1 },
        .valid = true,
        .latitude = 375165,
        .latitude_scale = 100,
        .longitude = -1450736,
        .longitude_scale = 100,
        .date = { -1, -1, -1 },
    };
    ck_assert(minmea_check(sentence) == true);
    ck_assert(minmea_parse_gprmc(&frame, sentence) == true);
    ck_assert(!memcmp(&frame, &expected, sizeof(frame)));
}
Ejemplo n.º 6
0
Archivo: tests.c Proyecto: eketh/minmea
END_TEST

START_TEST(test_minmea_parse_gsa1)
{
    const char *sentence = "$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39";
    struct minmea_sentence_gsa frame = {};
    struct minmea_sentence_gsa expected = {
        .mode = MINMEA_GPGSA_MODE_AUTO,
        .fix_type = MINMEA_GPGSA_FIX_3D,
        .sats = { 4, 5, 0, 9, 12, 0, 0, 24, 0, 0, 0, 0 },
        .pdop = 25,
        .pdop_scale = 10,
        .hdop = 13,
        .hdop_scale = 10,
        .vdop = 21,
        .vdop_scale = 10
    };
    ck_assert(minmea_check(sentence) == true);
    ck_assert(minmea_parse_gsa(&frame, sentence) == true);
    ck_assert(!memcmp(&frame, &expected, sizeof(frame)));
}