mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-18 21:23:02 +00:00
Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into vtl_experimental
This commit is contained in:
commit
457e886ba2
@ -60,19 +60,8 @@ target_link_libraries(telemetry_decoder_gr_blocks
|
||||
PRIVATE
|
||||
Gflags::gflags
|
||||
Glog::glog
|
||||
Matio::matio
|
||||
)
|
||||
|
||||
if(FILESYSTEM_FOUND)
|
||||
target_compile_definitions(telemetry_decoder_gr_blocks PRIVATE -DHAS_STD_FILESYSTEM=1)
|
||||
if(find_experimental)
|
||||
target_compile_definitions(telemetry_decoder_gr_blocks PRIVATE -DHAS_STD_FILESYSTEM_EXPERIMENTAL=1)
|
||||
endif()
|
||||
target_link_libraries(telemetry_decoder_gr_blocks PRIVATE std::filesystem)
|
||||
else()
|
||||
target_link_libraries(telemetry_decoder_gr_blocks PRIVATE Boost::filesystem Boost::system)
|
||||
endif()
|
||||
|
||||
if(GNURADIO_USES_STD_POINTERS)
|
||||
target_compile_definitions(telemetry_decoder_gr_blocks
|
||||
PUBLIC -DGNURADIO_USES_STD_POINTERS=1
|
||||
|
@ -27,9 +27,9 @@
|
||||
#include "beidou_dnav_utc_model.h"
|
||||
#include "display.h"
|
||||
#include "gnss_synchro.h"
|
||||
#include "tlm_utils.h"
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <matio.h> // for Mat_VarCreate
|
||||
#include <pmt/pmt.h> // for make_any
|
||||
#include <pmt/pmt_sugar.h> // for mp
|
||||
#include <cstddef> // for size_t
|
||||
@ -37,28 +37,6 @@
|
||||
#include <exception> // for exception
|
||||
#include <iostream> // for cout
|
||||
#include <memory> // for shared_ptr, make_shared
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for remove
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#define CRC_ERROR_LIMIT 8
|
||||
|
||||
@ -85,6 +63,7 @@ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs(
|
||||
d_dump_filename = conf.dump_filename;
|
||||
d_dump = conf.dump;
|
||||
d_dump_mat = conf.dump_mat;
|
||||
d_remove_dat = conf.remove_dat;
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
LOG(INFO) << "Initializing BeiDou B1I Telemetry Decoding for satellite " << this->d_satellite;
|
||||
|
||||
@ -144,8 +123,7 @@ beidou_b1i_telemetry_decoder_gs::~beidou_b1i_telemetry_decoder_gs()
|
||||
}
|
||||
if (pos == 0)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
if (!fs::remove(fs::path(d_dump_filename), ec))
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
@ -153,116 +131,15 @@ beidou_b1i_telemetry_decoder_gs::~beidou_b1i_telemetry_decoder_gs()
|
||||
}
|
||||
if (d_dump && (pos != 0) && d_dump_mat)
|
||||
{
|
||||
try
|
||||
save_tlm_matfile(d_dump_filename);
|
||||
if (d_remove_dat)
|
||||
{
|
||||
save_matfile();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
LOG(WARNING) << "Error saving the .mat file: " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t beidou_b1i_telemetry_decoder_gs::save_matfile() const
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
const int32_t number_of_double_vars = 2;
|
||||
const int32_t number_of_int_vars = 2;
|
||||
const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
|
||||
sizeof(int32_t) * number_of_int_vars;
|
||||
std::ifstream dump_file;
|
||||
std::string dump_filename_ = d_dump_filename;
|
||||
|
||||
std::cout << "Generating .mat file for " << dump_filename_ << '\n';
|
||||
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
try
|
||||
{
|
||||
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem opening dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
// count number of epochs and rewind
|
||||
int64_t num_epoch = 0;
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
size = dump_file.tellg();
|
||||
num_epoch = static_cast<int64_t>(size) / static_cast<int64_t>(epoch_size_bytes);
|
||||
if (num_epoch == 0LL)
|
||||
{
|
||||
// empty file, exit
|
||||
return 1;
|
||||
}
|
||||
dump_file.seekg(0, std::ios::beg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
auto TOW_at_current_symbol_ms = std::vector<double>(num_epoch);
|
||||
auto tracking_sample_counter = std::vector<uint64_t>(num_epoch);
|
||||
auto TOW_at_Preamble_ms = std::vector<double>(num_epoch);
|
||||
auto nav_symbol = std::vector<int32_t>(num_epoch);
|
||||
auto prn = std::vector<int32_t>(num_epoch);
|
||||
|
||||
try
|
||||
{
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
for (int64_t i = 0; i < num_epoch; i++)
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&tracking_sample_counter[i]), sizeof(uint64_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_Preamble_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&nav_symbol[i]), sizeof(int32_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&prn[i]), sizeof(int32_t));
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
}
|
||||
dump_file.close();
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem reading dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WRITE MAT FILE
|
||||
mat_t *matfp;
|
||||
matvar_t *matvar;
|
||||
std::string filename = dump_filename_;
|
||||
filename.erase(filename.length() - 4, 4);
|
||||
filename.append(".mat");
|
||||
matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73);
|
||||
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
|
||||
{
|
||||
std::array<size_t, 2> dims{1, static_cast<size_t>(num_epoch)};
|
||||
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_current_symbol_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("tracking_sample_counter", MAT_C_UINT64, MAT_T_UINT64, 2, dims.data(), tracking_sample_counter.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("TOW_at_Preamble_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_Preamble_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("nav_symbol", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), nav_symbol.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("PRN", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), prn.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
}
|
||||
Mat_Close(matfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,8 +75,6 @@ private:
|
||||
|
||||
beidou_b1i_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
|
||||
|
||||
int32_t save_matfile() const;
|
||||
|
||||
void decode_subframe(float *symbols);
|
||||
void decode_word(int32_t word_counter, const float *enc_word_symbols, int32_t *dec_word_symbols);
|
||||
void decode_bch15_11_01(const int32_t *bits, std::array<int32_t, 15> &decbits);
|
||||
@ -123,6 +121,7 @@ private:
|
||||
bool Flag_valid_word;
|
||||
bool d_dump;
|
||||
bool d_dump_mat;
|
||||
bool d_remove_dat;
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,9 +26,9 @@
|
||||
#include "beidou_dnav_utc_model.h"
|
||||
#include "display.h"
|
||||
#include "gnss_synchro.h"
|
||||
#include "tlm_utils.h"
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <matio.h> // for Mat_VarCreate
|
||||
#include <pmt/pmt.h> // for make_any
|
||||
#include <pmt/pmt_sugar.h> // for mp
|
||||
#include <cstddef> // for size_t
|
||||
@ -36,28 +36,6 @@
|
||||
#include <exception> // for exception
|
||||
#include <iostream> // for cout
|
||||
#include <memory> // for shared_ptr, make_shared
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for remove
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#define CRC_ERROR_LIMIT 8
|
||||
|
||||
@ -85,6 +63,7 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs(
|
||||
d_dump_filename = conf.dump_filename;
|
||||
d_dump = conf.dump;
|
||||
d_dump_mat = conf.dump_mat;
|
||||
d_remove_dat = conf.remove_dat;
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
LOG(INFO) << "Initializing BeiDou B3I Telemetry Decoding for satellite " << this->d_satellite;
|
||||
|
||||
@ -144,8 +123,7 @@ beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs()
|
||||
}
|
||||
if (pos == 0)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
if (!fs::remove(fs::path(d_dump_filename), ec))
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
@ -153,116 +131,15 @@ beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs()
|
||||
}
|
||||
if (d_dump && (pos != 0) && d_dump_mat)
|
||||
{
|
||||
try
|
||||
save_tlm_matfile(d_dump_filename);
|
||||
if (d_remove_dat)
|
||||
{
|
||||
save_matfile();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
LOG(WARNING) << "Error saving the .mat file: " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t beidou_b3i_telemetry_decoder_gs::save_matfile() const
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
const int32_t number_of_double_vars = 2;
|
||||
const int32_t number_of_int_vars = 2;
|
||||
const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
|
||||
sizeof(int32_t) * number_of_int_vars;
|
||||
std::ifstream dump_file;
|
||||
std::string dump_filename_ = d_dump_filename;
|
||||
|
||||
std::cout << "Generating .mat file for " << dump_filename_ << '\n';
|
||||
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
try
|
||||
{
|
||||
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem opening dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
// count number of epochs and rewind
|
||||
int64_t num_epoch = 0;
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
size = dump_file.tellg();
|
||||
num_epoch = static_cast<int64_t>(size) / static_cast<int64_t>(epoch_size_bytes);
|
||||
if (num_epoch == 0LL)
|
||||
{
|
||||
// empty file, exit
|
||||
return 1;
|
||||
}
|
||||
dump_file.seekg(0, std::ios::beg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
auto TOW_at_current_symbol_ms = std::vector<double>(num_epoch);
|
||||
auto tracking_sample_counter = std::vector<uint64_t>(num_epoch);
|
||||
auto TOW_at_Preamble_ms = std::vector<double>(num_epoch);
|
||||
auto nav_symbol = std::vector<int32_t>(num_epoch);
|
||||
auto prn = std::vector<int32_t>(num_epoch);
|
||||
|
||||
try
|
||||
{
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
for (int64_t i = 0; i < num_epoch; i++)
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&tracking_sample_counter[i]), sizeof(uint64_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_Preamble_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&nav_symbol[i]), sizeof(int32_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&prn[i]), sizeof(int32_t));
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
}
|
||||
dump_file.close();
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem reading dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WRITE MAT FILE
|
||||
mat_t *matfp;
|
||||
matvar_t *matvar;
|
||||
std::string filename = dump_filename_;
|
||||
filename.erase(filename.length() - 4, 4);
|
||||
filename.append(".mat");
|
||||
matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73);
|
||||
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
|
||||
{
|
||||
std::array<size_t, 2> dims{1, static_cast<size_t>(num_epoch)};
|
||||
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_current_symbol_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("tracking_sample_counter", MAT_C_UINT64, MAT_T_UINT64, 2, dims.data(), tracking_sample_counter.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("TOW_at_Preamble_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_Preamble_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("nav_symbol", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), nav_symbol.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("PRN", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), prn.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
}
|
||||
Mat_Close(matfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,8 +73,6 @@ private:
|
||||
|
||||
beidou_b3i_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
|
||||
|
||||
int32_t save_matfile() const;
|
||||
|
||||
void decode_subframe(float *symbols);
|
||||
void decode_word(int32_t word_counter, const float *enc_word_symbols,
|
||||
int32_t *dec_word_symbols);
|
||||
@ -120,6 +118,7 @@ private:
|
||||
bool Flag_valid_word;
|
||||
bool d_dump;
|
||||
bool d_dump_mat;
|
||||
bool d_remove_dat;
|
||||
};
|
||||
|
||||
|
||||
|
@ -32,38 +32,18 @@
|
||||
#include "galileo_iono.h" // for Galileo_Iono
|
||||
#include "galileo_utc_model.h" // for Galileo_Utc_Model
|
||||
#include "gnss_synchro.h"
|
||||
#include "tlm_utils.h"
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <matio.h> // for Mat_VarCreate
|
||||
#include <pmt/pmt.h> // for make_any
|
||||
#include <pmt/pmt_sugar.h> // for mp
|
||||
#include <cmath> // for fmod
|
||||
#include <cstddef> // for size_t
|
||||
#include <cstdlib> // for abs
|
||||
#include <exception> // for exception
|
||||
#include <iostream> // for cout
|
||||
#include <memory> // for make_shared
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for remove
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
#include <array>
|
||||
#include <cmath> // for fmod
|
||||
#include <cstddef> // for size_t
|
||||
#include <cstdlib> // for abs
|
||||
#include <exception> // for exception
|
||||
#include <iostream> // for cout
|
||||
#include <memory> // for make_shared
|
||||
|
||||
#define CRC_ERROR_LIMIT 6
|
||||
|
||||
@ -95,6 +75,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
|
||||
d_dump_filename = conf.dump_filename;
|
||||
d_dump = conf.dump;
|
||||
d_dump_mat = conf.dump_mat;
|
||||
d_remove_dat = conf.remove_dat;
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
d_frame_type = frame_type;
|
||||
DLOG(INFO) << "Initializing GALILEO UNIFIED TELEMETRY DECODER";
|
||||
@ -252,8 +233,7 @@ galileo_telemetry_decoder_gs::~galileo_telemetry_decoder_gs()
|
||||
}
|
||||
if (pos == 0)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
if (!fs::remove(fs::path(d_dump_filename), ec))
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
@ -261,116 +241,15 @@ galileo_telemetry_decoder_gs::~galileo_telemetry_decoder_gs()
|
||||
}
|
||||
if (d_dump && (pos != 0) && d_dump_mat)
|
||||
{
|
||||
try
|
||||
save_tlm_matfile(d_dump_filename);
|
||||
if (d_remove_dat)
|
||||
{
|
||||
save_matfile();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
LOG(WARNING) << "Error saving the .mat file: " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t galileo_telemetry_decoder_gs::save_matfile() const
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
const int32_t number_of_double_vars = 2;
|
||||
const int32_t number_of_int_vars = 2;
|
||||
const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
|
||||
sizeof(int32_t) * number_of_int_vars;
|
||||
std::ifstream dump_file;
|
||||
std::string dump_filename_ = d_dump_filename;
|
||||
|
||||
std::cout << "Generating .mat file for " << dump_filename_ << '\n';
|
||||
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
try
|
||||
{
|
||||
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem opening dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
// count number of epochs and rewind
|
||||
int64_t num_epoch = 0;
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
size = dump_file.tellg();
|
||||
num_epoch = static_cast<int64_t>(size) / static_cast<int64_t>(epoch_size_bytes);
|
||||
if (num_epoch == 0LL)
|
||||
{
|
||||
// empty file, exit
|
||||
return 1;
|
||||
}
|
||||
dump_file.seekg(0, std::ios::beg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
auto TOW_at_current_symbol_ms = std::vector<double>(num_epoch);
|
||||
auto tracking_sample_counter = std::vector<uint64_t>(num_epoch);
|
||||
auto TOW_at_Preamble_ms = std::vector<double>(num_epoch);
|
||||
auto nav_symbol = std::vector<int32_t>(num_epoch);
|
||||
auto prn = std::vector<int32_t>(num_epoch);
|
||||
|
||||
try
|
||||
{
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
for (int64_t i = 0; i < num_epoch; i++)
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&tracking_sample_counter[i]), sizeof(uint64_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_Preamble_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&nav_symbol[i]), sizeof(int32_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&prn[i]), sizeof(int32_t));
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
}
|
||||
dump_file.close();
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem reading dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WRITE MAT FILE
|
||||
mat_t *matfp;
|
||||
matvar_t *matvar;
|
||||
std::string filename = dump_filename_;
|
||||
filename.erase(filename.length() - 4, 4);
|
||||
filename.append(".mat");
|
||||
matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73);
|
||||
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
|
||||
{
|
||||
std::array<size_t, 2> dims{1, static_cast<size_t>(num_epoch)};
|
||||
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_current_symbol_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("tracking_sample_counter", MAT_C_UINT64, MAT_T_UINT64, 2, dims.data(), tracking_sample_counter.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("TOW_at_Preamble_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_Preamble_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("nav_symbol", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), nav_symbol.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("PRN", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), prn.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
}
|
||||
Mat_Close(matfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <gnuradio/block.h> // for block
|
||||
#include <gnuradio/types.h> // for gr_vector_const_void_star
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
@ -83,8 +82,6 @@ private:
|
||||
const int32_t d_nn = 2; // Coding rate 1/n
|
||||
const int32_t d_KK = 7; // Constraint Length
|
||||
|
||||
int32_t save_matfile() const;
|
||||
|
||||
void viterbi_decoder(float *page_part_symbols, int32_t *page_part_bits);
|
||||
void deinterleaver(int32_t rows, int32_t cols, const float *in, float *out);
|
||||
void decode_INAV_word(float *page_part_symbols, int32_t frame_length);
|
||||
@ -144,6 +141,7 @@ private:
|
||||
bool d_flag_preamble;
|
||||
bool d_dump;
|
||||
bool d_dump_mat;
|
||||
bool d_remove_dat;
|
||||
};
|
||||
|
||||
|
||||
|
@ -23,9 +23,9 @@
|
||||
#include "glonass_gnav_almanac.h"
|
||||
#include "glonass_gnav_ephemeris.h"
|
||||
#include "glonass_gnav_utc_model.h"
|
||||
#include "tlm_utils.h"
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <matio.h> // for Mat_VarCreate
|
||||
#include <pmt/pmt.h> // for make_any
|
||||
#include <pmt/pmt_sugar.h> // for mp
|
||||
#include <cmath> // for floor, round
|
||||
@ -34,28 +34,6 @@
|
||||
#include <exception> // for exception
|
||||
#include <iostream> // for cout
|
||||
#include <memory> // for shared_ptr, make_shared
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for remove
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#define CRC_ERROR_LIMIT 6
|
||||
|
||||
@ -82,6 +60,7 @@ glonass_l1_ca_telemetry_decoder_gs::glonass_l1_ca_telemetry_decoder_gs(
|
||||
d_dump_filename = conf.dump_filename;
|
||||
d_dump = conf.dump;
|
||||
d_dump_mat = conf.dump_mat;
|
||||
d_remove_dat = conf.remove_dat;
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
LOG(INFO) << "Initializing GLONASS L1 CA TELEMETRY DECODING";
|
||||
|
||||
@ -137,125 +116,23 @@ glonass_l1_ca_telemetry_decoder_gs::~glonass_l1_ca_telemetry_decoder_gs()
|
||||
}
|
||||
if (pos == 0)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
if (!fs::remove(fs::path(d_dump_filename), ec))
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (d_dump && (pos != 0))
|
||||
if (d_dump && (pos != 0) && d_dump_mat)
|
||||
{
|
||||
try
|
||||
save_tlm_matfile(d_dump_filename);
|
||||
if (d_remove_dat)
|
||||
{
|
||||
save_matfile();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
LOG(WARNING) << "Error saving the .mat file: " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t glonass_l1_ca_telemetry_decoder_gs::save_matfile() const
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
const int32_t number_of_double_vars = 2;
|
||||
const int32_t number_of_int_vars = 2;
|
||||
const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
|
||||
sizeof(int32_t) * number_of_int_vars;
|
||||
std::ifstream dump_file;
|
||||
std::string dump_filename_ = d_dump_filename;
|
||||
|
||||
std::cout << "Generating .mat file for " << dump_filename_ << '\n';
|
||||
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
try
|
||||
{
|
||||
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem opening dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
// count number of epochs and rewind
|
||||
int64_t num_epoch = 0;
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
size = dump_file.tellg();
|
||||
num_epoch = static_cast<int64_t>(size) / static_cast<int64_t>(epoch_size_bytes);
|
||||
if (num_epoch == 0LL)
|
||||
{
|
||||
// empty file, exit
|
||||
return 1;
|
||||
}
|
||||
dump_file.seekg(0, std::ios::beg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
auto TOW_at_current_symbol_ms = std::vector<double>(num_epoch);
|
||||
auto tracking_sample_counter = std::vector<uint64_t>(num_epoch);
|
||||
auto TOW_at_Preamble_ms = std::vector<double>(num_epoch);
|
||||
auto nav_symbol = std::vector<int32_t>(num_epoch);
|
||||
auto prn = std::vector<int32_t>(num_epoch);
|
||||
|
||||
try
|
||||
{
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
for (int64_t i = 0; i < num_epoch; i++)
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&tracking_sample_counter[i]), sizeof(uint64_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_Preamble_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&nav_symbol[i]), sizeof(int32_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&prn[i]), sizeof(int32_t));
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
}
|
||||
dump_file.close();
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem reading dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WRITE MAT FILE
|
||||
mat_t *matfp;
|
||||
matvar_t *matvar;
|
||||
std::string filename = dump_filename_;
|
||||
filename.erase(filename.length() - 4, 4);
|
||||
filename.append(".mat");
|
||||
matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73);
|
||||
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
|
||||
{
|
||||
std::array<size_t, 2> dims{1, static_cast<size_t>(num_epoch)};
|
||||
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_current_symbol_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("tracking_sample_counter", MAT_C_UINT64, MAT_T_UINT64, 2, dims.data(), tracking_sample_counter.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("TOW_at_Preamble_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_Preamble_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("nav_symbol", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), nav_symbol.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("PRN", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), prn.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
}
|
||||
Mat_Close(matfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,8 +83,6 @@ private:
|
||||
|
||||
const int32_t d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS;
|
||||
|
||||
int32_t save_matfile() const;
|
||||
|
||||
void decode_string(const double *symbols, int32_t frame_length);
|
||||
|
||||
// Help with coherent tracking
|
||||
@ -122,6 +120,7 @@ private:
|
||||
bool Flag_valid_word;
|
||||
bool d_dump;
|
||||
bool d_dump_mat;
|
||||
bool d_remove_dat;
|
||||
};
|
||||
|
||||
|
||||
|
@ -23,9 +23,9 @@
|
||||
#include "glonass_gnav_almanac.h"
|
||||
#include "glonass_gnav_ephemeris.h"
|
||||
#include "glonass_gnav_utc_model.h"
|
||||
#include "tlm_utils.h"
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <matio.h> // for Mat_VarCreate
|
||||
#include <pmt/pmt.h> // for make_any
|
||||
#include <pmt/pmt_sugar.h> // for mp
|
||||
#include <cmath> // for floor, round
|
||||
@ -34,28 +34,6 @@
|
||||
#include <exception> // for exception
|
||||
#include <iostream> // for cout
|
||||
#include <memory> // for shared_ptr, make_shared
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for remove
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#define CRC_ERROR_LIMIT 6
|
||||
|
||||
@ -82,6 +60,7 @@ glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs(
|
||||
d_dump_filename = conf.dump_filename;
|
||||
d_dump = conf.dump;
|
||||
d_dump_mat = conf.dump_mat;
|
||||
d_remove_dat = conf.remove_dat;
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
LOG(INFO) << "Initializing GLONASS L2 CA TELEMETRY DECODING";
|
||||
|
||||
@ -137,8 +116,7 @@ glonass_l2_ca_telemetry_decoder_gs::~glonass_l2_ca_telemetry_decoder_gs()
|
||||
}
|
||||
if (pos == 0)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
if (!fs::remove(fs::path(d_dump_filename), ec))
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
@ -146,116 +124,15 @@ glonass_l2_ca_telemetry_decoder_gs::~glonass_l2_ca_telemetry_decoder_gs()
|
||||
}
|
||||
if (d_dump && (pos != 0) && d_dump_mat)
|
||||
{
|
||||
try
|
||||
save_tlm_matfile(d_dump_filename);
|
||||
if (d_remove_dat)
|
||||
{
|
||||
save_matfile();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
LOG(WARNING) << "Error saving the .mat file: " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t glonass_l2_ca_telemetry_decoder_gs::save_matfile() const
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
const int32_t number_of_double_vars = 2;
|
||||
const int32_t number_of_int_vars = 2;
|
||||
const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
|
||||
sizeof(int32_t) * number_of_int_vars;
|
||||
std::ifstream dump_file;
|
||||
std::string dump_filename_ = d_dump_filename;
|
||||
|
||||
std::cout << "Generating .mat file for " << dump_filename_ << '\n';
|
||||
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
try
|
||||
{
|
||||
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem opening dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
// count number of epochs and rewind
|
||||
int64_t num_epoch = 0;
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
size = dump_file.tellg();
|
||||
num_epoch = static_cast<int64_t>(size) / static_cast<int64_t>(epoch_size_bytes);
|
||||
if (num_epoch == 0LL)
|
||||
{
|
||||
// empty file, exit
|
||||
return 1;
|
||||
}
|
||||
dump_file.seekg(0, std::ios::beg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
auto TOW_at_current_symbol_ms = std::vector<double>(num_epoch);
|
||||
auto tracking_sample_counter = std::vector<uint64_t>(num_epoch);
|
||||
auto TOW_at_Preamble_ms = std::vector<double>(num_epoch);
|
||||
auto nav_symbol = std::vector<int32_t>(num_epoch);
|
||||
auto prn = std::vector<int32_t>(num_epoch);
|
||||
|
||||
try
|
||||
{
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
for (int64_t i = 0; i < num_epoch; i++)
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&tracking_sample_counter[i]), sizeof(uint64_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_Preamble_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&nav_symbol[i]), sizeof(int32_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&prn[i]), sizeof(int32_t));
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
}
|
||||
dump_file.close();
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem reading dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WRITE MAT FILE
|
||||
mat_t *matfp;
|
||||
matvar_t *matvar;
|
||||
std::string filename = dump_filename_;
|
||||
filename.erase(filename.length() - 4, 4);
|
||||
filename.append(".mat");
|
||||
matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73);
|
||||
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
|
||||
{
|
||||
std::array<size_t, 2> dims{1, static_cast<size_t>(num_epoch)};
|
||||
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_current_symbol_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("tracking_sample_counter", MAT_C_UINT64, MAT_T_UINT64, 2, dims.data(), tracking_sample_counter.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("TOW_at_Preamble_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_Preamble_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("nav_symbol", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), nav_symbol.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("PRN", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), prn.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
}
|
||||
Mat_Close(matfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,8 +81,6 @@ private:
|
||||
|
||||
const int32_t d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS;
|
||||
|
||||
int32_t save_matfile() const;
|
||||
|
||||
void decode_string(const double *symbols, int32_t frame_length);
|
||||
|
||||
// Storage for incoming data
|
||||
@ -116,6 +114,7 @@ private:
|
||||
bool flag_TOW_set; // Indicates when time of week is set
|
||||
bool d_dump;
|
||||
bool d_dump_mat;
|
||||
bool d_remove_dat;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,30 +1,30 @@
|
||||
/*!
|
||||
* \file gps_l1_ca_telemetry_decoder_gs.cc
|
||||
* \brief Implementation of a NAV message demodulator block based on
|
||||
* Kay Borre book MATLAB-based GPS receiver
|
||||
* \author Javier Arribas, 2011. jarribas(at)cttc.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
* \file gps_l1_ca_telemetry_decoder_gs.cc
|
||||
* \brief Implementation of a NAV message demodulator block based on
|
||||
* Kay Borre book MATLAB-based GPS receiver
|
||||
* \author Javier Arribas, 2011. jarribas(at)cttc.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "gps_l1_ca_telemetry_decoder_gs.h"
|
||||
#include "gps_ephemeris.h" // for Gps_Ephemeris
|
||||
#include "gps_iono.h" // for Gps_Iono
|
||||
#include "gps_utc_model.h" // for Gps_Utc_Model
|
||||
#include "tlm_utils.h"
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <matio.h> // for Mat_VarCreate
|
||||
#include <pmt/pmt.h> // for make_any
|
||||
#include <pmt/pmt_sugar.h> // for mp
|
||||
#include <cmath> // for round
|
||||
@ -33,28 +33,6 @@
|
||||
#include <exception> // for exception
|
||||
#include <iostream> // for cout
|
||||
#include <memory> // for shared_ptr
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for remove
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#ifdef COMPILER_HAS_ROTL
|
||||
#include <bit>
|
||||
@ -97,6 +75,7 @@ gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs(
|
||||
d_dump_filename = conf.dump_filename;
|
||||
d_dump = conf.dump;
|
||||
d_dump_mat = conf.dump_mat;
|
||||
d_remove_dat = conf.remove_dat;
|
||||
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
DLOG(INFO) << "Initializing GPS L1 TELEMETRY DECODER";
|
||||
@ -159,8 +138,7 @@ gps_l1_ca_telemetry_decoder_gs::~gps_l1_ca_telemetry_decoder_gs()
|
||||
}
|
||||
if (pos == 0)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
if (!fs::remove(fs::path(d_dump_filename), ec))
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
@ -168,116 +146,15 @@ gps_l1_ca_telemetry_decoder_gs::~gps_l1_ca_telemetry_decoder_gs()
|
||||
}
|
||||
if (d_dump && (pos != 0) && d_dump_mat)
|
||||
{
|
||||
try
|
||||
save_tlm_matfile(d_dump_filename);
|
||||
if (d_remove_dat)
|
||||
{
|
||||
save_matfile();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
LOG(WARNING) << "Error saving the .mat file: " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t gps_l1_ca_telemetry_decoder_gs::save_matfile() const
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
const int32_t number_of_double_vars = 2;
|
||||
const int32_t number_of_int_vars = 2;
|
||||
const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
|
||||
sizeof(int32_t) * number_of_int_vars;
|
||||
std::ifstream dump_file;
|
||||
std::string dump_filename_ = d_dump_filename;
|
||||
|
||||
std::cout << "Generating .mat file for " << dump_filename_ << '\n';
|
||||
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
try
|
||||
{
|
||||
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem opening dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
// count number of epochs and rewind
|
||||
int64_t num_epoch = 0;
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
size = dump_file.tellg();
|
||||
num_epoch = static_cast<int64_t>(size) / static_cast<int64_t>(epoch_size_bytes);
|
||||
if (num_epoch == 0LL)
|
||||
{
|
||||
// empty file, exit
|
||||
return 1;
|
||||
}
|
||||
dump_file.seekg(0, std::ios::beg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
auto TOW_at_current_symbol_ms = std::vector<double>(num_epoch);
|
||||
auto tracking_sample_counter = std::vector<uint64_t>(num_epoch);
|
||||
auto TOW_at_Preamble_ms = std::vector<double>(num_epoch);
|
||||
auto nav_symbol = std::vector<int32_t>(num_epoch);
|
||||
auto prn = std::vector<int32_t>(num_epoch);
|
||||
|
||||
try
|
||||
{
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
for (int64_t i = 0; i < num_epoch; i++)
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&tracking_sample_counter[i]), sizeof(uint64_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_Preamble_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&nav_symbol[i]), sizeof(int32_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&prn[i]), sizeof(int32_t));
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
}
|
||||
dump_file.close();
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem reading dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WRITE MAT FILE
|
||||
mat_t *matfp;
|
||||
matvar_t *matvar;
|
||||
std::string filename = dump_filename_;
|
||||
filename.erase(filename.length() - 4, 4);
|
||||
filename.append(".mat");
|
||||
matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73);
|
||||
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
|
||||
{
|
||||
std::array<size_t, 2> dims{1, static_cast<size_t>(num_epoch)};
|
||||
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_current_symbol_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("tracking_sample_counter", MAT_C_UINT64, MAT_T_UINT64, 2, dims.data(), tracking_sample_counter.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("TOW_at_Preamble_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_Preamble_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("nav_symbol", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), nav_symbol.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("PRN", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), prn.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
}
|
||||
Mat_Close(matfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -438,8 +315,8 @@ bool gps_l1_ca_telemetry_decoder_gs::decode_subframe()
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
// get almanac (if available)
|
||||
// TODO: implement almanac reader in navigation_message
|
||||
// get almanac (if available)
|
||||
// TODO: implement almanac reader in navigation_message
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -73,8 +73,6 @@ private:
|
||||
|
||||
gps_l1_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
|
||||
|
||||
int32_t save_matfile() const;
|
||||
|
||||
bool gps_word_parityCheck(uint32_t gpsword);
|
||||
bool decode_subframe();
|
||||
|
||||
@ -114,6 +112,7 @@ private:
|
||||
bool d_flag_TOW_set;
|
||||
bool d_dump;
|
||||
bool d_dump_mat;
|
||||
bool d_remove_dat;
|
||||
};
|
||||
|
||||
|
||||
|
@ -25,9 +25,9 @@
|
||||
#include "gps_cnav_ephemeris.h" // for Gps_CNAV_Ephemeris
|
||||
#include "gps_cnav_iono.h" // for Gps_CNAV_Iono
|
||||
#include "gps_cnav_utc_model.h" // for Gps_CNAV_Utc_Model
|
||||
#include "tlm_utils.h"
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <matio.h> // for Mat_VarCreate
|
||||
#include <pmt/pmt.h> // for make_any
|
||||
#include <pmt/pmt_sugar.h> // for mp
|
||||
#include <bitset> // for bitset
|
||||
@ -36,28 +36,7 @@
|
||||
#include <exception> // for exception
|
||||
#include <iostream> // for cout
|
||||
#include <memory> // for shared_ptr, make_shared
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for remove
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
gps_l2c_telemetry_decoder_gs_sptr
|
||||
gps_l2c_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf)
|
||||
@ -86,6 +65,7 @@ gps_l2c_telemetry_decoder_gs::gps_l2c_telemetry_decoder_gs(
|
||||
d_dump_filename = conf.dump_filename;
|
||||
d_dump = conf.dump;
|
||||
d_dump_mat = conf.dump_mat;
|
||||
d_remove_dat = conf.remove_dat;
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
DLOG(INFO) << "GPS L2C M TELEMETRY PROCESSING: satellite " << d_satellite;
|
||||
// set_output_multiple (1);
|
||||
@ -121,8 +101,7 @@ gps_l2c_telemetry_decoder_gs::~gps_l2c_telemetry_decoder_gs()
|
||||
}
|
||||
if (pos == 0)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
if (!fs::remove(fs::path(d_dump_filename), ec))
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
@ -130,116 +109,15 @@ gps_l2c_telemetry_decoder_gs::~gps_l2c_telemetry_decoder_gs()
|
||||
}
|
||||
if (d_dump && (pos != 0) && d_dump_mat)
|
||||
{
|
||||
try
|
||||
save_tlm_matfile(d_dump_filename);
|
||||
if (d_remove_dat)
|
||||
{
|
||||
save_matfile();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
LOG(WARNING) << "Error saving the .mat file: " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t gps_l2c_telemetry_decoder_gs::save_matfile() const
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
const int32_t number_of_double_vars = 2;
|
||||
const int32_t number_of_int_vars = 2;
|
||||
const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
|
||||
sizeof(int32_t) * number_of_int_vars;
|
||||
std::ifstream dump_file;
|
||||
std::string dump_filename_ = d_dump_filename;
|
||||
|
||||
std::cout << "Generating .mat file for " << dump_filename_ << '\n';
|
||||
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
try
|
||||
{
|
||||
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem opening dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
// count number of epochs and rewind
|
||||
int64_t num_epoch = 0;
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
size = dump_file.tellg();
|
||||
num_epoch = static_cast<int64_t>(size) / static_cast<int64_t>(epoch_size_bytes);
|
||||
if (num_epoch == 0LL)
|
||||
{
|
||||
// empty file, exit
|
||||
return 1;
|
||||
}
|
||||
dump_file.seekg(0, std::ios::beg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
auto TOW_at_current_symbol_ms = std::vector<double>(num_epoch);
|
||||
auto tracking_sample_counter = std::vector<uint64_t>(num_epoch);
|
||||
auto TOW_at_Preamble_ms = std::vector<double>(num_epoch);
|
||||
auto nav_symbol = std::vector<int32_t>(num_epoch);
|
||||
auto prn = std::vector<int32_t>(num_epoch);
|
||||
|
||||
try
|
||||
{
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
for (int64_t i = 0; i < num_epoch; i++)
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&tracking_sample_counter[i]), sizeof(uint64_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_Preamble_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&nav_symbol[i]), sizeof(int32_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&prn[i]), sizeof(int32_t));
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
}
|
||||
dump_file.close();
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem reading dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WRITE MAT FILE
|
||||
mat_t *matfp;
|
||||
matvar_t *matvar;
|
||||
std::string filename = dump_filename_;
|
||||
filename.erase(filename.length() - 4, 4);
|
||||
filename.append(".mat");
|
||||
matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73);
|
||||
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
|
||||
{
|
||||
std::array<size_t, 2> dims{1, static_cast<size_t>(num_epoch)};
|
||||
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_current_symbol_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("tracking_sample_counter", MAT_C_UINT64, MAT_T_UINT64, 2, dims.data(), tracking_sample_counter.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("TOW_at_Preamble_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_Preamble_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("nav_symbol", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), nav_symbol.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("PRN", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), prn.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
}
|
||||
Mat_Close(matfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,8 +73,6 @@ private:
|
||||
|
||||
gps_l2c_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
|
||||
|
||||
int32_t save_matfile() const;
|
||||
|
||||
Gnss_Satellite d_satellite;
|
||||
|
||||
cnav_msg_decoder_t d_cnav_decoder{};
|
||||
@ -101,6 +99,7 @@ private:
|
||||
bool d_flag_PLL_180_deg_phase_locked;
|
||||
bool d_flag_valid_word;
|
||||
bool d_dump_mat;
|
||||
bool d_remove_dat;
|
||||
};
|
||||
|
||||
|
||||
|
@ -24,9 +24,9 @@
|
||||
#include "gps_cnav_ephemeris.h"
|
||||
#include "gps_cnav_iono.h"
|
||||
#include "gps_cnav_utc_model.h" // for Gps_CNAV_Utc_Model
|
||||
#include "tlm_utils.h"
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <matio.h> // for Mat_VarCreate
|
||||
#include <pmt/pmt.h> // for make_any
|
||||
#include <pmt/pmt_sugar.h> // for mp
|
||||
#include <bitset> // for std::bitset
|
||||
@ -35,28 +35,6 @@
|
||||
#include <exception> // for std::exception
|
||||
#include <iostream> // for std::cout
|
||||
#include <memory> // for shared_ptr, make_shared
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for remove
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
gps_l5_telemetry_decoder_gs_sptr
|
||||
gps_l5_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf)
|
||||
@ -85,6 +63,7 @@ gps_l5_telemetry_decoder_gs::gps_l5_telemetry_decoder_gs(
|
||||
d_dump_filename = conf.dump_filename;
|
||||
d_dump = conf.dump;
|
||||
d_dump_mat = conf.dump_mat;
|
||||
d_remove_dat = conf.remove_dat;
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
DLOG(INFO) << "GPS L5 TELEMETRY PROCESSING: satellite " << d_satellite;
|
||||
d_channel = 0;
|
||||
@ -116,8 +95,7 @@ gps_l5_telemetry_decoder_gs::~gps_l5_telemetry_decoder_gs()
|
||||
}
|
||||
if (pos == 0)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
if (!fs::remove(fs::path(d_dump_filename), ec))
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
@ -125,116 +103,15 @@ gps_l5_telemetry_decoder_gs::~gps_l5_telemetry_decoder_gs()
|
||||
}
|
||||
if (d_dump && (pos != 0) && d_dump_mat)
|
||||
{
|
||||
try
|
||||
save_tlm_matfile(d_dump_filename);
|
||||
if (d_remove_dat)
|
||||
{
|
||||
save_matfile();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
LOG(WARNING) << "Error saving the .mat file: " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t gps_l5_telemetry_decoder_gs::save_matfile() const
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
const int32_t number_of_double_vars = 2;
|
||||
const int32_t number_of_int_vars = 2;
|
||||
const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
|
||||
sizeof(int32_t) * number_of_int_vars;
|
||||
std::ifstream dump_file;
|
||||
std::string dump_filename_ = d_dump_filename;
|
||||
|
||||
std::cout << "Generating .mat file for " << dump_filename_ << '\n';
|
||||
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
try
|
||||
{
|
||||
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem opening dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
// count number of epochs and rewind
|
||||
int64_t num_epoch = 0;
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
size = dump_file.tellg();
|
||||
num_epoch = static_cast<int64_t>(size) / static_cast<int64_t>(epoch_size_bytes);
|
||||
if (num_epoch == 0LL)
|
||||
{
|
||||
// empty file, exit
|
||||
return 1;
|
||||
}
|
||||
dump_file.seekg(0, std::ios::beg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
auto TOW_at_current_symbol_ms = std::vector<double>(num_epoch);
|
||||
auto tracking_sample_counter = std::vector<uint64_t>(num_epoch);
|
||||
auto TOW_at_Preamble_ms = std::vector<double>(num_epoch);
|
||||
auto nav_symbol = std::vector<int32_t>(num_epoch);
|
||||
auto prn = std::vector<int32_t>(num_epoch);
|
||||
|
||||
try
|
||||
{
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
for (int64_t i = 0; i < num_epoch; i++)
|
||||
if (!tlm_remove_file(d_dump_filename))
|
||||
{
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&tracking_sample_counter[i]), sizeof(uint64_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_Preamble_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&nav_symbol[i]), sizeof(int32_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&prn[i]), sizeof(int32_t));
|
||||
LOG(WARNING) << "Error deleting temporary file";
|
||||
}
|
||||
}
|
||||
dump_file.close();
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem reading dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WRITE MAT FILE
|
||||
mat_t *matfp;
|
||||
matvar_t *matvar;
|
||||
std::string filename = dump_filename_;
|
||||
filename.erase(filename.length() - 4, 4);
|
||||
filename.append(".mat");
|
||||
matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73);
|
||||
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
|
||||
{
|
||||
std::array<size_t, 2> dims{1, static_cast<size_t>(num_epoch)};
|
||||
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_current_symbol_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("tracking_sample_counter", MAT_C_UINT64, MAT_T_UINT64, 2, dims.data(), tracking_sample_counter.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("TOW_at_Preamble_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_Preamble_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("nav_symbol", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), nav_symbol.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("PRN", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), prn.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
}
|
||||
Mat_Close(matfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,8 +72,6 @@ private:
|
||||
|
||||
gps_l5_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
|
||||
|
||||
int32_t save_matfile() const;
|
||||
|
||||
cnav_msg_decoder_t d_cnav_decoder{};
|
||||
|
||||
Gnss_Satellite d_satellite;
|
||||
@ -97,6 +95,7 @@ private:
|
||||
bool d_sent_tlm_failed_msg;
|
||||
bool d_dump;
|
||||
bool d_dump_mat;
|
||||
bool d_remove_dat;
|
||||
};
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@ add_subdirectory(libswiftcnav)
|
||||
|
||||
set(TELEMETRY_DECODER_LIB_SOURCES
|
||||
tlm_conf.cc
|
||||
tlm_utils.cc
|
||||
viterbi_decoder.cc
|
||||
)
|
||||
|
||||
@ -19,6 +20,7 @@ set(TELEMETRY_DECODER_LIB_HEADERS
|
||||
tlm_conf.h
|
||||
viterbi_decoder.h
|
||||
convolutional.h
|
||||
tlm_utils.h
|
||||
)
|
||||
|
||||
list(SORT TELEMETRY_DECODER_LIB_HEADERS)
|
||||
@ -46,8 +48,19 @@ target_link_libraries(telemetry_decoder_libs
|
||||
PRIVATE
|
||||
Gflags::gflags
|
||||
Glog::glog
|
||||
Matio::matio
|
||||
)
|
||||
|
||||
if(FILESYSTEM_FOUND)
|
||||
target_compile_definitions(telemetry_decoder_libs PRIVATE -DHAS_STD_FILESYSTEM=1)
|
||||
if(find_experimental)
|
||||
target_compile_definitions(telemetry_decoder_libs PRIVATE -DHAS_STD_FILESYSTEM_EXPERIMENTAL=1)
|
||||
endif()
|
||||
target_link_libraries(telemetry_decoder_libs PRIVATE std::filesystem)
|
||||
else()
|
||||
target_link_libraries(telemetry_decoder_libs PRIVATE Boost::filesystem Boost::system)
|
||||
endif()
|
||||
|
||||
target_include_directories(telemetry_decoder_libs
|
||||
PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/src/core/interfaces
|
||||
|
@ -34,4 +34,5 @@ void Tlm_Conf::SetFromConfiguration(const ConfigurationInterface *configuration,
|
||||
dump_filename = configuration->property(role + ".dump_filename", default_dumpname);
|
||||
dump = configuration->property(role + ".dump", false);
|
||||
dump_mat = configuration->property(role + ".dump_mat", dump);
|
||||
remove_dat = configuration->property(role + ".remove_dat", false);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
std::string dump_filename;
|
||||
bool dump;
|
||||
bool dump_mat;
|
||||
bool remove_dat;
|
||||
};
|
||||
|
||||
|
||||
|
160
src/algorithms/telemetry_decoder/libs/tlm_utils.cc
Normal file
160
src/algorithms/telemetry_decoder/libs/tlm_utils.cc
Normal file
@ -0,0 +1,160 @@
|
||||
/*!
|
||||
* \file tlm_utils.cc
|
||||
* \brief Utilities for the telemetry decoder blocks.
|
||||
* \author Carles Fernandez, 2020. cfernandez(at)cttc.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "tlm_utils.h"
|
||||
#include <matio.h>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
// clang-format off
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for remove
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
int save_tlm_matfile(const std::string &dumpfile)
|
||||
{
|
||||
std::ifstream::pos_type size;
|
||||
const int32_t number_of_double_vars = 2;
|
||||
const int32_t number_of_int_vars = 2;
|
||||
const int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
|
||||
sizeof(int32_t) * number_of_int_vars;
|
||||
std::ifstream dump_file;
|
||||
const std::string &dump_filename_(dumpfile);
|
||||
|
||||
std::cout << "Generating .mat file for " << std::string(dump_filename_.begin(), dump_filename_.end() - 4) << '\n';
|
||||
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
try
|
||||
{
|
||||
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem opening dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
// count number of epochs and rewind
|
||||
int64_t num_epoch = 0;
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
size = dump_file.tellg();
|
||||
num_epoch = static_cast<int64_t>(size) / static_cast<int64_t>(epoch_size_bytes);
|
||||
if (num_epoch == 0LL)
|
||||
{
|
||||
// empty file, exit
|
||||
return 1;
|
||||
}
|
||||
dump_file.seekg(0, std::ios::beg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
auto TOW_at_current_symbol_ms = std::vector<double>(num_epoch);
|
||||
auto tracking_sample_counter = std::vector<uint64_t>(num_epoch);
|
||||
auto TOW_at_Preamble_ms = std::vector<double>(num_epoch);
|
||||
auto nav_symbol = std::vector<int32_t>(num_epoch);
|
||||
auto prn = std::vector<int32_t>(num_epoch);
|
||||
|
||||
try
|
||||
{
|
||||
if (dump_file.is_open())
|
||||
{
|
||||
for (int64_t i = 0; i < num_epoch; i++)
|
||||
{
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&tracking_sample_counter[i]), sizeof(uint64_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&TOW_at_Preamble_ms[i]), sizeof(double));
|
||||
dump_file.read(reinterpret_cast<char *>(&nav_symbol[i]), sizeof(int32_t));
|
||||
dump_file.read(reinterpret_cast<char *>(&prn[i]), sizeof(int32_t));
|
||||
}
|
||||
}
|
||||
dump_file.close();
|
||||
}
|
||||
catch (const std::ifstream::failure &e)
|
||||
{
|
||||
std::cerr << "Problem reading dump file:" << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// WRITE MAT FILE
|
||||
mat_t *matfp;
|
||||
matvar_t *matvar;
|
||||
std::string filename = dump_filename_;
|
||||
filename.erase(filename.length() - 4, 4);
|
||||
filename.append(".mat");
|
||||
try
|
||||
{
|
||||
matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73);
|
||||
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
|
||||
{
|
||||
std::array<size_t, 2> dims{1, static_cast<size_t>(num_epoch)};
|
||||
matvar = Mat_VarCreate("TOW_at_current_symbol_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_current_symbol_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("tracking_sample_counter", MAT_C_UINT64, MAT_T_UINT64, 2, dims.data(), tracking_sample_counter.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("TOW_at_Preamble_ms", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims.data(), TOW_at_Preamble_ms.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("nav_symbol", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), nav_symbol.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
|
||||
matvar = Mat_VarCreate("PRN", MAT_C_INT32, MAT_T_INT32, 2, dims.data(), prn.data(), 0);
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
}
|
||||
Mat_Close(matfp);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
std::cerr << "Error saving the .mat file: " << ex.what();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool tlm_remove_file(const std::string &file_to_remove)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
return fs::remove(fs::path(file_to_remove), ec);
|
||||
}
|
36
src/algorithms/telemetry_decoder/libs/tlm_utils.h
Normal file
36
src/algorithms/telemetry_decoder/libs/tlm_utils.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*!
|
||||
* \file tlm_utils.h
|
||||
* \brief Utilities for the telemetry decoder blocks.
|
||||
* \author Carles Fernandez, 2020. cfernandez(at)cttc.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef GNSS_SDR_TLM_UTILS_H
|
||||
#define GNSS_SDR_TLM_UTILS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
/** \addtogroup Telemetry_Decoder
|
||||
* \{ */
|
||||
/** \addtogroup Telemetry_Decoder_libs
|
||||
* \{ */
|
||||
|
||||
int save_tlm_matfile(const std::string &dumpfile);
|
||||
|
||||
bool tlm_remove_file(const std::string &file_to_remove);
|
||||
|
||||
/** \} */
|
||||
/** \} */
|
||||
#endif // GNSS_SDR_TLM_UTILS_H
|
Loading…
Reference in New Issue
Block a user