24 size_t& out_minimum_rx_buf_to_decide)
27 static uint32_t num_leap_seconds =
28 getenv(
"MRPT_HWDRIVERS_DEFAULT_LEAP_SECONDS") ==
nullptr 30 : atoi(getenv(
"MRPT_HWDRIVERS_DEFAULT_LEAP_SECONDS"));
36 const size_t nBytesAval = m_rx_buffer.size();
37 if (nBytesAval < out_minimum_rx_buf_to_decide)
41 uint8_t peek_buffer[3];
42 m_rx_buffer.peek_many(&peek_buffer[0], 3);
45 const bool is_short_hdr =
46 peek_buffer[0] == nv_oem6_short_header_t::SYNCH0 &&
47 peek_buffer[1] == nv_oem6_short_header_t::SYNCH1 &&
48 peek_buffer[2] == nv_oem6_short_header_t::SYNCH2;
50 const bool is_regular_hdr = peek_buffer[0] == nv_oem6_header_t::SYNCH0 &&
51 peek_buffer[1] == nv_oem6_header_t::SYNCH1 &&
52 peek_buffer[2] == nv_oem6_header_t::SYNCH2;
54 if (!is_short_hdr && !is_regular_hdr)
65 m_rx_buffer.peek_many(reinterpret_cast<uint8_t*>(&hdr),
sizeof(hdr));
67 const uint32_t expected_total_msg_len =
69 if (nBytesAval < expected_total_msg_len)
71 out_minimum_rx_buf_to_decide = expected_total_msg_len;
75 std::vector<uint8_t> buf(expected_total_msg_len);
76 m_rx_buffer.pop_many(reinterpret_cast<uint8_t*>(&buf[0]),
sizeof(hdr));
78 reinterpret_cast<uint8_t*>(&buf[
sizeof(hdr)]),
82 const uint32_t crc_computed =
84 const uint32_t crc_read = (buf[expected_total_msg_len - 1] << 24) |
85 (buf[expected_total_msg_len - 2] << 16) |
86 (buf[expected_total_msg_len - 3] << 8) |
87 (buf[expected_total_msg_len - 4] << 0);
88 if (crc_read != crc_computed)
93 const bool use_generic_container = !gnss_message::FactoryKnowsMsgType(
104 const uint32_t msg_id = use_generic_container
107 arch << (uint32_t)(msg_id);
109 arch << (uint32_t)(expected_total_msg_len);
110 arch.WriteBuffer(&buf[0], buf.size());
116 std::cerr <<
"[CGPSInterface::implement_parser_NOVATEL_OEM6] Error " 117 "parsing binary packet msg_id=" 121 m_just_parsed_messages.messages[msg->
message_type] = msg;
123 if (!CObservationGPS::GPS_time_to_UTC(
125 m_just_parsed_messages.timestamp))
128 m_just_parsed_messages.has_satellite_timestamp =
true;
132 flushParsedMessagesNow();
144 m_rx_buffer.peek_many(reinterpret_cast<uint8_t*>(&hdr),
sizeof(hdr));
146 const uint32_t expected_total_msg_len =
147 sizeof(hdr) + hdr.
msg_len + 4 ;
148 if (nBytesAval < expected_total_msg_len)
150 out_minimum_rx_buf_to_decide = expected_total_msg_len;
154 std::vector<uint8_t> buf(expected_total_msg_len);
155 m_rx_buffer.pop_many(reinterpret_cast<uint8_t*>(&buf[0]),
sizeof(hdr));
156 m_rx_buffer.pop_many(
157 reinterpret_cast<uint8_t*>(&buf[
sizeof(hdr)]),
161 const uint32_t crc_computed =
163 const uint32_t crc_read = (buf[expected_total_msg_len - 1] << 24) |
164 (buf[expected_total_msg_len - 2] << 16) |
165 (buf[expected_total_msg_len - 3] << 8) |
166 (buf[expected_total_msg_len - 4] << 0);
167 if (crc_read != crc_computed)
172 const bool use_generic_container = !gnss_message::FactoryKnowsMsgType(
183 const int32_t msg_id = use_generic_container
187 arch << (uint32_t)(expected_total_msg_len);
188 arch.WriteBuffer(&buf[0], buf.size());
194 std::cerr <<
"[CGPSInterface::implement_parser_NOVATEL_OEM6] Error " 195 "parsing binary packet msg_id=" 199 m_just_parsed_messages.messages[msg->
message_type] = msg;
205 dynamic_cast<const gnss::Message_NV_OEM6_IONUTC*
>(msg.
get());
206 if (ionutc) num_leap_seconds = ionutc->fields.deltat_ls;
208 if (!CObservationGPS::GPS_time_to_UTC(
210 m_just_parsed_messages.timestamp))
213 m_just_parsed_messages.has_satellite_timestamp =
true;
216 flushParsedMessagesNow();
gnss_message_type_t
List of all known GNSS message types.
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Contains classes for various device interfaces.
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream, std::istream, std::ostream, std::stringstream.
This CStream derived class allow using a memory buffer as a CStream.
uint32_t compute_CRC32(const std::vector< uint8_t > &data, const uint32_t gen_pol=0xEDB88320L)
Computes the CRC32 checksum of a block of data.
uint64_t Seek(int64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
Introduces a pure virtual method for moving to a specified position in the streamed resource...
This namespace contains representation of robot actions and observations.
bool implement_parser_NOVATEL_OEM6(size_t &out_minimum_rx_buf_to_decide)
gnss_message_type_t message_type
Type of GNSS message.
GNSS (GPS) data structures, mainly for use within mrpt::obs::CObservationGPS.
const std::string & getMessageTypeAsString() const
Returns "NMEA_GGA", etc.
A smart pointer to a GNSS message.