From 5a0cbc35a544f448e8db1e1578de7607b39a3e76 Mon Sep 17 00:00:00 2001 From: Kurt Nistelberger Date: Tue, 7 Feb 2023 18:49:51 -0700 Subject: [PATCH] Ubloxd: glonass ephem parsing (#27248) temp fix Co-authored-by: Kurt Nistelberger --- selfdrive/locationd/ublox_msg.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/selfdrive/locationd/ublox_msg.cc b/selfdrive/locationd/ublox_msg.cc index 877ace9a06..8fa721a091 100644 --- a/selfdrive/locationd/ublox_msg.cc +++ b/selfdrive/locationd/ublox_msg.cc @@ -359,9 +359,6 @@ kj::Array UbloxMsgParser::parse_glonass_ephemeris(ubx_t::rxm_sfrbx_ eph.setAge(data->e_n()); eph.setP4(data->p4()); eph.setSvURA(glonass_URA_lookup.at(data->f_t())); - if (msg->sv_id() != data->n()) { - LOGE("SV_ID != SLOT_NUMBER: %d %d", msg->sv_id(), data->n()) - } eph.setSvType(data->m()); } @@ -375,6 +372,13 @@ kj::Array UbloxMsgParser::parse_glonass_ephemeris(ubx_t::rxm_sfrbx_ // the year can be fetched later in laika (note rollovers and leap year) uint8_t n_4 = data->n_4(); uint16_t year = get_glonass_year(n_4, current_day); + if (current_day > 1461) { + // impossible day within last 4 year, reject ephemeris + // TODO: check if this can be detected via hamming code + LOGE("INVALID DATA: current day out of range: %d, %d", current_day, n_4); + glonass_strings[msg->sv_id()].clear(); + return kj::Array(); + } uint16_t last_leap_year = 1996 + 4*(n_4-1); uint16_t days_till_this_year = (year - last_leap_year)*365;