From 9af82c090e1bcb0d76b4c2468d538c75b6e9c650 Mon Sep 17 00:00:00 2001 From: Kurt Nistelberger Date: Tue, 7 Feb 2023 15:01:47 -0800 Subject: [PATCH] ublox_day_fix --- 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 3ff768ba06..33ac2fe088 100644 --- a/selfdrive/locationd/ublox_msg.cc +++ b/selfdrive/locationd/ublox_msg.cc @@ -358,9 +358,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()); } @@ -374,6 +371,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;