Exemplo n.º 1
0
END_TEST


START_TEST (test_nmea_checksum_check)
{
    uint8_t err = nmea_valid_checksum("$GPRMC,174407.000,A,4504.2577,N,00738.7661,E,1.75,342.80,231113,,,A*6A");
    ck_assert_msg(err == _EMPTY, "Valid checksum computing fail");

    err = nmea_valid_checksum("$GPRMC,174407.000,A,4504.2577,N,00738.7661,E,1.75,342.80,231113,,,A*6B");
    ck_assert_msg(err == NMEA_CHECKSUM_ERR, "Invalid checksum computing fail");
}
Exemplo n.º 2
0
/**
 * Get the message type (GPGGA, GPRMC, etc..)
 *
 * This function filters out also wrong packages (invalid checksum)
 *
 * @param message The NMEA message
 * @return The type of message if it is valid
 */
nmea_message_type nmea_get_message_type(const char *message) {
	int checksum = nmea_valid_checksum(message);
	if (checksum != _EMPTY) {
		return checksum;
	}

	if (strstr(message, NMEA_GPGGA_STR) != NULL) {
		return NMEA_GPGGA;
	}

	if (strstr(message, NMEA_GPRMC_STR) != NULL) {
		return NMEA_GPRMC;
	}

	return NMEA_UNKNOWN;
}