23 size_t& out_minimum_rx_buf_to_decide)
27 getenv(
"MRPT_HWDRIVERS_DEFAULT_LEAP_SECONDS") ==
nullptr 29 : atoi(getenv(
"MRPT_HWDRIVERS_DEFAULT_LEAP_SECONDS"));
35 const size_t nBytesAval = m_rx_buffer.size();
36 if (nBytesAval < out_minimum_rx_buf_to_decide)
41 m_rx_buffer.peek_many(&peek_buffer[0], 3);
43 const bool is_short_hdr =
44 peek_buffer[0] == nv_oem6_short_header_t::SYNCH0 &&
45 peek_buffer[1] == nv_oem6_short_header_t::SYNCH1 &&
46 peek_buffer[2] == nv_oem6_short_header_t::SYNCH2;
48 const bool is_regular_hdr = peek_buffer[0] == nv_oem6_header_t::SYNCH0 &&
49 peek_buffer[1] == nv_oem6_header_t::SYNCH1 &&
50 peek_buffer[2] == nv_oem6_header_t::SYNCH2;
52 if (!is_short_hdr && !is_regular_hdr)
63 m_rx_buffer.peek_many(reinterpret_cast<uint8_t*>(&hdr),
sizeof(hdr));
64 const uint32_t expected_total_msg_len =
66 if (nBytesAval < expected_total_msg_len)
68 out_minimum_rx_buf_to_decide = expected_total_msg_len;
72 std::vector<uint8_t> buf(expected_total_msg_len);
73 m_rx_buffer.pop_many(reinterpret_cast<uint8_t*>(&buf[0]),
sizeof(hdr));
75 reinterpret_cast<uint8_t*>(&buf[
sizeof(hdr)]),
81 const uint32_t crc_read = (buf[expected_total_msg_len - 1] << 24) |
82 (buf[expected_total_msg_len - 2] << 16) |
83 (buf[expected_total_msg_len - 3] << 8) |
84 (buf[expected_total_msg_len - 4] << 0);
85 if (crc_read != crc_computed)
90 const bool use_generic_container = !gnss_message::FactoryKnowsMsgType(
100 const uint32_t msg_id = use_generic_container
105 expected_total_msg_len);
112 std::cerr <<
"[CGPSInterface::implement_parser_NOVATEL_OEM6] Error " 113 "parsing binary packet msg_id=" 117 m_just_parsed_messages.messages[msg->
message_type] = msg;
119 if (!CObservationGPS::GPS_time_to_UTC(
121 m_just_parsed_messages.timestamp))
124 m_just_parsed_messages.has_satellite_timestamp =
true;
128 flushParsedMessagesNow();
140 m_rx_buffer.peek_many(reinterpret_cast<uint8_t*>(&hdr),
sizeof(hdr));
141 const uint32_t expected_total_msg_len =
142 sizeof(hdr) + hdr.
msg_len + 4 ;
143 if (nBytesAval < expected_total_msg_len)
145 out_minimum_rx_buf_to_decide = expected_total_msg_len;
149 std::vector<uint8_t> buf(expected_total_msg_len);
150 m_rx_buffer.pop_many(reinterpret_cast<uint8_t*>(&buf[0]),
sizeof(hdr));
151 m_rx_buffer.pop_many(
152 reinterpret_cast<uint8_t*>(&buf[
sizeof(hdr)]),
158 const uint32_t crc_read = (buf[expected_total_msg_len - 1] << 24) |
159 (buf[expected_total_msg_len - 2] << 16) |
160 (buf[expected_total_msg_len - 3] << 8) |
161 (buf[expected_total_msg_len - 4] << 0);
162 if (crc_read != crc_computed)
167 const bool use_generic_container = !gnss_message::FactoryKnowsMsgType(
177 const int32_t msg_id = use_generic_container
181 tmpStream << (
uint32_t)(expected_total_msg_len);
188 std::cerr <<
"[CGPSInterface::implement_parser_NOVATEL_OEM6] Error " 189 "parsing binary packet msg_id=" 193 m_just_parsed_messages.messages[msg->
message_type] = msg;
198 const gnss::Message_NV_OEM6_IONUTC* ionutc =
199 dynamic_cast<const gnss::Message_NV_OEM6_IONUTC*
>(msg.
get());
200 if (ionutc) num_leap_seconds = ionutc->fields.deltat_ls;
202 if (!CObservationGPS::GPS_time_to_UTC(
204 m_just_parsed_messages.timestamp))
207 m_just_parsed_messages.has_satellite_timestamp =
true;
210 flushParsedMessagesNow();
uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
Introduces a pure virtual method for moving to a specified position in the streamed resource...
gnss_message_type_t
List of all known GNSS message types.
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Contains classes for various device interfaces.
This CStream derived class allow using a memory buffer as a CStream.
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.
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.
const std::string & getMessageTypeAsString() const
Returns "NMEA_GGA", etc.
unsigned __int32 uint32_t
A smart pointer to a GNSS message.