    dev.configure_message_rate(ublox.CLASS_MON, ublox.MSG_MON_HW, 1)
    dev.configure_message_rate(ublox.CLASS_MON, ublox.MSG_MON_HW2, 1)
  
  
  if __name__ == "__main__":
    class Device:
      def write(self, s):
        d = '"{}"s'.format(''.join('\\x{:02X}'.format(b) for b in s))
 
</s> remove       struct tm sys_time = get_time();
 </s> add       struct tm sys_time = util::get_time(); </s> remove   struct tm sys_time;
  gmtime_r(&rawtime, &sys_time);

  return sys_time;
}

bool time_valid(struct tm sys_time){
  int year = 1900 + sys_time.tm_year;
  int month = 1 + sys_time.tm_mon;
  return (year > 2020) || (year == 2020 && month >= 10);
}
 </s> add  </s> remove     struct tm sys_time = get_time();
 </s> add     struct tm sys_time = util::get_time(); </s> remove     if (!time_valid(sys_time) && time_valid(rtc_time)) {
 </s> add     if (!util::time_valid(sys_time) && util::time_valid(rtc_time)) {
  print("send on stop:")

  # Save on shutdown
  # Controlled GNSS stop and hot start
  payload = struct.pack('<HBB', 0x0000, 0x08, 0x00)
  dev.send_message(ublox.CLASS_CFG, ublox.MSG_CFG_RST, payload)

  # UBX-UPD-SOS backup
  dev.send_message(0x09, 0x14, b"\x00\x00\x00\x00")

    dev.configure_message_rate(ublox.CLASS_MON, ublox.MSG_MON_HW, 1)
    dev.configure_message_rate(ublox.CLASS_MON, ublox.MSG_MON_HW2, 1)
  
  print("send on stop:")

  # Save on shutdown
  # Controlled GNSS stop and hot start
  payload = struct.pack('<HBB', 0x0000, 0x08, 0x00)
  dev.send_message(ublox.CLASS_CFG, ublox.MSG_CFG_RST, payload)

  # UBX-UPD-SOS backup
  dev.send_message(0x09, 0x14, b"\x00\x00\x00\x00")

  
  if __name__ == "__main__":
    class Device:
      def write(self, s):
        d = '"{}"s'.format(''.join('\\x{:02X}'.format(b) for b in s))
keep keep add keep keep keep keep keep
 Store almanac on ublox poweroff (#20967)

* Store almanac on ublox poweroff

* send current UTC time

* move message building to ublox_msg.h 
selfdrive/locationd/test/ubloxd.py