Skip to content

Commit

Permalink
Add runtime test for NMEA (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
waltjohnson authored Jan 8, 2025
1 parent 3b839fb commit b6c01d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions tests/runtime/device_runtime_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ void DeviceRuntimeTests::ProcessNMEA(const uint8_t* msg, int msgSize)
{
case NMEA_MSG_ID_GNGGA: TestNmeaGga(msg, msgSize); break;
case NMEA_MSG_ID_GNZDA: TestNmeaZda(msg, msgSize); break;
case NMEA_MSG_ID_INTEL: TestNmeaIntel(msg, msgSize); break;
}
}

Expand Down Expand Up @@ -176,6 +177,24 @@ void DeviceRuntimeTests::TestNmeaZda(const uint8_t* msg, int msgSize)
CheckGpsTime("NMEA ZDA Error", m_errorCount.nmeaZdaTime, hist);
}

/**
* @brief Test messages for duplicates, reversed order, or irregular timestamps.
*/
void DeviceRuntimeTests::TestNmeaIntel(const uint8_t* msg, int msgSize)
{
dev_info_t info;
gps_pos_t pos;
gps_vel_t vel;
float ppsPhase[2];
uint32_t ppsNoiseNs[1];
nmea_parse_intel((char*)msg, msgSize, info, pos, vel, ppsPhase, ppsNoiseNs);
std::deque<msg_history_t> &hist = AddMsgHistory(m_hist.nmea.intel, msg_history_t(&pos, (uint8_t*)msg, msgSize));

// WriteStatus("NMEA INTEL (%d ms): %.*s", gpsTowMs, msgSize, msg);

CheckGpsTime("NMEA INTEL Error", m_errorCount.nmeaZdaTime, hist);
}

std::string printfToString(const char* format, ...)
{
va_list args;
Expand Down
4 changes: 3 additions & 1 deletion tests/runtime/device_runtime_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class DeviceRuntimeTests
void TestIsbGps(const p_data_hdr_t &dataHdr, const uint8_t *dataBuf);
void TestNmeaGga(const uint8_t* msg, int msgSize);
void TestNmeaZda(const uint8_t* msg, int msgSize);
void TestNmeaIntel(const uint8_t* msg, int msgSize);
bool CheckGpsTime(const char* description, int &count, std::deque<msg_history_t> &hist);
bool CheckGpsTimeDuplicate(const char* description, int &count, std::deque<msg_history_t> &hist);
bool CheckGpsTimeReversed(const char* description, int &count, std::deque<msg_history_t> &hist);
Expand Down Expand Up @@ -143,8 +144,9 @@ class DeviceRuntimeTests

struct
{
std::deque<msg_history_t> zda;
std::deque<msg_history_t> gga;
std::deque<msg_history_t> intel;
std::deque<msg_history_t> zda;
} nmea;
} m_hist = {};

Expand Down

0 comments on commit b6c01d0

Please sign in to comment.