This commit is contained in:
Sofiene Beji 2024-04-28 15:58:59 -04:00 committed by GitHub
commit a9054c927d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 3 deletions

View File

@ -153,6 +153,19 @@ gps_l1_ca_telemetry_decoder_gs::~gps_l1_ca_telemetry_decoder_gs()
{
DLOG(INFO) << "GPS L1 C/A Telemetry decoder block (channel " << d_channel << ") destructor called.";
size_t pos = 0;
if( subframe_data_file.is_open())
{
try
{
subframe_data_file.close();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "*** Exception in destructor closing the subframe file " << ex.what();
}
}
if (d_dump_file.is_open() == true)
{
pos = d_dump_file.tellp();
@ -228,6 +241,20 @@ void gps_l1_ca_telemetry_decoder_gs::set_channel(int32_t channel)
d_nav.set_channel(channel);
DLOG(INFO) << "Navigation channel set to " << channel;
// ############# ENABLE DATA FILE LOG #################
if( subframe_data_file.is_open()==false)
{
try
{
std::string file_name = subframe_file_prefix+std::to_string(channel)+std::string(".csv");
subframe_data_file.open(file_name.data());
}
catch(const std::ofstream::failure &e)
{
std::cerr << "*** Fail to open subframe file for channel "+ channel << "\n"
<< e.what() << "\n";
}
}
if (d_dump == true)
{
if (d_dump_file.is_open() == false)
@ -349,7 +376,7 @@ bool gps_l1_ca_telemetry_decoder_gs::decode_subframe(double cn0, bool flag_inver
}
d_nav_msg_packet.nav_message = subframe_bits.to_string();
}
const int32_t subframe_ID = d_nav.subframe_decoder(subframe.data()); // decode the subframe
const int32_t subframe_ID = d_nav.subframe_decoder(subframe.data(),&subframe_data_file); // decode the subframe
if (subframe_ID > 0 && subframe_ID < 6)
{
switch (subframe_ID)

View File

@ -89,6 +89,9 @@ private:
std::string d_dump_filename;
std::ofstream d_dump_file;
std::ofstream subframe_data_file;
std::string subframe_file_prefix = "./RawNavMessagesChannel-";
boost::circular_buffer<float> d_symbol_history;
uint64_t d_sample_counter;

View File

@ -24,6 +24,8 @@
#include <iostream> // for operator<<, cout
#include <limits> // for std::numeric_limits
#include <fstream>
Gps_Navigation_Message::Gps_Navigation_Message()
{
@ -78,7 +80,7 @@ int64_t Gps_Navigation_Message::read_navigation_signed(const std::bitset<GPS_SUB
}
int32_t Gps_Navigation_Message::subframe_decoder(const char* subframe)
int32_t Gps_Navigation_Message::subframe_decoder(const char* subframe, std::ofstream* subframe_writer)
{
uint32_t gps_word;
@ -97,6 +99,12 @@ int32_t Gps_Navigation_Message::subframe_decoder(const char* subframe)
const auto subframe_ID = static_cast<int32_t>(read_navigation_unsigned(subframe_bits, SUBFRAME_ID));
if(subframe_writer!=nullptr)
{
*subframe_writer << subframe_ID << ",";
*subframe_writer << subframe_bits << "\n";
}
// Decode all 5 sub-frames
switch (subframe_ID)
{

View File

@ -68,7 +68,7 @@ public:
/*!
* \brief Decodes the GPS NAV message
*/
int32_t subframe_decoder(const char* subframe);
int32_t subframe_decoder(const char* subframe, std::ofstream* subframe_writer=nullptr);
/*!
* \brief Computes the Coordinated Universal Time (UTC) and