mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-12 10:20:32 +00:00
GPS CNAV telemetry page decoder is finally working!
This commit is contained in:
parent
4fe35f760b
commit
f56348d2d7
@ -180,7 +180,7 @@ int gps_l2_m_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_in
|
||||
|
||||
// verify checksum
|
||||
// and return the valid messages
|
||||
std::vector<msg_candiate_char_t> valid_msgs;
|
||||
std::vector<msg_candiate_int_t> valid_msgs;
|
||||
d_crc_verifier.get_valid_frames(msg_candidates, valid_msgs);
|
||||
if (valid_msgs.size()==0)
|
||||
{
|
||||
@ -193,7 +193,14 @@ int gps_l2_m_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_in
|
||||
}
|
||||
}else{ //at least one frame has good CRC, keep the invert sign for the next frames
|
||||
d_flag_invert_input_symbols=d_flag_invert_buffer_symbols;
|
||||
std::vector<int> tmp_msg;
|
||||
std::string msg;
|
||||
LOG(INFO)<<valid_msgs.size()<<" GOOD L2C CNAV FRAME DETECTED!";
|
||||
for (int i=0;i<valid_msgs.size();i++)
|
||||
{
|
||||
tmp_msg =valid_msgs.at(i).second;
|
||||
d_CNAV_Message.decode_page(tmp_msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -411,9 +418,9 @@ void gps_l2_m_telemetry_decoder_cc::crc_verifier::reset()
|
||||
|
||||
}
|
||||
|
||||
void gps_l2_m_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vector<msg_candiate_int_t> msg_candidates, std::vector<msg_candiate_char_t> &valid_msgs)
|
||||
void gps_l2_m_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vector<msg_candiate_int_t> msg_candidates, std::vector<msg_candiate_int_t> &valid_msgs)
|
||||
{
|
||||
std::stringstream ss;
|
||||
std::vector <unsigned char> tmp_msg;
|
||||
LOG(INFO) << "get_valid_frames(): " << "msg_candidates.size()=" << msg_candidates.size();
|
||||
// for each candidate
|
||||
for (std::vector<msg_candiate_int_t>::const_iterator candidate_it = msg_candidates.begin(); candidate_it < msg_candidates.end(); ++candidate_it)
|
||||
@ -430,19 +437,9 @@ void gps_l2_m_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::ve
|
||||
// the final remainder must be zero for a valid message, because the CRC is done over the received CRC value
|
||||
if (crc == 0)
|
||||
{
|
||||
valid_msgs.push_back(msg_candiate_char_t(candidate_it->first, candidate_bytes));
|
||||
ss << "Valid message found!";
|
||||
valid_msgs.push_back(msg_candiate_int_t(candidate_it->first, candidate_it->second));
|
||||
std::cout << "Valid CNAV message found!"<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << "Not a valid message.";
|
||||
}
|
||||
//ss << " Relbitoffset=" << candidate_it->first << " content=";
|
||||
for (std::vector<unsigned char>::iterator byte_it = candidate_bytes.begin(); byte_it < candidate_bytes.end(); ++byte_it)
|
||||
{
|
||||
ss << std::setw(2) << std::setfill('0') << std::hex << (unsigned int)(*byte_it);
|
||||
}
|
||||
LOG(INFO) << ss.str() << std::setfill(' ') << std::resetiosflags(std::ios::hex) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,9 +467,9 @@ void gps_l2_m_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_b
|
||||
}
|
||||
}
|
||||
bytes.push_back(byte); // implies: insert 6 zeros at the end to fit the 250bits into a multiple of bytes
|
||||
LOG(INFO) << " -> byte=" << std::setw(2)
|
||||
<< std::setfill('0') << std::hex << (unsigned int)byte
|
||||
<< std::setfill(' ') << std::resetiosflags(std::ios::hex);
|
||||
//LOG(INFO) << " -> byte=" << std::setw(2)
|
||||
// << std::setfill('0') << std::hex << (unsigned int)byte
|
||||
// << std::setfill(' ') << std::resetiosflags(std::ios::hex);
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include "gnss_satellite.h"
|
||||
#include "viterbi_decoder.h"
|
||||
//#include "sbas_telemetry_data.h"
|
||||
#include "gps_cnav_navigation_message.h"
|
||||
|
||||
class gps_l2_m_telemetry_decoder_cc;
|
||||
|
||||
@ -146,7 +146,7 @@ private:
|
||||
{
|
||||
public:
|
||||
void reset();
|
||||
void get_valid_frames(const std::vector<msg_candiate_int_t> msg_candidates, std::vector<msg_candiate_char_t> &valid_msgs);
|
||||
void get_valid_frames(const std::vector<msg_candiate_int_t> msg_candidates, std::vector<msg_candiate_int_t> &valid_msgs);
|
||||
private:
|
||||
typedef boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> crc_24_q_type;
|
||||
crc_24_q_type d_checksum_agent;
|
||||
@ -155,7 +155,7 @@ private:
|
||||
} d_crc_verifier;
|
||||
|
||||
|
||||
//Sbas_Telemetry_Data sbas_telemetry_data;
|
||||
Gps_CNAV_Navigation_Message d_CNAV_Message;
|
||||
};
|
||||
|
||||
|
||||
|
@ -97,11 +97,13 @@ const int32_t GPS_L2C_M_INIT_REG[115] =
|
||||
#define GPS_CNAV_PREAMBLE {1, 0, 0, 0, 1, 0, 1, 1}
|
||||
|
||||
const int GPS_L2_CNAV_DATA_PAGE_BITS = 300; //!< GPS L2 CNAV page length, including preamble and CRC [bits]
|
||||
const int GPS_L2_CNAV_DATA_PAGE_BITS_EXTENDED_BYTES = 304; //!< GPS L2 CNAV page length, including preamble and CRC [bits]
|
||||
|
||||
// common to all messages
|
||||
const std::vector<std::pair<int,int> > CNAV_PRN( { {9,6} } );
|
||||
const std::vector<std::pair<int,int> > CNAV_MSG_TYPE( { {15,6} } );
|
||||
const std::vector<std::pair<int,int> > CNAV_TOW( { {21,17} } );
|
||||
const std::vector<std::pair<int,int> > CNAV_TOW( { {21,17} } ); //GPS Time Of Week in seconds
|
||||
const double CNAV_TOW_LSB = 6.0;
|
||||
const std::vector<std::pair<int,int> > CNAV_ALERT_FLAG( { {38,1} } );
|
||||
|
||||
// MESSAGE TYPE 10 (Ephemeris 1)
|
||||
@ -109,11 +111,11 @@ const std::vector<std::pair<int,int> > CNAV_ALERT_FLAG( { {38,1} } );
|
||||
const std::vector<std::pair<int,int> > CNAV_WN({{39,13}});
|
||||
const std::vector<std::pair<int,int> > CNAV_HEALTH({{52,3}});
|
||||
const std::vector<std::pair<int,int> > CNAV_TOP1({{55,11}});
|
||||
const double CNAV_TOP1_LSB = 300;
|
||||
const double CNAV_TOP1_LSB = 300.0;
|
||||
const std::vector<std::pair<int,int> > CNAV_URA({{66,5}});
|
||||
|
||||
const std::vector<std::pair<int,int> > CNAV_TOE1({{71,11}});
|
||||
const double CNAV_TOE1_LSB = 300;
|
||||
const double CNAV_TOE1_LSB = 300.0;
|
||||
|
||||
const std::vector<std::pair<int,int> > CNAV_DELTA_A({{82,26}}); //Relative to AREF = 26,559,710 meters
|
||||
const double CNAV_DELTA_A_LSB = TWO_N9;
|
||||
@ -137,7 +139,7 @@ const std::vector<std::pair<int,int> > CNAV_L2_PHASING_FLAG({{273,1}});
|
||||
// MESSAGE TYPE 11 (Ephemeris 2)
|
||||
|
||||
const std::vector<std::pair<int,int> > CNAV_TOE2({{39,11}});
|
||||
const double CNAV_TOE2_LSB = 300;
|
||||
const double CNAV_TOE2_LSB = 300.0;
|
||||
const std::vector<std::pair<int,int> > CNAV_OMEGA0({{50,33}});
|
||||
const double CNAV_OMEGA0_LSB = TWO_N32;
|
||||
const std::vector<std::pair<int,int> > CNAV_I0({{83,33}});
|
||||
@ -163,13 +165,13 @@ const double CNAV_CUC_LSB = TWO_N30;
|
||||
// MESSAGE TYPE 30 (CLOCK, IONO, GRUP DELAY)
|
||||
|
||||
const std::vector<std::pair<int,int> > CNAV_TOP2({{39,11}});
|
||||
const double CNAV_TOP2_LSB = 300;
|
||||
const double CNAV_TOP2_LSB = 300.0;
|
||||
|
||||
const std::vector<std::pair<int,int> > CNAV_URA_NED0({{50,5}});
|
||||
const std::vector<std::pair<int,int> > CNAV_URA_NED1({{55,3}});
|
||||
const std::vector<std::pair<int,int> > CNAV_URA_NED2({{58,3}});
|
||||
const std::vector<std::pair<int,int> > CNAV_TOC({{61,11}});
|
||||
const double CNAV_TOC_LSB = 300;
|
||||
const double CNAV_TOC_LSB = 300.0;
|
||||
const std::vector<std::pair<int,int> > CNAV_AF0({{72,26}});
|
||||
const double CNAV_AF0_LSB = TWO_N60;
|
||||
const std::vector<std::pair<int,int> > CNAV_AF1({{98,20}});
|
||||
|
@ -167,9 +167,33 @@ signed long int Gps_CNAV_Navigation_Message::read_navigation_signed(std::bitset<
|
||||
}
|
||||
|
||||
|
||||
void Gps_CNAV_Navigation_Message::decode_page(std::string data)
|
||||
void Gps_CNAV_Navigation_Message::decode_page(std::vector<int> data)
|
||||
{
|
||||
std::bitset<GPS_L2_CNAV_DATA_PAGE_BITS> data_bits(data);
|
||||
std::bitset<GPS_L2_CNAV_DATA_PAGE_BITS> data_bits;
|
||||
|
||||
try {
|
||||
|
||||
// std::cout<<"data length="<<data.size()<<std::endl;
|
||||
// std::cout<<"data=";
|
||||
// for (int p=0;p<data.size();p++)
|
||||
// {
|
||||
// std::cout<<data.at(p)<<",";
|
||||
// }
|
||||
// std::cout<<std::endl;
|
||||
|
||||
for(int i=0;i<GPS_L2_CNAV_DATA_PAGE_BITS;i++)
|
||||
{
|
||||
//std::cout<<"byte["<<i<<"]="<<(int)data[i]<<std::endl;
|
||||
data_bits[i]=(uint8_t)data[GPS_L2_CNAV_DATA_PAGE_BITS-i-1];
|
||||
|
||||
}
|
||||
//std::cout<<"bitset="<<data_bits<<std::endl;
|
||||
// try {
|
||||
// data_bits=std::bitset<GPS_L2_CNAV_DATA_PAGE_BITS>(data);
|
||||
} catch(std::exception &e) {
|
||||
std::cout << "Exception converting to bitset " << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
int PRN;
|
||||
int page_type;
|
||||
@ -179,9 +203,11 @@ void Gps_CNAV_Navigation_Message::decode_page(std::string data)
|
||||
// common to all messages
|
||||
PRN = static_cast<int>(read_navigation_unsigned(data_bits, CNAV_PRN));
|
||||
TOW = static_cast<double>(read_navigation_unsigned(data_bits, CNAV_TOW));
|
||||
TOW=TOW*CNAV_TOW_LSB;
|
||||
alert_flag= static_cast<bool>(read_navigation_bool(data_bits, CNAV_ALERT_FLAG));
|
||||
page_type = static_cast<int>(read_navigation_unsigned(data_bits, CNAV_MSG_TYPE));
|
||||
|
||||
std::cout<<"PRN= "<<PRN<<" TOW="<<TOW<<" alert_flag= "<<alert_flag<<" page_type= "<<page_type<<std::endl;
|
||||
switch(page_type)
|
||||
{
|
||||
case 10: // Ephemeris 1/2
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <bitset>
|
||||
#include "stdint.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
@ -91,7 +92,7 @@ public:
|
||||
// public functions
|
||||
void reset();
|
||||
|
||||
void decode_page(std::string data);
|
||||
void decode_page(std::vector<int> data);
|
||||
/*!
|
||||
* \brief Obtain a GPS SV Ephemeris class filled with current SV data
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user