1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-05 23:10:34 +00:00

Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into vtl_experimental

This commit is contained in:
Javier Arribas 2020-11-23 10:58:53 +01:00
commit f78512462f
75 changed files with 1666 additions and 251 deletions

View File

@ -44,7 +44,7 @@ jobs:
- name: install dependencies - name: install dependencies
run: brew install clang-format run: brew install clang-format
- name: run clang-format - name: run clang-format
run: find . -iname \*.h -o -iname \*.c -o -iname \*.cpp | xargs clang-format -style=file -i run: find . -iname \*.h -o -iname \*.c -o -iname \*.cc | xargs clang-format -style=file -i
- name: check - name: check
run: git diff > clang_format.patch && echo -e "if \n [ -s clang_format.patch ] \nthen \n echo "clang-format not applied:"; echo ""; more clang_format.patch; exit 1 \nfi \n" > detect && chmod +x ./detect && ./detect run: git diff > clang_format.patch && echo -e "if \n [ -s clang_format.patch ] \nthen \n echo "clang-format not applied:"; echo ""; more clang_format.patch; exit 1 \nfi \n" > detect && chmod +x ./detect && ./detect
@ -112,6 +112,10 @@ jobs:
- name: test - name: test
shell: powershell shell: powershell
run: cd build; ctest -C Release run: cd build; ctest -C Release
- name: install
run: cmake --install build
- name: run profile
run: cd 'C:\Program Files (x86)\volk_gnsssdr\bin'; .\volk_gnsssdr_profile.exe
volk-gnsssdr-ubuntu: volk-gnsssdr-ubuntu:

View File

@ -14,7 +14,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Prevented in-tree build, it is bad practice.\nTry 'cd build && cmake ..' instead.") message(FATAL_ERROR "Prevented in-tree build, it is bad practice.\nTry 'cd build && cmake ..' instead.")
endif() endif()
cmake_minimum_required(VERSION 2.8.12...3.18) cmake_minimum_required(VERSION 2.8.12...3.19)
project(gnss-sdr CXX C) project(gnss-sdr CXX C)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)

View File

@ -57,6 +57,8 @@ SPDX-FileCopyrightText: 2011-2020 Carles Fernandez-Prades <carles.fernandez@cttc
GNSS-SDR, the old method is still used in old development environments. No GNSS-SDR, the old method is still used in old development environments. No
extra dependency is needed. This change is transparent to the user, since extra dependency is needed. This change is transparent to the user, since
everything is managed by the CMake scripts. everything is managed by the CMake scripts.
- The `volk_gnsssdr` library can be built on Microsoft Windows and can execute
SIMD instructions on that OS.
- Fix building with `-DENABLE_CUDA=ON` for blocks implemented with CUDA. - Fix building with `-DENABLE_CUDA=ON` for blocks implemented with CUDA.
### Improvements in Usability: ### Improvements in Usability:
@ -67,6 +69,8 @@ SPDX-FileCopyrightText: 2011-2020 Carles Fernandez-Prades <carles.fernandez@cttc
parameters for the `DataTypeAdapter`, `InputFilter` and `Resampler` blocks are parameters for the `DataTypeAdapter`, `InputFilter` and `Resampler` blocks are
ignored. This was the default behavior in GNSS-SDR v0.0.12, but it changed in ignored. This was the default behavior in GNSS-SDR v0.0.12, but it changed in
v0.0.13. This change recovers the old behavior. v0.0.13. This change recovers the old behavior.
- Fixed occasional segmentation fault when exiting with `q` + `[Enter]` keys if
`Acquisition_XX.blocking=false`.
- Fixed the termination of the receiver with `q` + `[Enter]` keys when using the - Fixed the termination of the receiver with `q` + `[Enter]` keys when using the
`Osmosdr_Signal_Source` implementation of the `SignalSource` block. `Osmosdr_Signal_Source` implementation of the `SignalSource` block.
- The `Labsat_Signal_Source` implementation of the `SignalSource` block now can - The `Labsat_Signal_Source` implementation of the `SignalSource` block now can
@ -85,6 +89,10 @@ SPDX-FileCopyrightText: 2011-2020 Carles Fernandez-Prades <carles.fernandez@cttc
Make use of MathJax for equation rendering. Added new building option Make use of MathJax for equation rendering. Added new building option
`ENABLE_EXTERNAL_MATHJAX`, set to `ON` by default. If set to `OFF`, it allows `ENABLE_EXTERNAL_MATHJAX`, set to `ON` by default. If set to `OFF`, it allows
using a local installation of MathJax 2. using a local installation of MathJax 2.
- Improved dumps in Telemetry Decoding blocks. Now they include the raw
navigation message bits. If `TelemetryDecoder_XX.dump=true`, the resulting
`.dat` binary file is also delivered in `.mat` format, which is readable from
Matlab and Python.
&nbsp; &nbsp;

View File

@ -29,6 +29,7 @@
#include <iostream> // for cout, cerr #include <iostream> // for cout, cerr
#include <sstream> // for stringstream #include <sstream> // for stringstream
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -47,6 +48,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
GeoJSON_Printer::GeoJSON_Printer(const std::string& base_path) GeoJSON_Printer::GeoJSON_Printer(const std::string& base_path)
{ {

View File

@ -29,6 +29,7 @@
#include <iostream> // for cout, cerr #include <iostream> // for cout, cerr
#include <sstream> // for stringstream #include <sstream> // for stringstream
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -47,6 +48,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
Gpx_Printer::Gpx_Printer(const std::string& base_path) Gpx_Printer::Gpx_Printer(const std::string& base_path)

View File

@ -31,6 +31,7 @@
#include <sys/stat.h> // for S_IXUSR | S_IRWXG | S_IRWXO #include <sys/stat.h> // for S_IXUSR | S_IRWXG | S_IRWXO
#include <sys/types.h> // for mode_t #include <sys/types.h> // for mode_t
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -49,6 +50,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
Kml_Printer::Kml_Printer(const std::string& base_path) Kml_Printer::Kml_Printer(const std::string& base_path)

View File

@ -34,6 +34,7 @@
#include <termios.h> #include <termios.h>
#include <utility> #include <utility>
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -52,6 +53,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string& base_path) Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string& base_path)

View File

@ -56,6 +56,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -74,6 +75,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
Rinex_Printer::Rinex_Printer(int32_t conf_version, const std::string& base_path, const std::string& base_name) Rinex_Printer::Rinex_Printer(int32_t conf_version, const std::string& base_path, const std::string& base_name)

View File

@ -38,6 +38,8 @@
#include <iostream> // for cout, cerr #include <iostream> // for cout, cerr
#include <termios.h> // for tcgetattr #include <termios.h> // for tcgetattr
#include <unistd.h> // for close, write #include <unistd.h> // for close, write
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -56,6 +58,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format off
Rtcm_Printer::Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump, bool flag_rtcm_server, bool flag_rtcm_tty_port, uint16_t rtcm_tcp_port, uint16_t rtcm_station_id, const std::string& rtcm_dump_devname, bool time_tag_name, const std::string& base_path) Rtcm_Printer::Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump, bool flag_rtcm_server, bool flag_rtcm_tty_port, uint16_t rtcm_tcp_port, uint16_t rtcm_station_id, const std::string& rtcm_dump_devname, bool time_tag_name, const std::string& base_path)

View File

@ -41,6 +41,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -59,6 +60,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
Rtklib_Solver::Rtklib_Solver(const rtk_t &rtk, int nchannels, const std::string &dump_filename, bool flag_dump_to_file, bool flag_dump_to_mat) Rtklib_Solver::Rtklib_Solver(const rtk_t &rtk, int nchannels, const std::string &dump_filename, bool flag_dump_to_file, bool flag_dump_to_mat)

View File

@ -659,8 +659,10 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count)
<< ", doppler_step: " << d_doppler_step << ", doppler_step: " << d_doppler_step
<< ", use_CFAR_algorithm_flag: " << (d_use_CFAR_algorithm_flag ? "true" : "false"); << ", use_CFAR_algorithm_flag: " << (d_use_CFAR_algorithm_flag ? "true" : "false");
lk.unlock(); if (d_acq_parameters.blocking)
{
lk.unlock();
}
// Doppler frequency grid loop // Doppler frequency grid loop
if (!d_step_two) if (!d_step_two)
{ {
@ -782,7 +784,11 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count)
} }
} }
lk.lock(); if (d_acq_parameters.blocking)
{
lk.lock();
}
if (!d_acq_parameters.bit_transition_flag) if (!d_acq_parameters.bit_transition_flag)
{ {
if (d_test_statistics > d_threshold) if (d_test_statistics > d_threshold)
@ -872,7 +878,6 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count)
send_negative_acquisition(); send_negative_acquisition();
} }
} }
d_worker_active = false;
if ((d_num_noncoherent_integrations_counter == d_acq_parameters.max_dwells) or (d_positive_acq == 1)) if ((d_num_noncoherent_integrations_counter == d_acq_parameters.max_dwells) or (d_positive_acq == 1))
{ {
@ -884,6 +889,8 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count)
d_num_noncoherent_integrations_counter = 0U; d_num_noncoherent_integrations_counter = 0U;
d_positive_acq = 0; d_positive_acq = 0;
} }
d_worker_active = false;
} }
@ -930,6 +937,7 @@ int pcps_acquisition::general_work(int noutput_items __attribute__((unused)),
* 6. Declare positive or negative acquisition using a message port * 6. Declare positive or negative acquisition using a message port
*/ */
gr::thread::scoped_lock lk(d_setlock); gr::thread::scoped_lock lk(d_setlock);
if (!d_active or d_worker_active) if (!d_active or d_worker_active)
{ {
if (!d_acq_parameters.blocking_on_standby) if (!d_acq_parameters.blocking_on_standby)
@ -1016,7 +1024,8 @@ int pcps_acquisition::general_work(int noutput_items __attribute__((unused)),
} }
else else
{ {
gr::thread::thread d_worker(&pcps_acquisition::acquisition_core, this, d_sample_counter); d_worker = std::thread([&] { pcps_acquisition::acquisition_core(d_sample_counter); });
d_worker.detach();
d_worker_active = true; d_worker_active = true;
} }
consume_each(0); consume_each(0);

View File

@ -61,8 +61,8 @@
#include <memory> #include <memory>
#include <queue> #include <queue>
#include <string> #include <string>
#include <thread>
#include <utility> #include <utility>
#if HAS_STD_SPAN #if HAS_STD_SPAN
#include <span> #include <span>
namespace own = std; namespace own = std;
@ -259,6 +259,7 @@ private:
arma::fmat d_narrow_grid; arma::fmat d_narrow_grid;
std::string d_dump_filename; std::string d_dump_filename;
std::thread d_worker;
int64_t d_dump_number; int64_t d_dump_number;
uint64_t d_sample_counter; uint64_t d_sample_counter;

View File

@ -81,8 +81,8 @@ pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc(
bool dump, bool dump,
const std::string &dump_filename, const std::string &dump_filename,
bool enable_monitor_output) : gr::block("pcps_opencl_acquisition_cc", bool enable_monitor_output) : gr::block("pcps_opencl_acquisition_cc",
gr::io_signature::make(1, 1, static_cast<int>(sizeof(gr_complex) * sampled_ms * samples_per_ms)), gr::io_signature::make(1, 1, static_cast<int>(sizeof(gr_complex) * sampled_ms * samples_per_ms)),
gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) gr::io_signature::make(0, 1, sizeof(Gnss_Synchro)))
{ {
this->message_port_register_out(pmt::mp("events")); this->message_port_register_out(pmt::mp("events"));
d_sample_counter = 0ULL; // SAMPLE COUNTER d_sample_counter = 0ULL; // SAMPLE COUNTER

View File

@ -22,6 +22,7 @@
#include <exception> // for exception #include <exception> // for exception
#include <fstream> // for ofstream #include <fstream> // for ofstream
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -40,6 +41,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
bool gnss_sdr_create_directory(const std::string& foldername) bool gnss_sdr_create_directory(const std::string& foldername)
{ {

View File

@ -247,7 +247,10 @@ if(CMAKE_VERSION VERSION_GREATER 3.0 AND SUPPORTED_CPU_FEATURES_ARCH)
FORCE FORCE
) )
set(USE_CPU_FEATURES ON) set(USE_CPU_FEATURES ON)
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(cpu_features) add_subdirectory(cpu_features)
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
endif() endif()
# Python # Python

View File

@ -139,6 +139,24 @@ $ volk_gnsssdr_profile
$ sudo ldconfig $ sudo ldconfig
``` ```
### Building on Microsoft Windows
With Visual Studio 2019, in a Powershell run by administrator:
```
$ git clone https://github.com/gnss-sdr/gnss-sdr
$ cd gnss-sdr
$ git checkout next
$ cd build
$ cmake -G "Visual Studio 16 2019" ..\src\algorithms\libs\volk_gnsssdr_module\volk_gnsssdr
$ cd ..
$ cmake --build build --config Release
$ cd build
$ ctest -C Release
$ cd ..
$ cmake --install build
```
## References ## References
If you use VOLK_GNSSSDR in your research and/or software, please cite the If you use VOLK_GNSSSDR in your research and/or software, please cite the

View File

@ -68,7 +68,6 @@
<check name="mmx"></check> <check name="mmx"></check>
<flag compiler="gnu">-mmmx</flag> <flag compiler="gnu">-mmmx</flag>
<flag compiler="clang">-mmmx</flag> <flag compiler="clang">-mmmx</flag>
<flag compiler="msvc">/arch:SSE</flag>
<alignment>8</alignment> <alignment>8</alignment>
</arch> </arch>
@ -84,7 +83,6 @@
<check name="sse"></check> <check name="sse"></check>
<flag compiler="gnu">-msse</flag> <flag compiler="gnu">-msse</flag>
<flag compiler="clang">-msse</flag> <flag compiler="clang">-msse</flag>
<flag compiler="msvc">/arch:SSE</flag>
<environment>_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);</environment> <environment>_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);</environment>
<include>xmmintrin.h</include> <include>xmmintrin.h</include>
<alignment>16</alignment> <alignment>16</alignment>
@ -94,7 +92,6 @@
<check name="sse2"></check> <check name="sse2"></check>
<flag compiler="gnu">-msse2</flag> <flag compiler="gnu">-msse2</flag>
<flag compiler="clang">-msse2</flag> <flag compiler="clang">-msse2</flag>
<flag compiler="msvc">/arch:SSE2</flag>
<alignment>16</alignment> <alignment>16</alignment>
</arch> </arch>

View File

@ -63,7 +63,6 @@
#include <volk_gnsssdr/volk_gnsssdr_complex.h> #include <volk_gnsssdr/volk_gnsssdr_complex.h>
#include <volk_gnsssdr/volk_gnsssdr_malloc.h> #include <volk_gnsssdr/volk_gnsssdr_malloc.h>
#include <math.h> #include <math.h>
// #include <stdio.h>
#ifdef LV_HAVE_GENERIC #ifdef LV_HAVE_GENERIC
@ -74,7 +73,7 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_generic(lv_32f
unsigned int n; unsigned int n;
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
result[n_vec] = lv_cmake(0, 0); result[n_vec] = lv_cmake(0.0f, 0.0f);
} }
for (n = 0; n < num_points; n++) for (n = 0; n < num_points; n++)
{ {
@ -115,7 +114,7 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_generic_reload
unsigned int j; unsigned int j;
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
result[n_vec] = lv_cmake(0, 0); result[n_vec] = lv_cmake(0.0f, 0.0f);
} }
for (n = 0; n < num_points / ROTATOR_RELOAD; n++) for (n = 0; n < num_points / ROTATOR_RELOAD; n++)
@ -158,6 +157,7 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_generic_reload
#include <immintrin.h> #include <immintrin.h>
static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const float** in_a, int num_a_vectors, unsigned int num_points) static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const float** in_a, int num_a_vectors, unsigned int num_points)
{ {
#ifndef WIN32
unsigned int number = 0; unsigned int number = 0;
int vec_ind = 0; int vec_ind = 0;
unsigned int i = 0; unsigned int i = 0;
@ -287,7 +287,7 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_
_mm256_store_ps((float*)dotProductVector, dotProdVal0[vec_ind]); // Store the results back into the dot product vector _mm256_store_ps((float*)dotProductVector, dotProdVal0[vec_ind]); // Store the results back into the dot product vector
result[vec_ind] = lv_cmake(0, 0); result[vec_ind] = lv_cmake(0.0f, 0.0f);
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
{ {
result[vec_ind] += dotProductVector[i]; result[vec_ind] += dotProductVector[i];
@ -312,6 +312,9 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_
} }
*phase = _phase; *phase = _phase;
#else
volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_generic_reload(result, in_common, phase_inc, phase, in_a, num_a_vectors, num_points);
#endif
} }
#endif /* LV_HAVE_AVX */ #endif /* LV_HAVE_AVX */
@ -322,6 +325,7 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_
#include <immintrin.h> #include <immintrin.h>
static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const float** in_a, int num_a_vectors, unsigned int num_points) static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const float** in_a, int num_a_vectors, unsigned int num_points)
{ {
#ifndef WIN32
unsigned int number = 0; unsigned int number = 0;
int vec_ind = 0; int vec_ind = 0;
unsigned int i = 0; unsigned int i = 0;
@ -451,7 +455,7 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_
_mm256_store_ps((float*)dotProductVector, dotProdVal0[vec_ind]); // Store the results back into the dot product vector _mm256_store_ps((float*)dotProductVector, dotProdVal0[vec_ind]); // Store the results back into the dot product vector
result[vec_ind] = lv_cmake(0, 0); result[vec_ind] = lv_cmake(0.0f, 0.0f);
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
{ {
result[vec_ind] += dotProductVector[i]; result[vec_ind] += dotProductVector[i];
@ -476,6 +480,9 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_
} }
*phase = _phase; *phase = _phase;
#else
volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_generic_reload(result, in_common, phase_inc, phase, in_a, num_a_vectors, num_points);
#endif
} }

View File

@ -106,8 +106,11 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_u_avx(lv_3
in_a[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); in_a[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment());
memcpy((float*)in_a[n], (float*)in, sizeof(float) * num_points); memcpy((float*)in_a[n], (float*)in, sizeof(float) * num_points);
} }
#ifndef WIN32
volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(result, local_code, phase_inc[0], phase, (const float**)in_a, num_a_vectors, num_points); volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(result, local_code, phase_inc[0], phase, (const float**)in_a, num_a_vectors, num_points);
#else
volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_generic_reload(result, local_code, phase_inc[0], phase, (const float**)in_a, num_a_vectors, num_points);
#endif
for (n = 0; n < num_a_vectors; n++) for (n = 0; n < num_a_vectors; n++)
{ {
volk_gnsssdr_free(in_a[n]); volk_gnsssdr_free(in_a[n]);
@ -136,8 +139,11 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_a_avx(lv_3
in_a[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment()); in_a[n] = (float*)volk_gnsssdr_malloc(sizeof(float) * num_points, volk_gnsssdr_get_alignment());
memcpy((float*)in_a[n], (float*)in, sizeof(float) * num_points); memcpy((float*)in_a[n], (float*)in, sizeof(float) * num_points);
} }
#ifndef WIN32
volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(result, local_code, phase_inc[0], phase, (const float**)in_a, num_a_vectors, num_points); volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(result, local_code, phase_inc[0], phase, (const float**)in_a, num_a_vectors, num_points);
#else
volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_generic_reload(result, local_code, phase_inc[0], phase, (const float**)in_a, num_a_vectors, num_points);
#endif
for (n = 0; n < num_a_vectors; n++) for (n = 0; n < num_a_vectors; n++)
{ {
volk_gnsssdr_free(in_a[n]); volk_gnsssdr_free(in_a[n]);

View File

@ -74,7 +74,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_generic(lv_32fc
unsigned int n; unsigned int n;
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
result[n_vec] = lv_cmake(0, 0); result[n_vec] = lv_cmake(0.0f, 0.0f);
} }
for (n = 0; n < num_points; n++) for (n = 0; n < num_points; n++)
{ {
@ -115,7 +115,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_generic_reload(
unsigned int j; unsigned int j;
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
result[n_vec] = lv_cmake(0, 0); result[n_vec] = lv_cmake(0.0f, 0.0f);
} }
for (n = 0; n < num_points / ROTATOR_RELOAD; n++) for (n = 0; n < num_points / ROTATOR_RELOAD; n++)
@ -158,7 +158,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_generic_reload(
#include <pmmintrin.h> #include <pmmintrin.h>
static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_u_sse3(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_32fc_t** in_a, int num_a_vectors, unsigned int num_points) static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_u_sse3(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_32fc_t** in_a, int num_a_vectors, unsigned int num_points)
{ {
lv_32fc_t dotProduct = lv_cmake(0, 0); lv_32fc_t dotProduct = lv_cmake(0.0f, 0.0f);
lv_32fc_t tmp32_1, tmp32_2; lv_32fc_t tmp32_1, tmp32_2;
const unsigned int sse_iters = num_points / 2; const unsigned int sse_iters = num_points / 2;
int n_vec; int n_vec;
@ -240,7 +240,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_u_sse3(lv_32fc_
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
_mm_store_ps((float*)dotProductVector, acc[n_vec]); // Store the results back into the dot product vector _mm_store_ps((float*)dotProductVector, acc[n_vec]); // Store the results back into the dot product vector
dotProduct = lv_cmake(0, 0); dotProduct = lv_cmake(0.0f, 0.0f);
for (i = 0; i < 2; ++i) for (i = 0; i < 2; ++i)
{ {
dotProduct = dotProduct + dotProductVector[i]; dotProduct = dotProduct + dotProductVector[i];
@ -270,7 +270,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_u_sse3(lv_32fc_
#include <pmmintrin.h> #include <pmmintrin.h>
static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_a_sse3(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_32fc_t** in_a, int num_a_vectors, unsigned int num_points) static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_a_sse3(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_32fc_t** in_a, int num_a_vectors, unsigned int num_points)
{ {
lv_32fc_t dotProduct = lv_cmake(0, 0); lv_32fc_t dotProduct = lv_cmake(0.0f, 0.0f);
lv_32fc_t tmp32_1, tmp32_2; lv_32fc_t tmp32_1, tmp32_2;
const unsigned int sse_iters = num_points / 2; const unsigned int sse_iters = num_points / 2;
int n_vec; int n_vec;
@ -352,7 +352,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_a_sse3(lv_32fc_
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
_mm_store_ps((float*)dotProductVector, acc[n_vec]); // Store the results back into the dot product vector _mm_store_ps((float*)dotProductVector, acc[n_vec]); // Store the results back into the dot product vector
dotProduct = lv_cmake(0, 0); dotProduct = lv_cmake(0.0f, 0.0f);
for (i = 0; i < 2; ++i) for (i = 0; i < 2; ++i)
{ {
dotProduct = dotProduct + dotProductVector[i]; dotProduct = dotProduct + dotProductVector[i];
@ -382,7 +382,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_a_sse3(lv_32fc_
#include <immintrin.h> #include <immintrin.h>
static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_32fc_t** in_a, int num_a_vectors, unsigned int num_points) static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_32fc_t** in_a, int num_a_vectors, unsigned int num_points)
{ {
lv_32fc_t dotProduct = lv_cmake(0, 0); lv_32fc_t dotProduct = lv_cmake(0.0f, 0.0f);
lv_32fc_t tmp32_1, tmp32_2; lv_32fc_t tmp32_1, tmp32_2;
const unsigned int avx_iters = num_points / 4; const unsigned int avx_iters = num_points / 4;
int n_vec; int n_vec;
@ -401,13 +401,14 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_t
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
acc[n_vec] = _mm256_setzero_ps(); acc[n_vec] = _mm256_setzero_ps();
result[n_vec] = lv_cmake(0, 0); result[n_vec] = lv_cmake(0.0f, 0.0f);
} }
// phase rotation registers // phase rotation registers
__m256 a, four_phase_acc_reg, yl, yh, tmp1, tmp1p, tmp2, tmp2p, z; __m256 a, four_phase_acc_reg, yl, yh, tmp1, tmp1p, tmp2, tmp2p, z;
__attribute__((aligned(32))) lv_32fc_t four_phase_inc[4]; __VOLK_ATTR_ALIGNED(32)
lv_32fc_t four_phase_inc[4];
const lv_32fc_t phase_inc2 = phase_inc * phase_inc; const lv_32fc_t phase_inc2 = phase_inc * phase_inc;
const lv_32fc_t phase_inc3 = phase_inc2 * phase_inc; const lv_32fc_t phase_inc3 = phase_inc2 * phase_inc;
const lv_32fc_t phase_inc4 = phase_inc3 * phase_inc; const lv_32fc_t phase_inc4 = phase_inc3 * phase_inc;
@ -417,7 +418,8 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_t
four_phase_inc[3] = phase_inc4; four_phase_inc[3] = phase_inc4;
const __m256 four_phase_inc_reg = _mm256_load_ps((float*)four_phase_inc); const __m256 four_phase_inc_reg = _mm256_load_ps((float*)four_phase_inc);
__attribute__((aligned(32))) lv_32fc_t four_phase_acc[4]; __VOLK_ATTR_ALIGNED(32)
lv_32fc_t four_phase_acc[4];
four_phase_acc[0] = _phase; four_phase_acc[0] = _phase;
four_phase_acc[1] = _phase * phase_inc; four_phase_acc[1] = _phase * phase_inc;
four_phase_acc[2] = _phase * phase_inc2; four_phase_acc[2] = _phase * phase_inc2;
@ -472,7 +474,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_t
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
_mm256_store_ps((float*)dotProductVector, acc[n_vec]); // Store the results back into the dot product vector _mm256_store_ps((float*)dotProductVector, acc[n_vec]); // Store the results back into the dot product vector
dotProduct = lv_cmake(0, 0); dotProduct = lv_cmake(0.0f, 0.0f);
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
{ {
dotProduct = dotProduct + dotProductVector[i]; dotProduct = dotProduct + dotProductVector[i];
@ -510,7 +512,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_t
#include <immintrin.h> #include <immintrin.h>
static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_32fc_t** in_a, int num_a_vectors, unsigned int num_points) static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_32fc_t** in_a, int num_a_vectors, unsigned int num_points)
{ {
lv_32fc_t dotProduct = lv_cmake(0, 0); lv_32fc_t dotProduct = lv_cmake(0.0f, 0.0f);
lv_32fc_t tmp32_1, tmp32_2; lv_32fc_t tmp32_1, tmp32_2;
const unsigned int avx_iters = num_points / 4; const unsigned int avx_iters = num_points / 4;
int n_vec; int n_vec;
@ -529,7 +531,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_t
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
acc[n_vec] = _mm256_setzero_ps(); acc[n_vec] = _mm256_setzero_ps();
result[n_vec] = lv_cmake(0, 0); result[n_vec] = lv_cmake(0.0f, 0.0f);
} }
// phase rotation registers // phase rotation registers
@ -602,7 +604,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_t
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
_mm256_store_ps((float*)dotProductVector, acc[n_vec]); // Store the results back into the dot product vector _mm256_store_ps((float*)dotProductVector, acc[n_vec]); // Store the results back into the dot product vector
dotProduct = lv_cmake(0, 0); dotProduct = lv_cmake(0.0f, 0.0f);
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
{ {
dotProduct = dotProduct + dotProductVector[i]; dotProduct = dotProduct + dotProductVector[i];
@ -655,7 +657,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_neon(lv_32fc_t*
if (neon_iters > 0) if (neon_iters > 0)
{ {
lv_32fc_t dotProduct = lv_cmake(0, 0); lv_32fc_t dotProduct = lv_cmake(0.0f, 0.0f);
float32_t arg_phase0 = cargf(_phase); float32_t arg_phase0 = cargf(_phase);
float32_t arg_phase_inc = cargf(phase_inc); float32_t arg_phase_inc = cargf(phase_inc);
float32_t phase_est; float32_t phase_est;
@ -760,7 +762,7 @@ static inline void volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn_neon(lv_32fc_t*
for (n_vec = 0; n_vec < num_a_vectors; n_vec++) for (n_vec = 0; n_vec < num_a_vectors; n_vec++)
{ {
vst2q_f32((float32_t*)dotProductVector, accumulator1[n_vec]); // Store the results back into the dot product vector vst2q_f32((float32_t*)dotProductVector, accumulator1[n_vec]); // Store the results back into the dot product vector
dotProduct = lv_cmake(0, 0); dotProduct = lv_cmake(0.0f, 0.0f);
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
{ {
dotProduct = dotProduct + dotProductVector[i]; dotProduct = dotProduct + dotProductVector[i];

View File

@ -145,6 +145,11 @@ macro(OVERRULE_ARCH arch reason)
list(REMOVE_ITEM available_archs ${arch}) list(REMOVE_ITEM available_archs ${arch})
endmacro() endmacro()
macro(FORCE_ARCH arch reason)
message(STATUS "${reason}, Forced arch ${arch}")
list(APPEND available_archs ${arch})
endmacro()
######################################################################## ########################################################################
# eliminate AVX on if not on x86, or if the compiler does not accept # eliminate AVX on if not on x86, or if the compiler does not accept
# the xgetbv instruction, or {if not cross-compiling and the xgetbv # the xgetbv instruction, or {if not cross-compiling and the xgetbv
@ -264,13 +269,13 @@ if(NOT CROSSCOMPILE_MULTILIB AND CPU_IS_x86)
endif() endif()
# MSVC 64 bit does not have MMX, overrule it # MSVC 64 bit does not have MMX, overrule it
if(${SIZEOF_CPU} EQUAL 64 AND MSVC) if(MSVC)
overrule_arch(mmx "No MMX for Win64") if(${SIZEOF_CPU} EQUAL 64)
if(MSVC_VERSION GREATER 1700) overrule_arch(mmx "No MMX for Win64")
overrule_arch(sse "No SSE for Win64 Visual Studio 2013")
endif() endif()
force_arch(sse "Built-in for MSVC > 2013")
force_arch(sse2 "Built-in for MSVC > 2013")
endif() endif()
endif() endif()
######################################################################## ########################################################################

View File

@ -15,25 +15,10 @@
#include <string.h> #include <string.h>
// clang-format on // clang-format on
#if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4
#define __popcnt __builtin_popcount
#else
inline unsigned __popcnt(unsigned num)
{
unsigned pop = 0;
while (num)
{
if (num & 0x1) pop++;
num >>= 1;
}
return pop;
}
#endif
int volk_gnsssdr_get_index( int volk_gnsssdr_get_index(
const char *impl_names[], //list of implementations by name const char *impl_names[], // list of implementations by name
const size_t n_impls, //number of implementations available const size_t n_impls, // number of implementations available
const char *impl_name //the implementation name to find const char *impl_name // the implementation name to find
) )
{ {
unsigned int i; unsigned int i;
@ -44,20 +29,20 @@ int volk_gnsssdr_get_index(
return i; return i;
} }
} }
//TODO return -1; // TODO return -1;
//something terrible should happen here // something terrible should happen here
fprintf(stderr, "VOLK_GNSSSDR warning: no arch found, returning generic impl\n"); fprintf(stderr, "VOLK_GNSSSDR warning: no arch found, returning generic impl\n");
return volk_gnsssdr_get_index(impl_names, n_impls, "generic"); //but we'll fake it for now return volk_gnsssdr_get_index(impl_names, n_impls, "generic"); //but we'll fake it for now
} }
int volk_gnsssdr_rank_archs( int volk_gnsssdr_rank_archs(
const char *kern_name, //name of the kernel to rank const char *kern_name, // name of the kernel to rank
const char *impl_names[], //list of implementations by name const char *impl_names[], // list of implementations by name
const int *impl_deps, //requirement mask per implementation const int *impl_deps, // requirement mask per implementation
const bool *alignment, //alignment status of each implementation const bool *alignment, // alignment status of each implementation
size_t n_impls, //number of implementations available size_t n_impls, // number of implementations available
const bool align //if false, filter aligned implementations const bool align // if false, filter aligned implementations
) )
{ {
size_t i; size_t i;
@ -78,7 +63,7 @@ int volk_gnsssdr_rank_archs(
return volk_gnsssdr_get_index(impl_names, n_impls, "generic"); return volk_gnsssdr_get_index(impl_names, n_impls, "generic");
} }
//now look for the function name in the prefs list // now look for the function name in the prefs list
for (i = 0; i < n_arch_prefs; i++) for (i = 0; i < n_arch_prefs; i++)
{ {
if (!strncmp(kern_name, volk_gnsssdr_arch_prefs[i].name, sizeof(volk_gnsssdr_arch_prefs[i].name))) //found it if (!strncmp(kern_name, volk_gnsssdr_arch_prefs[i].name, sizeof(volk_gnsssdr_arch_prefs[i].name))) //found it
@ -88,14 +73,14 @@ int volk_gnsssdr_rank_archs(
} }
} }
//return the best index with the largest deps // return the best index with the largest deps
size_t best_index_a = 0; size_t best_index_a = 0;
size_t best_index_u = 0; size_t best_index_u = 0;
int best_value_a = -1; int best_value_a = -1;
int best_value_u = -1; int best_value_u = -1;
for (i = 0; i < n_impls; i++) for (i = 0; i < n_impls; i++)
{ {
const signed val = __popcnt(impl_deps[i]); const signed val = impl_deps[i];
if (alignment[i] && val > best_value_a) if (alignment[i] && val > best_value_a)
{ {
best_index_a = i; best_index_a = i;
@ -108,9 +93,9 @@ int volk_gnsssdr_rank_archs(
} }
} }
//when align and we found a best aligned, use it // when align and we found a best aligned, use it
if (align && best_value_a != -1) return best_index_a; if (align && best_value_a != -1) return best_index_a;
//otherwise return the best unaligned // otherwise return the best unaligned
return best_index_u; return best_index_u;
} }

View File

@ -41,6 +41,7 @@
#include <boost/bind/bind.hpp> #include <boost/bind/bind.hpp>
#endif #endif
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -59,6 +60,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
hybrid_observables_gs_sptr hybrid_observables_gs_make(const Obs_Conf &conf_) hybrid_observables_gs_sptr hybrid_observables_gs_make(const Obs_Conf &conf_)

View File

@ -60,11 +60,11 @@ endif()
target_link_libraries(telemetry_decoder_adapters target_link_libraries(telemetry_decoder_adapters
PUBLIC PUBLIC
telemetry_decoder_gr_blocks telemetry_decoder_gr_blocks
telemetry_decoder_libs
PRIVATE PRIVATE
Gflags::gflags Gflags::gflags
Glog::glog Glog::glog
Gnuradio::runtime Gnuradio::runtime
telemetry_decoder_libs
) )
target_include_directories(telemetry_decoder_adapters target_include_directories(telemetry_decoder_adapters

View File

@ -32,12 +32,10 @@ BeidouB1iTelemetryDecoder::BeidouB1iTelemetryDecoder(
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = beidou_b1i_make_telemetry_decoder_gs(satellite_, dump_); // TODO fix me telemetry_decoder_ = beidou_b1i_make_telemetry_decoder_gs(satellite_, tlm_parameters_);
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -27,6 +27,7 @@
#include "gnss_satellite.h" // for Gnss_Satellite #include "gnss_satellite.h" // for Gnss_Satellite
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -86,12 +87,11 @@ public:
private: private:
beidou_b1i_telemetry_decoder_gs_sptr telemetry_decoder_; beidou_b1i_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
std::string dump_filename_; Tlm_Conf tlm_parameters_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };

View File

@ -27,13 +27,10 @@ BeidouB3iTelemetryDecoder::BeidouB3iTelemetryDecoder(
unsigned int in_streams, unsigned int out_streams) unsigned int in_streams, unsigned int out_streams)
: role_(role), in_streams_(in_streams), out_streams_(out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ =
configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = beidou_b3i_make_telemetry_decoder_gs(satellite_, dump_); telemetry_decoder_ = beidou_b3i_make_telemetry_decoder_gs(satellite_, tlm_parameters_);
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -25,6 +25,7 @@
#include "gnss_satellite.h" // for Gnss_Satellite #include "gnss_satellite.h" // for Gnss_Satellite
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -81,12 +82,11 @@ public:
private: private:
beidou_b3i_telemetry_decoder_gs_sptr telemetry_decoder_; beidou_b3i_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
std::string dump_filename_; Tlm_Conf tlm_parameters_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };
/** \} */ /** \} */

View File

@ -33,12 +33,10 @@ GalileoE1BTelemetryDecoder::GalileoE1BTelemetryDecoder(
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, 1, dump_); // unified galileo decoder set to INAV (frame_type=1) telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, tlm_parameters_, 1); // unified galileo decoder set to INAV (frame_type=1)
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -28,6 +28,7 @@
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -89,12 +90,11 @@ public:
private: private:
galileo_telemetry_decoder_gs_sptr telemetry_decoder_; galileo_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
std::string dump_filename_; Tlm_Conf tlm_parameters_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };

View File

@ -36,12 +36,10 @@ GalileoE5aTelemetryDecoder::GalileoE5aTelemetryDecoder(
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, 2, dump_); // unified galileo decoder set to FNAV (frame_type=2) telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, tlm_parameters_, 2); // unified galileo decoder set to FNAV (frame_type=2)
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -30,6 +30,7 @@
#include "gnss_satellite.h" // for Gnss_Satellite #include "gnss_satellite.h" // for Gnss_Satellite
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -91,12 +92,11 @@ public:
private: private:
galileo_telemetry_decoder_gs_sptr telemetry_decoder_; galileo_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
std::string dump_filename_; Tlm_Conf tlm_parameters_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };

View File

@ -34,12 +34,10 @@ GalileoE5bTelemetryDecoder::GalileoE5bTelemetryDecoder(
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, 1, dump_); // unified galileo decoder set to INAV (frame_type=1) telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, tlm_parameters_, 1); // unified galileo decoder set to INAV (frame_type=1)
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -28,6 +28,7 @@
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -104,12 +105,11 @@ public:
private: private:
galileo_telemetry_decoder_gs_sptr telemetry_decoder_; galileo_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
std::string dump_filename_; Tlm_Conf tlm_parameters_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };

View File

@ -33,12 +33,10 @@ GalileoE6TelemetryDecoder::GalileoE6TelemetryDecoder(
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, 3, dump_); // unified galileo decoder set to CNAV (frame_type=3) telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, tlm_parameters_, 3); // unified galileo decoder set to CNAV (frame_type=3)
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -27,6 +27,7 @@
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -103,12 +104,11 @@ public:
private: private:
galileo_telemetry_decoder_gs_sptr telemetry_decoder_; galileo_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
std::string dump_filename_; Tlm_Conf tlm_parameters_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };

View File

@ -33,12 +33,10 @@ GlonassL1CaTelemetryDecoder::GlonassL1CaTelemetryDecoder(
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = glonass_l1_ca_make_telemetry_decoder_gs(satellite_, dump_); telemetry_decoder_ = glonass_l1_ca_make_telemetry_decoder_gs(satellite_, tlm_parameters_);
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -27,6 +27,7 @@
#include "gnss_satellite.h" // for Gnss_Satellite #include "gnss_satellite.h" // for Gnss_Satellite
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -85,12 +86,11 @@ public:
private: private:
glonass_l1_ca_telemetry_decoder_gs_sptr telemetry_decoder_; glonass_l1_ca_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
std::string dump_filename_; Tlm_Conf tlm_parameters_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };

View File

@ -32,12 +32,10 @@ GlonassL2CaTelemetryDecoder::GlonassL2CaTelemetryDecoder(
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = glonass_l2_ca_make_telemetry_decoder_gs(satellite_, dump_); telemetry_decoder_ = glonass_l2_ca_make_telemetry_decoder_gs(satellite_, tlm_parameters_);
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -26,6 +26,7 @@
#include "gnss_satellite.h" // for Gnss_Satellite #include "gnss_satellite.h" // for Gnss_Satellite
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -84,12 +85,11 @@ public:
private: private:
glonass_l2_ca_telemetry_decoder_gs_sptr telemetry_decoder_; glonass_l2_ca_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
std::string dump_filename_; Tlm_Conf tlm_parameters_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };

View File

@ -32,12 +32,10 @@ GpsL1CaTelemetryDecoder::GpsL1CaTelemetryDecoder(
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = gps_l1_ca_make_telemetry_decoder_gs(satellite_, dump_); // TODO fix me telemetry_decoder_ = gps_l1_ca_make_telemetry_decoder_gs(satellite_, tlm_parameters_);
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -26,6 +26,7 @@
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "gps_l1_ca_telemetry_decoder_gs.h" #include "gps_l1_ca_telemetry_decoder_gs.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -88,12 +89,11 @@ public:
private: private:
gps_l1_ca_telemetry_decoder_gs_sptr telemetry_decoder_; gps_l1_ca_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
std::string dump_filename_; Tlm_Conf tlm_parameters_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };

View File

@ -32,12 +32,10 @@ GpsL2CTelemetryDecoder::GpsL2CTelemetryDecoder(
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = gps_l2c_make_telemetry_decoder_gs(satellite_, dump_); // TODO fix me telemetry_decoder_ = gps_l2c_make_telemetry_decoder_gs(satellite_, tlm_parameters_);
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -26,6 +26,7 @@
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "gps_l2c_telemetry_decoder_gs.h" #include "gps_l2c_telemetry_decoder_gs.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -86,12 +87,11 @@ public:
private: private:
gps_l2c_telemetry_decoder_gs_sptr telemetry_decoder_; gps_l2c_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
std::string dump_filename_; Tlm_Conf tlm_parameters_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };

View File

@ -32,12 +32,10 @@ GpsL5TelemetryDecoder::GpsL5TelemetryDecoder(
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
const std::string default_dump_filename("./navigation.dat");
DLOG(INFO) << "role " << role; DLOG(INFO) << "role " << role;
dump_ = configuration->property(role + ".dump", false); tlm_parameters_.SetFromConfiguration(configuration, role);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
// make telemetry decoder object // make telemetry decoder object
telemetry_decoder_ = gps_l5_make_telemetry_decoder_gs(satellite_, dump_); telemetry_decoder_ = gps_l5_make_telemetry_decoder_gs(satellite_, tlm_parameters_);
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
channel_ = 0; channel_ = 0;
if (in_streams_ > 1) if (in_streams_ > 1)

View File

@ -27,6 +27,7 @@
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "gps_l5_telemetry_decoder_gs.h" #include "gps_l5_telemetry_decoder_gs.h"
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include "tlm_conf.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <string> #include <string>
@ -86,12 +87,12 @@ public:
private: private:
gps_l5_telemetry_decoder_gs_sptr telemetry_decoder_; gps_l5_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
Tlm_Conf tlm_parameters_;
std::string dump_filename_; std::string dump_filename_;
std::string role_; std::string role_;
int channel_; int channel_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
bool dump_;
}; };

View File

@ -60,8 +60,19 @@ target_link_libraries(telemetry_decoder_gr_blocks
PRIVATE PRIVATE
Gflags::gflags Gflags::gflags
Glog::glog 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) if(GNURADIO_USES_STD_POINTERS)
target_compile_definitions(telemetry_decoder_gr_blocks target_compile_definitions(telemetry_decoder_gr_blocks
PUBLIC -DGNURADIO_USES_STD_POINTERS=1 PUBLIC -DGNURADIO_USES_STD_POINTERS=1

View File

@ -29,27 +29,51 @@
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <matio.h> // for Mat_VarCreate
#include <pmt/pmt.h> // for make_any #include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp #include <pmt/pmt_sugar.h> // for mp
#include <cstddef> // for size_t
#include <cstdlib> // for abs #include <cstdlib> // for abs
#include <exception> // for exception #include <exception> // for exception
#include <iostream> // for cout #include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared #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 #define CRC_ERROR_LIMIT 8
beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_telemetry_decoder_gs_sptr
beidou_b1i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump) beidou_b1i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf)
{ {
return beidou_b1i_telemetry_decoder_gs_sptr(new beidou_b1i_telemetry_decoder_gs(satellite, dump)); return beidou_b1i_telemetry_decoder_gs_sptr(new beidou_b1i_telemetry_decoder_gs(satellite, conf));
} }
beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs( beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump) : gr::block("beidou_b1i_telemetry_decoder_gs", const Tlm_Conf &conf) : gr::block("beidou_b1i_telemetry_decoder_gs",
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{ {
// prevent telemetry symbols accumulation in output buffers // prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1); this->set_max_noutput_items(1);
@ -58,7 +82,9 @@ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs(
// Control messages to tracking block // Control messages to tracking block
this->message_port_register_out(pmt::mp("telemetry_to_trk")); this->message_port_register_out(pmt::mp("telemetry_to_trk"));
// initialize internal vars // initialize internal vars
d_dump = dump; d_dump_filename = conf.dump_filename;
d_dump = conf.dump;
d_dump_mat = conf.dump_mat;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
LOG(INFO) << "Initializing BeiDou B1I Telemetry Decoding for satellite " << this->d_satellite; LOG(INFO) << "Initializing BeiDou B1I Telemetry Decoding for satellite " << this->d_satellite;
@ -104,8 +130,10 @@ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs(
beidou_b1i_telemetry_decoder_gs::~beidou_b1i_telemetry_decoder_gs() beidou_b1i_telemetry_decoder_gs::~beidou_b1i_telemetry_decoder_gs()
{ {
DLOG(INFO) << "BeiDou B1I Telemetry decoder block (channel " << d_channel << ") destructor called."; DLOG(INFO) << "BeiDou B1I Telemetry decoder block (channel " << d_channel << ") destructor called.";
size_t pos = 0;
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
pos = d_dump_file.tellp();
try try
{ {
d_dump_file.close(); d_dump_file.close();
@ -114,7 +142,127 @@ beidou_b1i_telemetry_decoder_gs::~beidou_b1i_telemetry_decoder_gs()
{ {
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
} }
if (pos == 0)
{
errorlib::error_code ec;
if (!fs::remove(fs::path(d_dump_filename), ec))
{
LOG(WARNING) << "Error deleting temporary file";
}
}
} }
if (d_dump && (pos != 0) && d_dump_mat)
{
try
{
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++)
{
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");
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;
} }
@ -348,7 +496,6 @@ void beidou_b1i_telemetry_decoder_gs::set_channel(int32_t channel)
{ {
try try
{ {
d_dump_filename = "telemetry";
d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(std::to_string(d_channel));
d_dump_filename.append(".dat"); d_dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
@ -585,12 +732,17 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_
{ {
double tmp_double; double tmp_double;
uint64_t tmp_ulong_int; uint64_t tmp_ulong_int;
int32_t tmp_int;
tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0; tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = current_symbol.Tracking_sample_counter; tmp_ulong_int = current_symbol.Tracking_sample_counter;
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t)); d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
tmp_double = static_cast<double>(d_TOW_at_Preamble_ms) / 1000.0; tmp_double = static_cast<double>(d_TOW_at_Preamble_ms) / 1000.0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_int = (current_symbol.Prompt_I > 0.0 ? 1 : -1);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
tmp_int = static_cast<int32_t>(current_symbol.PRN);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
} }
catch (const std::ifstream::failure &e) catch (const std::ifstream::failure &e)
{ {

View File

@ -26,6 +26,7 @@
#include "beidou_dnav_navigation_message.h" #include "beidou_dnav_navigation_message.h"
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "tlm_conf.h"
#include <boost/circular_buffer.hpp> #include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> // for block #include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star #include <gnuradio/types.h> // for gr_vector_const_void_star
@ -46,7 +47,7 @@ using beidou_b1i_telemetry_decoder_gs_sptr = gnss_shared_ptr<beidou_b1i_telemetr
beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_make_telemetry_decoder_gs( beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
/*! /*!
@ -70,9 +71,11 @@ public:
private: private:
friend beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_make_telemetry_decoder_gs( friend beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
beidou_b1i_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); 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_subframe(float *symbols);
void decode_word(int32_t word_counter, const float *enc_word_symbols, int32_t *dec_word_symbols); void decode_word(int32_t word_counter, const float *enc_word_symbols, int32_t *dec_word_symbols);
@ -119,6 +122,7 @@ private:
bool d_sent_tlm_failed_msg; bool d_sent_tlm_failed_msg;
bool Flag_valid_word; bool Flag_valid_word;
bool d_dump; bool d_dump;
bool d_dump_mat;
}; };

View File

@ -28,25 +28,49 @@
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <matio.h> // for Mat_VarCreate
#include <pmt/pmt.h> // for make_any #include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp #include <pmt/pmt_sugar.h> // for mp
#include <cstddef> // for size_t
#include <cstdlib> // for abs #include <cstdlib> // for abs
#include <exception> // for exception #include <exception> // for exception
#include <iostream> // for cout #include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared #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 #define CRC_ERROR_LIMIT 8
beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_telemetry_decoder_gs_sptr
beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite,
bool dump) const Tlm_Conf &conf)
{ {
return beidou_b3i_telemetry_decoder_gs_sptr(new beidou_b3i_telemetry_decoder_gs(satellite, dump)); return beidou_b3i_telemetry_decoder_gs_sptr(new beidou_b3i_telemetry_decoder_gs(satellite, conf));
} }
beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs( beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs(
const Gnss_Satellite &satellite, bool dump) const Gnss_Satellite &satellite, const Tlm_Conf &conf)
: gr::block("beidou_b3i_telemetry_decoder_gs", : gr::block("beidou_b3i_telemetry_decoder_gs",
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
@ -58,7 +82,9 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs(
// Control messages to tracking block // Control messages to tracking block
this->message_port_register_out(pmt::mp("telemetry_to_trk")); this->message_port_register_out(pmt::mp("telemetry_to_trk"));
// initialize internal vars // initialize internal vars
d_dump = dump; d_dump_filename = conf.dump_filename;
d_dump = conf.dump;
d_dump_mat = conf.dump_mat;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
LOG(INFO) << "Initializing BeiDou B3I Telemetry Decoding for satellite " << this->d_satellite; LOG(INFO) << "Initializing BeiDou B3I Telemetry Decoding for satellite " << this->d_satellite;
@ -104,8 +130,10 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs(
beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs() beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs()
{ {
DLOG(INFO) << "BeiDou B3I Telemetry decoder block (channel " << d_channel << ") destructor called."; DLOG(INFO) << "BeiDou B3I Telemetry decoder block (channel " << d_channel << ") destructor called.";
size_t pos = 0;
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
pos = d_dump_file.tellp();
try try
{ {
d_dump_file.close(); d_dump_file.close();
@ -114,7 +142,127 @@ beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs()
{ {
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
} }
if (pos == 0)
{
errorlib::error_code ec;
if (!fs::remove(fs::path(d_dump_filename), ec))
{
LOG(WARNING) << "Error deleting temporary file";
}
}
} }
if (d_dump && (pos != 0) && d_dump_mat)
{
try
{
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++)
{
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");
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;
} }
@ -365,7 +513,6 @@ void beidou_b3i_telemetry_decoder_gs::set_channel(int32_t channel)
{ {
try try
{ {
d_dump_filename = "telemetry";
d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(std::to_string(d_channel));
d_dump_filename.append(".dat"); d_dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
@ -615,12 +762,17 @@ int beidou_b3i_telemetry_decoder_gs::general_work(
{ {
double tmp_double; double tmp_double;
uint64_t tmp_ulong_int; uint64_t tmp_ulong_int;
int32_t tmp_int;
tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0; tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = current_symbol.Tracking_sample_counter; tmp_ulong_int = current_symbol.Tracking_sample_counter;
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t)); d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
tmp_double = static_cast<double>(d_TOW_at_Preamble_ms) / 1000.0; tmp_double = static_cast<double>(d_TOW_at_Preamble_ms) / 1000.0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_int = (current_symbol.Prompt_I > 0.0 ? 1 : -1);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
tmp_int = static_cast<int32_t>(current_symbol.PRN);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
} }
catch (const std::ifstream::failure &e) catch (const std::ifstream::failure &e)
{ {

View File

@ -23,6 +23,7 @@
#include "beidou_dnav_navigation_message.h" #include "beidou_dnav_navigation_message.h"
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "tlm_conf.h"
#include <boost/circular_buffer.hpp> #include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> // for block #include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star #include <gnuradio/types.h> // for gr_vector_const_void_star
@ -45,7 +46,7 @@ using beidou_b3i_telemetry_decoder_gs_sptr =
beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs( beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
/*! /*!
* \brief This class implements a block that decodes the BeiDou DNAV data. * \brief This class implements a block that decodes the BeiDou DNAV data.
@ -68,9 +69,11 @@ public:
private: private:
friend beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs( friend beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
beidou_b3i_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); 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_subframe(float *symbols);
void decode_word(int32_t word_counter, const float *enc_word_symbols, void decode_word(int32_t word_counter, const float *enc_word_symbols,
@ -116,6 +119,7 @@ private:
bool d_sent_tlm_failed_msg; bool d_sent_tlm_failed_msg;
bool Flag_valid_word; bool Flag_valid_word;
bool d_dump; bool d_dump;
bool d_dump_mat;
}; };

View File

@ -34,29 +34,52 @@
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <matio.h> // for Mat_VarCreate
#include <pmt/pmt.h> // for make_any #include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp #include <pmt/pmt_sugar.h> // for mp
#include <cmath> // for fmod #include <cmath> // for fmod
#include <cstddef> // for size_t
#include <cstdlib> // for abs #include <cstdlib> // for abs
#include <exception> // for exception #include <exception> // for exception
#include <iostream> // for cout #include <iostream> // for cout
#include <memory> // for make_shared #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
#define CRC_ERROR_LIMIT 6 #define CRC_ERROR_LIMIT 6
galileo_telemetry_decoder_gs_sptr galileo_telemetry_decoder_gs_sptr
galileo_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, int frame_type, bool dump) galileo_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf, int frame_type)
{ {
return galileo_telemetry_decoder_gs_sptr(new galileo_telemetry_decoder_gs(satellite, frame_type, dump)); return galileo_telemetry_decoder_gs_sptr(new galileo_telemetry_decoder_gs(satellite, conf, frame_type));
} }
galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs( galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
const Gnss_Satellite &satellite, int frame_type, const Gnss_Satellite &satellite,
bool dump) : gr::block("galileo_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), const Tlm_Conf &conf,
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) int frame_type) : gr::block("galileo_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{ {
// prevent telemetry symbols accumulation in output buffers // prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1); this->set_max_noutput_items(1);
@ -69,7 +92,9 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_band = '1'; d_band = '1';
// initialize internal vars // initialize internal vars
d_dump = dump; d_dump_filename = conf.dump_filename;
d_dump = conf.dump;
d_dump_mat = conf.dump_mat;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
d_frame_type = frame_type; d_frame_type = frame_type;
DLOG(INFO) << "Initializing GALILEO UNIFIED TELEMETRY DECODER"; DLOG(INFO) << "Initializing GALILEO UNIFIED TELEMETRY DECODER";
@ -213,8 +238,10 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
galileo_telemetry_decoder_gs::~galileo_telemetry_decoder_gs() galileo_telemetry_decoder_gs::~galileo_telemetry_decoder_gs()
{ {
DLOG(INFO) << "Galileo Telemetry decoder block (channel " << d_channel << ") destructor called."; DLOG(INFO) << "Galileo Telemetry decoder block (channel " << d_channel << ") destructor called.";
size_t pos = 0;
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
pos = d_dump_file.tellp();
try try
{ {
d_dump_file.close(); d_dump_file.close();
@ -223,7 +250,127 @@ galileo_telemetry_decoder_gs::~galileo_telemetry_decoder_gs()
{ {
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
} }
if (pos == 0)
{
errorlib::error_code ec;
if (!fs::remove(fs::path(d_dump_filename), ec))
{
LOG(WARNING) << "Error deleting temporary file";
}
}
} }
if (d_dump && (pos != 0) && d_dump_mat)
{
try
{
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++)
{
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");
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;
} }
@ -535,7 +682,6 @@ void galileo_telemetry_decoder_gs::set_channel(int32_t channel)
{ {
try try
{ {
d_dump_filename = "telemetry";
d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(std::to_string(d_channel));
d_dump_filename.append(".dat"); d_dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
@ -907,12 +1053,31 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
{ {
double tmp_double; double tmp_double;
uint64_t tmp_ulong_int; uint64_t tmp_ulong_int;
int32_t tmp_int;
tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0; tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = current_symbol.Tracking_sample_counter; tmp_ulong_int = current_symbol.Tracking_sample_counter;
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t)); d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
tmp_double = static_cast<double>(d_TOW_at_Preamble_ms) / 1000.0; tmp_double = static_cast<double>(d_TOW_at_Preamble_ms) / 1000.0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
switch (d_frame_type)
{
case 1:
tmp_int = (current_symbol.Prompt_I > 0.0 ? 1 : -1);
break;
case 2:
tmp_int = (current_symbol.Prompt_Q > 0.0 ? 1 : -1);
break;
case 3:
tmp_int = (current_symbol.Prompt_I > 0.0 ? 1 : -1);
break;
default:
tmp_int = 0;
break;
}
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
tmp_int = static_cast<int32_t>(current_symbol.PRN);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
} }
catch (const std::ifstream::failure &e) catch (const std::ifstream::failure &e)
{ {

View File

@ -28,6 +28,7 @@
#include "galileo_inav_message.h" #include "galileo_inav_message.h"
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "tlm_conf.h"
#include <boost/circular_buffer.hpp> #include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> // for block #include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star #include <gnuradio/types.h> // for gr_vector_const_void_star
@ -49,8 +50,8 @@ using galileo_telemetry_decoder_gs_sptr = gnss_shared_ptr<galileo_telemetry_deco
galileo_telemetry_decoder_gs_sptr galileo_make_telemetry_decoder_gs( galileo_telemetry_decoder_gs_sptr galileo_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
int frame_type, const Tlm_Conf &conf,
bool dump); int frame_type);
/*! /*!
* \brief This class implements a block that decodes the INAV and FNAV data defined in Galileo ICD * \brief This class implements a block that decodes the INAV and FNAV data defined in Galileo ICD
@ -74,14 +75,16 @@ public:
private: private:
friend galileo_telemetry_decoder_gs_sptr galileo_make_telemetry_decoder_gs( friend galileo_telemetry_decoder_gs_sptr galileo_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
int frame_type, const Tlm_Conf &conf,
bool dump); int frame_type);
galileo_telemetry_decoder_gs(const Gnss_Satellite &satellite, int frame_type, bool dump); galileo_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf, int frame_type);
const int32_t d_nn = 2; // Coding rate 1/n const int32_t d_nn = 2; // Coding rate 1/n
const int32_t d_KK = 7; // Constraint Length 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 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 deinterleaver(int32_t rows, int32_t cols, const float *in, float *out);
void decode_INAV_word(float *page_part_symbols, int32_t frame_length); void decode_INAV_word(float *page_part_symbols, int32_t frame_length);
@ -140,6 +143,7 @@ private:
bool d_flag_parity; bool d_flag_parity;
bool d_flag_preamble; bool d_flag_preamble;
bool d_dump; bool d_dump;
bool d_dump_mat;
}; };

View File

@ -25,28 +25,52 @@
#include "glonass_gnav_utc_model.h" #include "glonass_gnav_utc_model.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <matio.h> // for Mat_VarCreate
#include <pmt/pmt.h> // for make_any #include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp #include <pmt/pmt_sugar.h> // for mp
#include <cmath> // for floor, round #include <cmath> // for floor, round
#include <cstddef> // for size_t
#include <cstdlib> // for abs #include <cstdlib> // for abs
#include <exception> // for exception #include <exception> // for exception
#include <iostream> // for cout #include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared #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 #define CRC_ERROR_LIMIT 6
glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_telemetry_decoder_gs_sptr
glonass_l1_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump) glonass_l1_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf)
{ {
return glonass_l1_ca_telemetry_decoder_gs_sptr(new glonass_l1_ca_telemetry_decoder_gs(satellite, dump)); return glonass_l1_ca_telemetry_decoder_gs_sptr(new glonass_l1_ca_telemetry_decoder_gs(satellite, conf));
} }
glonass_l1_ca_telemetry_decoder_gs::glonass_l1_ca_telemetry_decoder_gs( glonass_l1_ca_telemetry_decoder_gs::glonass_l1_ca_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump) : gr::block("glonass_l1_ca_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), const Tlm_Conf &conf) : gr::block("glonass_l1_ca_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{ {
// prevent telemetry symbols accumulation in output buffers // prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1); this->set_max_noutput_items(1);
@ -55,7 +79,9 @@ glonass_l1_ca_telemetry_decoder_gs::glonass_l1_ca_telemetry_decoder_gs(
// Control messages to tracking block // Control messages to tracking block
this->message_port_register_out(pmt::mp("telemetry_to_trk")); this->message_port_register_out(pmt::mp("telemetry_to_trk"));
// initialize internal vars // initialize internal vars
d_dump = dump; d_dump_filename = conf.dump_filename;
d_dump = conf.dump;
d_dump_mat = conf.dump_mat;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
LOG(INFO) << "Initializing GLONASS L1 CA TELEMETRY DECODING"; LOG(INFO) << "Initializing GLONASS L1 CA TELEMETRY DECODING";
@ -97,8 +123,10 @@ glonass_l1_ca_telemetry_decoder_gs::glonass_l1_ca_telemetry_decoder_gs(
glonass_l1_ca_telemetry_decoder_gs::~glonass_l1_ca_telemetry_decoder_gs() glonass_l1_ca_telemetry_decoder_gs::~glonass_l1_ca_telemetry_decoder_gs()
{ {
DLOG(INFO) << "Glonass L1 Telemetry decoder block (channel " << d_channel << ") destructor called."; DLOG(INFO) << "Glonass L1 Telemetry decoder block (channel " << d_channel << ") destructor called.";
size_t pos = 0;
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
pos = d_dump_file.tellp();
try try
{ {
d_dump_file.close(); d_dump_file.close();
@ -107,7 +135,127 @@ glonass_l1_ca_telemetry_decoder_gs::~glonass_l1_ca_telemetry_decoder_gs()
{ {
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
} }
if (pos == 0)
{
errorlib::error_code ec;
if (!fs::remove(fs::path(d_dump_filename), ec))
{
LOG(WARNING) << "Error deleting temporary file";
}
}
} }
if (d_dump && (pos != 0))
{
try
{
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++)
{
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");
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;
} }
@ -234,7 +382,6 @@ void glonass_l1_ca_telemetry_decoder_gs::set_channel(int32_t channel)
{ {
try try
{ {
d_dump_filename = "telemetry";
d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(std::to_string(d_channel));
d_dump_filename.append(".dat"); d_dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
@ -414,12 +561,17 @@ int glonass_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu
{ {
double tmp_double; double tmp_double;
uint64_t tmp_ulong_int; uint64_t tmp_ulong_int;
int32_t tmp_int;
tmp_double = d_TOW_at_current_symbol; tmp_double = d_TOW_at_current_symbol;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = current_symbol.Tracking_sample_counter; tmp_ulong_int = current_symbol.Tracking_sample_counter;
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t)); d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
tmp_double = 0; tmp_double = 0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_int = (current_symbol.Prompt_I > 0.0 ? 1 : -1);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
tmp_int = static_cast<int32_t>(current_symbol.PRN);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
} }
catch (const std::ifstream::failure &e) catch (const std::ifstream::failure &e)
{ {

View File

@ -27,6 +27,7 @@
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "tlm_conf.h"
#include <boost/circular_buffer.hpp> #include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> // for block #include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star #include <gnuradio/types.h> // for gr_vector_const_void_star
@ -47,7 +48,7 @@ using glonass_l1_ca_telemetry_decoder_gs_sptr = gnss_shared_ptr<glonass_l1_ca_te
glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs( glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
/*! /*!
* \brief This class implements a block that decodes the GNAV data defined in GLONASS ICD v5.1 * \brief This class implements a block that decodes the GNAV data defined in GLONASS ICD v5.1
@ -74,14 +75,16 @@ public:
private: private:
friend glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs( friend glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
glonass_l1_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); glonass_l1_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
const std::array<uint16_t, GLONASS_GNAV_PREAMBLE_LENGTH_BITS> d_preambles_bits{GLONASS_GNAV_PREAMBLE}; const std::array<uint16_t, GLONASS_GNAV_PREAMBLE_LENGTH_BITS> d_preambles_bits{GLONASS_GNAV_PREAMBLE};
const int32_t d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS; 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); void decode_string(const double *symbols, int32_t frame_length);
// Help with coherent tracking // Help with coherent tracking
@ -118,6 +121,7 @@ private:
bool flag_TOW_set; // Indicates when time of week is set bool flag_TOW_set; // Indicates when time of week is set
bool Flag_valid_word; bool Flag_valid_word;
bool d_dump; bool d_dump;
bool d_dump_mat;
}; };

View File

@ -25,28 +25,52 @@
#include "glonass_gnav_utc_model.h" #include "glonass_gnav_utc_model.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <matio.h> // for Mat_VarCreate
#include <pmt/pmt.h> // for make_any #include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp #include <pmt/pmt_sugar.h> // for mp
#include <cmath> // for floor, round #include <cmath> // for floor, round
#include <cstddef> // for size_t
#include <cstdlib> // for abs #include <cstdlib> // for abs
#include <exception> // for exception #include <exception> // for exception
#include <iostream> // for cout #include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared #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 #define CRC_ERROR_LIMIT 6
glonass_l2_ca_telemetry_decoder_gs_sptr glonass_l2_ca_telemetry_decoder_gs_sptr
glonass_l2_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump) glonass_l2_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf)
{ {
return glonass_l2_ca_telemetry_decoder_gs_sptr(new glonass_l2_ca_telemetry_decoder_gs(satellite, dump)); return glonass_l2_ca_telemetry_decoder_gs_sptr(new glonass_l2_ca_telemetry_decoder_gs(satellite, conf));
} }
glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs( glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump) : gr::block("glonass_l2_ca_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), const Tlm_Conf &conf) : gr::block("glonass_l2_ca_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{ {
// prevent telemetry symbols accumulation in output buffers // prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1); this->set_max_noutput_items(1);
@ -55,7 +79,9 @@ glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs(
// Control messages to tracking block // Control messages to tracking block
this->message_port_register_out(pmt::mp("telemetry_to_trk")); this->message_port_register_out(pmt::mp("telemetry_to_trk"));
// initialize internal vars // initialize internal vars
d_dump = dump; d_dump_filename = conf.dump_filename;
d_dump = conf.dump;
d_dump_mat = conf.dump_mat;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
LOG(INFO) << "Initializing GLONASS L2 CA TELEMETRY DECODING"; LOG(INFO) << "Initializing GLONASS L2 CA TELEMETRY DECODING";
@ -97,8 +123,10 @@ glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs(
glonass_l2_ca_telemetry_decoder_gs::~glonass_l2_ca_telemetry_decoder_gs() glonass_l2_ca_telemetry_decoder_gs::~glonass_l2_ca_telemetry_decoder_gs()
{ {
DLOG(INFO) << "Glonass L2 Telemetry decoder block (channel " << d_channel << ") destructor called."; DLOG(INFO) << "Glonass L2 Telemetry decoder block (channel " << d_channel << ") destructor called.";
size_t pos = 0;
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
pos = d_dump_file.tellp();
try try
{ {
d_dump_file.close(); d_dump_file.close();
@ -107,7 +135,127 @@ glonass_l2_ca_telemetry_decoder_gs::~glonass_l2_ca_telemetry_decoder_gs()
{ {
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
} }
if (pos == 0)
{
errorlib::error_code ec;
if (!fs::remove(fs::path(d_dump_filename), ec))
{
LOG(WARNING) << "Error deleting temporary file";
}
}
} }
if (d_dump && (pos != 0) && d_dump_mat)
{
try
{
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++)
{
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");
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;
} }
@ -233,7 +381,6 @@ void glonass_l2_ca_telemetry_decoder_gs::set_channel(int32_t channel)
{ {
try try
{ {
d_dump_filename = "telemetry";
d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(std::to_string(d_channel));
d_dump_filename.append(".dat"); d_dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
@ -413,12 +560,17 @@ int glonass_l2_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu
{ {
double tmp_double; double tmp_double;
uint64_t tmp_ulong_int; uint64_t tmp_ulong_int;
int32_t tmp_int;
tmp_double = d_TOW_at_current_symbol; tmp_double = d_TOW_at_current_symbol;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = current_symbol.Tracking_sample_counter; tmp_ulong_int = current_symbol.Tracking_sample_counter;
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t)); d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
tmp_double = 0; tmp_double = 0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_int = (current_symbol.Prompt_I > 0.0 ? 1 : -1);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
tmp_int = static_cast<int32_t>(current_symbol.PRN);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
} }
catch (const std::ifstream::failure &e) catch (const std::ifstream::failure &e)
{ {

View File

@ -26,6 +26,7 @@
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "tlm_conf.h"
#include <boost/circular_buffer.hpp> #include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> #include <gnuradio/block.h>
#include <gnuradio/types.h> // for gr_vector_const_void_star #include <gnuradio/types.h> // for gr_vector_const_void_star
@ -46,7 +47,7 @@ using glonass_l2_ca_telemetry_decoder_gs_sptr = gnss_shared_ptr<glonass_l2_ca_te
glonass_l2_ca_telemetry_decoder_gs_sptr glonass_l2_ca_make_telemetry_decoder_gs( glonass_l2_ca_telemetry_decoder_gs_sptr glonass_l2_ca_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
/*! /*!
* \brief This class implements a block that decodes the GNAV data defined in GLONASS ICD v5.1 * \brief This class implements a block that decodes the GNAV data defined in GLONASS ICD v5.1
@ -72,14 +73,16 @@ public:
private: private:
friend glonass_l2_ca_telemetry_decoder_gs_sptr glonass_l2_ca_make_telemetry_decoder_gs( friend glonass_l2_ca_telemetry_decoder_gs_sptr glonass_l2_ca_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
glonass_l2_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); glonass_l2_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
const std::array<uint16_t, GLONASS_GNAV_PREAMBLE_LENGTH_BITS> d_preambles_bits{GLONASS_GNAV_PREAMBLE}; const std::array<uint16_t, GLONASS_GNAV_PREAMBLE_LENGTH_BITS> d_preambles_bits{GLONASS_GNAV_PREAMBLE};
const int32_t d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS; 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); void decode_string(const double *symbols, int32_t frame_length);
// Storage for incoming data // Storage for incoming data
@ -112,6 +115,7 @@ private:
bool d_flag_preamble; // Flag indicating when preamble was found bool d_flag_preamble; // Flag indicating when preamble was found
bool flag_TOW_set; // Indicates when time of week is set bool flag_TOW_set; // Indicates when time of week is set
bool d_dump; bool d_dump;
bool d_dump_mat;
}; };

View File

@ -24,14 +24,37 @@
#include "gps_utc_model.h" // for Gps_Utc_Model #include "gps_utc_model.h" // for Gps_Utc_Model
#include <glog/logging.h> #include <glog/logging.h>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <matio.h> // for Mat_VarCreate
#include <pmt/pmt.h> // for make_any #include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp #include <pmt/pmt_sugar.h> // for mp
#include <cmath> // for round #include <cmath> // for round
#include <cstddef> // for size_t
#include <cstring> // for memcpy #include <cstring> // for memcpy
#include <exception> // for exception #include <exception> // for exception
#include <iostream> // for cout #include <iostream> // for cout
#include <memory> // for shared_ptr #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 #ifdef COMPILER_HAS_ROTL
#include <bit> #include <bit>
@ -49,16 +72,16 @@ auto rotl = [](uint32_t x, uint32_t n) { return (((x) << (n)) ^ ((x) >> (32 - (n
gps_l1_ca_telemetry_decoder_gs_sptr gps_l1_ca_telemetry_decoder_gs_sptr
gps_l1_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump) gps_l1_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf)
{ {
return gps_l1_ca_telemetry_decoder_gs_sptr(new gps_l1_ca_telemetry_decoder_gs(satellite, dump)); return gps_l1_ca_telemetry_decoder_gs_sptr(new gps_l1_ca_telemetry_decoder_gs(satellite, conf));
} }
gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs( gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump) : gr::block("gps_navigation_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), const Tlm_Conf &conf) : gr::block("gps_navigation_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{ {
// prevent telemetry symbols accumulation in output buffers // prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1); this->set_max_noutput_items(1);
@ -71,7 +94,10 @@ gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs(
d_sent_tlm_failed_msg = false; d_sent_tlm_failed_msg = false;
// initialize internal vars // initialize internal vars
d_dump = dump; d_dump_filename = conf.dump_filename;
d_dump = conf.dump;
d_dump_mat = conf.dump_mat;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
DLOG(INFO) << "Initializing GPS L1 TELEMETRY DECODER"; DLOG(INFO) << "Initializing GPS L1 TELEMETRY DECODER";
@ -119,8 +145,10 @@ gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs(
gps_l1_ca_telemetry_decoder_gs::~gps_l1_ca_telemetry_decoder_gs() 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."; DLOG(INFO) << "GPS L1 C/A Telemetry decoder block (channel " << d_channel << ") destructor called.";
size_t pos = 0;
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
pos = d_dump_file.tellp();
try try
{ {
d_dump_file.close(); d_dump_file.close();
@ -129,7 +157,127 @@ gps_l1_ca_telemetry_decoder_gs::~gps_l1_ca_telemetry_decoder_gs()
{ {
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
} }
if (pos == 0)
{
errorlib::error_code ec;
if (!fs::remove(fs::path(d_dump_filename), ec))
{
LOG(WARNING) << "Error deleting temporary file";
}
}
} }
if (d_dump && (pos != 0) && d_dump_mat)
{
try
{
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++)
{
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");
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;
} }
@ -181,7 +329,6 @@ void gps_l1_ca_telemetry_decoder_gs::set_channel(int32_t channel)
{ {
try try
{ {
d_dump_filename = "telemetry";
d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(std::to_string(d_channel));
d_dump_filename.append(".dat"); d_dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
@ -501,12 +648,17 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__
{ {
double tmp_double; double tmp_double;
uint64_t tmp_ulong_int; uint64_t tmp_ulong_int;
int32_t tmp_int;
tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0; tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = current_symbol.Tracking_sample_counter; tmp_ulong_int = current_symbol.Tracking_sample_counter;
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t)); d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
tmp_double = static_cast<double>(d_TOW_at_Preamble_ms) / 1000.0; tmp_double = static_cast<double>(d_TOW_at_Preamble_ms) / 1000.0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_int = (current_symbol.Prompt_I > 0.0 ? 1 : -1);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
tmp_int = static_cast<int32_t>(current_symbol.PRN);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
} }
catch (const std::ifstream::failure &e) catch (const std::ifstream::failure &e)
{ {

View File

@ -25,6 +25,7 @@
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "gps_navigation_message.h" #include "gps_navigation_message.h"
#include "tlm_conf.h"
#include <boost/circular_buffer.hpp> #include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> // for block #include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star #include <gnuradio/types.h> // for gr_vector_const_void_star
@ -46,7 +47,7 @@ using gps_l1_ca_telemetry_decoder_gs_sptr = gnss_shared_ptr<gps_l1_ca_telemetry_
gps_l1_ca_telemetry_decoder_gs_sptr gps_l1_ca_make_telemetry_decoder_gs( gps_l1_ca_telemetry_decoder_gs_sptr gps_l1_ca_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
/*! /*!
* \brief This class implements a block that decodes the NAV data defined in IS-GPS-200K * \brief This class implements a block that decodes the NAV data defined in IS-GPS-200K
@ -68,9 +69,11 @@ public:
private: private:
friend gps_l1_ca_telemetry_decoder_gs_sptr gps_l1_ca_make_telemetry_decoder_gs( friend gps_l1_ca_telemetry_decoder_gs_sptr gps_l1_ca_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
gps_l1_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); 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 gps_word_parityCheck(uint32_t gpsword);
bool decode_subframe(); bool decode_subframe();
@ -110,6 +113,7 @@ private:
bool d_flag_PLL_180_deg_phase_locked; bool d_flag_PLL_180_deg_phase_locked;
bool d_flag_TOW_set; bool d_flag_TOW_set;
bool d_dump; bool d_dump;
bool d_dump_mat;
}; };

View File

@ -27,26 +27,50 @@
#include "gps_cnav_utc_model.h" // for Gps_CNAV_Utc_Model #include "gps_cnav_utc_model.h" // for Gps_CNAV_Utc_Model
#include <glog/logging.h> #include <glog/logging.h>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <matio.h> // for Mat_VarCreate
#include <pmt/pmt.h> // for make_any #include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp #include <pmt/pmt_sugar.h> // for mp
#include <bitset> // for bitset #include <bitset> // for bitset
#include <cmath> // for round #include <cmath> // for round
#include <cstddef> // for size_t
#include <exception> // for exception #include <exception> // for exception
#include <iostream> // for cout #include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared #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_telemetry_decoder_gs_sptr
gps_l2c_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump) gps_l2c_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf)
{ {
return gps_l2c_telemetry_decoder_gs_sptr(new gps_l2c_telemetry_decoder_gs(satellite, dump)); return gps_l2c_telemetry_decoder_gs_sptr(new gps_l2c_telemetry_decoder_gs(satellite, conf));
} }
gps_l2c_telemetry_decoder_gs::gps_l2c_telemetry_decoder_gs( gps_l2c_telemetry_decoder_gs::gps_l2c_telemetry_decoder_gs(
const Gnss_Satellite &satellite, bool dump) : gr::block("gps_l2c_telemetry_decoder_gs", const Gnss_Satellite &satellite,
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), const Tlm_Conf &conf) : gr::block("gps_l2c_telemetry_decoder_gs",
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{ {
// prevent telemetry symbols accumulation in output buffers // prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1); this->set_max_noutput_items(1);
@ -59,7 +83,9 @@ gps_l2c_telemetry_decoder_gs::gps_l2c_telemetry_decoder_gs(
d_max_symbols_without_valid_frame = GPS_L2_CNAV_DATA_PAGE_BITS * GPS_L2_SYMBOLS_PER_BIT * 5; // rise alarm if 5 consecutive subframes have no valid CRC d_max_symbols_without_valid_frame = GPS_L2_CNAV_DATA_PAGE_BITS * GPS_L2_SYMBOLS_PER_BIT * 5; // rise alarm if 5 consecutive subframes have no valid CRC
// initialize internal vars // initialize internal vars
d_dump = dump; d_dump_filename = conf.dump_filename;
d_dump = conf.dump;
d_dump_mat = conf.dump_mat;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
DLOG(INFO) << "GPS L2C M TELEMETRY PROCESSING: satellite " << d_satellite; DLOG(INFO) << "GPS L2C M TELEMETRY PROCESSING: satellite " << d_satellite;
// set_output_multiple (1); // set_output_multiple (1);
@ -81,8 +107,10 @@ gps_l2c_telemetry_decoder_gs::gps_l2c_telemetry_decoder_gs(
gps_l2c_telemetry_decoder_gs::~gps_l2c_telemetry_decoder_gs() gps_l2c_telemetry_decoder_gs::~gps_l2c_telemetry_decoder_gs()
{ {
DLOG(INFO) << "GPS L2C Telemetry decoder block (channel " << d_channel << ") destructor called."; DLOG(INFO) << "GPS L2C Telemetry decoder block (channel " << d_channel << ") destructor called.";
size_t pos = 0;
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
pos = d_dump_file.tellp();
try try
{ {
d_dump_file.close(); d_dump_file.close();
@ -91,7 +119,127 @@ gps_l2c_telemetry_decoder_gs::~gps_l2c_telemetry_decoder_gs()
{ {
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
} }
if (pos == 0)
{
errorlib::error_code ec;
if (!fs::remove(fs::path(d_dump_filename), ec))
{
LOG(WARNING) << "Error deleting temporary file";
}
}
} }
if (d_dump && (pos != 0) && d_dump_mat)
{
try
{
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++)
{
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");
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;
} }
@ -113,7 +261,6 @@ void gps_l2c_telemetry_decoder_gs::set_channel(int channel)
{ {
try try
{ {
d_dump_filename = "telemetry_L2CM_";
d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(std::to_string(d_channel));
d_dump_filename.append(".dat"); d_dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
@ -252,12 +399,17 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
{ {
double tmp_double; double tmp_double;
uint64_t tmp_ulong_int; uint64_t tmp_ulong_int;
int32_t tmp_int;
tmp_double = d_TOW_at_current_symbol; tmp_double = d_TOW_at_current_symbol;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = current_synchro_data.Tracking_sample_counter; tmp_ulong_int = current_synchro_data.Tracking_sample_counter;
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t)); d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
tmp_double = d_TOW_at_Preamble; tmp_double = d_TOW_at_Preamble;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_int = (current_synchro_data.Prompt_I > 0.0 ? 1 : -1);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
tmp_int = static_cast<int32_t>(current_synchro_data.PRN);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
} }
catch (const std::ifstream::failure &e) catch (const std::ifstream::failure &e)
{ {

View File

@ -23,6 +23,7 @@
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "gps_cnav_navigation_message.h" #include "gps_cnav_navigation_message.h"
#include "tlm_conf.h"
#include <gnuradio/block.h> #include <gnuradio/block.h>
#include <gnuradio/types.h> // for gr_vector_const_void_star #include <gnuradio/types.h> // for gr_vector_const_void_star
#include <cstdint> #include <cstdint>
@ -46,7 +47,7 @@ using gps_l2c_telemetry_decoder_gs_sptr = gnss_shared_ptr<gps_l2c_telemetry_deco
gps_l2c_telemetry_decoder_gs_sptr gps_l2c_make_telemetry_decoder_gs( gps_l2c_telemetry_decoder_gs_sptr gps_l2c_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
/*! /*!
* \brief This class implements a block that decodes CNAV data defined in IS-GPS-200K * \brief This class implements a block that decodes CNAV data defined in IS-GPS-200K
@ -68,9 +69,11 @@ public:
private: private:
friend gps_l2c_telemetry_decoder_gs_sptr gps_l2c_make_telemetry_decoder_gs( friend gps_l2c_telemetry_decoder_gs_sptr gps_l2c_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
gps_l2c_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); gps_l2c_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf);
int32_t save_matfile() const;
Gnss_Satellite d_satellite; Gnss_Satellite d_satellite;
@ -97,6 +100,7 @@ private:
bool d_sent_tlm_failed_msg; bool d_sent_tlm_failed_msg;
bool d_flag_PLL_180_deg_phase_locked; bool d_flag_PLL_180_deg_phase_locked;
bool d_flag_valid_word; bool d_flag_valid_word;
bool d_dump_mat;
}; };

View File

@ -26,26 +26,50 @@
#include "gps_cnav_utc_model.h" // for Gps_CNAV_Utc_Model #include "gps_cnav_utc_model.h" // for Gps_CNAV_Utc_Model
#include <glog/logging.h> #include <glog/logging.h>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <matio.h> // for Mat_VarCreate
#include <pmt/pmt.h> // for make_any #include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp #include <pmt/pmt_sugar.h> // for mp
#include <bitset> // for std::bitset #include <bitset> // for std::bitset
#include <cstddef> // for size_t
#include <cstdlib> // for std::llabs #include <cstdlib> // for std::llabs
#include <exception> // for std::exception #include <exception> // for std::exception
#include <iostream> // for std::cout #include <iostream> // for std::cout
#include <memory> // for shared_ptr, make_shared #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_telemetry_decoder_gs_sptr
gps_l5_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump) gps_l5_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf &conf)
{ {
return gps_l5_telemetry_decoder_gs_sptr(new gps_l5_telemetry_decoder_gs(satellite, dump)); return gps_l5_telemetry_decoder_gs_sptr(new gps_l5_telemetry_decoder_gs(satellite, conf));
} }
gps_l5_telemetry_decoder_gs::gps_l5_telemetry_decoder_gs( gps_l5_telemetry_decoder_gs::gps_l5_telemetry_decoder_gs(
const Gnss_Satellite &satellite, bool dump) : gr::block("gps_l5_telemetry_decoder_gs", const Gnss_Satellite &satellite,
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), const Tlm_Conf &conf) : gr::block("gps_l5_telemetry_decoder_gs",
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{ {
// prevent telemetry symbols accumulation in output buffers // prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1); this->set_max_noutput_items(1);
@ -58,7 +82,9 @@ gps_l5_telemetry_decoder_gs::gps_l5_telemetry_decoder_gs(
d_max_symbols_without_valid_frame = GPS_L5_CNAV_DATA_PAGE_BITS * GPS_L5_SYMBOLS_PER_BIT * 10; // rise alarm if 20 consecutive subframes have no valid CRC d_max_symbols_without_valid_frame = GPS_L5_CNAV_DATA_PAGE_BITS * GPS_L5_SYMBOLS_PER_BIT * 10; // rise alarm if 20 consecutive subframes have no valid CRC
// initialize internal vars // initialize internal vars
d_dump = dump; d_dump_filename = conf.dump_filename;
d_dump = conf.dump;
d_dump_mat = conf.dump_mat;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
DLOG(INFO) << "GPS L5 TELEMETRY PROCESSING: satellite " << d_satellite; DLOG(INFO) << "GPS L5 TELEMETRY PROCESSING: satellite " << d_satellite;
d_channel = 0; d_channel = 0;
@ -76,8 +102,10 @@ gps_l5_telemetry_decoder_gs::gps_l5_telemetry_decoder_gs(
gps_l5_telemetry_decoder_gs::~gps_l5_telemetry_decoder_gs() gps_l5_telemetry_decoder_gs::~gps_l5_telemetry_decoder_gs()
{ {
DLOG(INFO) << "GPS L5 Telemetry decoder block (channel " << d_channel << ") destructor called."; DLOG(INFO) << "GPS L5 Telemetry decoder block (channel " << d_channel << ") destructor called.";
size_t pos = 0;
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
pos = d_dump_file.tellp();
try try
{ {
d_dump_file.close(); d_dump_file.close();
@ -86,7 +114,127 @@ gps_l5_telemetry_decoder_gs::~gps_l5_telemetry_decoder_gs()
{ {
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
} }
if (pos == 0)
{
errorlib::error_code ec;
if (!fs::remove(fs::path(d_dump_filename), ec))
{
LOG(WARNING) << "Error deleting temporary file";
}
}
} }
if (d_dump && (pos != 0) && d_dump_mat)
{
try
{
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++)
{
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");
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;
} }
@ -110,7 +258,6 @@ void gps_l5_telemetry_decoder_gs::set_channel(int32_t channel)
{ {
try try
{ {
d_dump_filename = "telemetry_L5_";
d_dump_filename.append(std::to_string(d_channel)); d_dump_filename.append(std::to_string(d_channel));
d_dump_filename.append(".dat"); d_dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
@ -263,12 +410,17 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u
{ {
double tmp_double; double tmp_double;
uint64_t tmp_ulong_int; uint64_t tmp_ulong_int;
int32_t tmp_int;
tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0; tmp_double = static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_ulong_int = current_synchro_data.Tracking_sample_counter; tmp_ulong_int = current_synchro_data.Tracking_sample_counter;
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t)); d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
tmp_double = static_cast<double>(d_TOW_at_Preamble_ms) / 1000.0; tmp_double = static_cast<double>(d_TOW_at_Preamble_ms) / 1000.0;
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double)); d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
tmp_int = (current_synchro_data.Prompt_Q > 0.0 ? 1 : -1);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
tmp_int = static_cast<int32_t>(current_synchro_data.PRN);
d_dump_file.write(reinterpret_cast<char *>(&tmp_int), sizeof(int32_t));
} }
catch (const std::ifstream::failure &e) catch (const std::ifstream::failure &e)
{ {

View File

@ -24,6 +24,7 @@
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
#include "gnss_satellite.h" // for Gnss_Satellite #include "gnss_satellite.h" // for Gnss_Satellite
#include "gps_cnav_navigation_message.h" // for Gps_CNAV_Navigation_Message #include "gps_cnav_navigation_message.h" // for Gps_CNAV_Navigation_Message
#include "tlm_conf.h"
#include <boost/circular_buffer.hpp> #include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> #include <gnuradio/block.h>
#include <gnuradio/types.h> // for gr_vector_const_void_star #include <gnuradio/types.h> // for gr_vector_const_void_star
@ -48,7 +49,7 @@ using gps_l5_telemetry_decoder_gs_sptr = gnss_shared_ptr<gps_l5_telemetry_decode
gps_l5_telemetry_decoder_gs_sptr gps_l5_make_telemetry_decoder_gs( gps_l5_telemetry_decoder_gs_sptr gps_l5_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
/*! /*!
* \brief This class implements a GPS L5 Telemetry decoder * \brief This class implements a GPS L5 Telemetry decoder
@ -67,9 +68,11 @@ public:
private: private:
friend gps_l5_telemetry_decoder_gs_sptr gps_l5_make_telemetry_decoder_gs( friend gps_l5_telemetry_decoder_gs_sptr gps_l5_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite, const Gnss_Satellite &satellite,
bool dump); const Tlm_Conf &conf);
gps_l5_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); 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{}; cnav_msg_decoder_t d_cnav_decoder{};
@ -93,6 +96,7 @@ private:
bool d_flag_valid_word; bool d_flag_valid_word;
bool d_sent_tlm_failed_msg; bool d_sent_tlm_failed_msg;
bool d_dump; bool d_dump;
bool d_dump_mat;
}; };

View File

@ -11,10 +11,12 @@
add_subdirectory(libswiftcnav) add_subdirectory(libswiftcnav)
set(TELEMETRY_DECODER_LIB_SOURCES set(TELEMETRY_DECODER_LIB_SOURCES
tlm_conf.cc
viterbi_decoder.cc viterbi_decoder.cc
) )
set(TELEMETRY_DECODER_LIB_HEADERS set(TELEMETRY_DECODER_LIB_HEADERS
tlm_conf.h
viterbi_decoder.h viterbi_decoder.h
convolutional.h convolutional.h
) )
@ -46,6 +48,11 @@ target_link_libraries(telemetry_decoder_libs
Glog::glog Glog::glog
) )
target_include_directories(telemetry_decoder_libs
PUBLIC
${CMAKE_SOURCE_DIR}/src/core/interfaces
)
if(ENABLE_CLANG_TIDY) if(ENABLE_CLANG_TIDY)
if(CLANG_TIDY_EXE) if(CLANG_TIDY_EXE)
set_target_properties(telemetry_decoder_libs set_target_properties(telemetry_decoder_libs

View File

@ -0,0 +1,37 @@
/*!
* \file tlm_conf.cc
* \brief Class that contains all the configuration parameters for generic
* telemetry decoder block.
* \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_conf.h"
Tlm_Conf::Tlm_Conf()
{
dump = false;
dump_mat = false;
}
void Tlm_Conf::SetFromConfiguration(const ConfigurationInterface *configuration,
const std::string &role)
{
const std::string default_dumpname("telemetry");
dump_filename = configuration->property(role + ".dump_filename", default_dumpname);
dump = configuration->property(role + ".dump", false);
dump_mat = configuration->property(role + ".dump_mat", dump);
}

View File

@ -0,0 +1,48 @@
/*!
* \file tlm_conf.h
* \brief Class that contains all the configuration parameters for generic
* telemetry decoder block.
* \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_CONF_H
#define GNSS_SDR_TLM_CONF_H
#include "configuration_interface.h"
#include <string>
/** \addtogroup Telemetry_Decoder
* \{ */
/** \addtogroup Telemetry_Decoder_libs
* \{ */
class Tlm_Conf
{
public:
Tlm_Conf();
void SetFromConfiguration(const ConfigurationInterface *configuration, const std::string &role);
std::string dump_filename;
bool dump;
bool dump_mat;
};
/** \} */
/** \} */
#endif // GNSS_SDR_TLM_CONF_H

View File

@ -56,7 +56,7 @@ gnss_synchro_monitor::gnss_synchro_monitor(int n_channels,
udp_sink_ptr = std::make_unique<Gnss_Synchro_Udp_Sink>(udp_addresses, udp_port, enable_protobuf); udp_sink_ptr = std::make_unique<Gnss_Synchro_Udp_Sink>(udp_addresses, udp_port, enable_protobuf);
} }
void gnss_synchro_monitor::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) void gnss_synchro_monitor::forecast(int noutput_items __attribute__((unused)), gr_vector_int& ninput_items_required)
{ {
for (int32_t channel_index = 0; channel_index < d_nchannels; channel_index++) for (int32_t channel_index = 0; channel_index < d_nchannels; channel_index++)
{ {

View File

@ -213,9 +213,9 @@ void Galileo_Cnav_Message::read_MT1_body(const std::string& message_string)
std::string msg = message.substr(0, HAS_MSG_SATELLITE_MASK_LENGTH); std::string msg = message.substr(0, HAS_MSG_SATELLITE_MASK_LENGTH);
d_HAS_data.satellite_mask[i] = read_has_message_body_uint64(msg); d_HAS_data.satellite_mask[i] = read_has_message_body_uint64(msg);
int ones_in_satellite_mask = 0; int ones_in_satellite_mask = 0;
for (size_t i = 0; i < msg.length(); i++) for (char c : msg)
{ {
if (msg[i] == '1') if (c == '1')
{ {
ones_in_satellite_mask++; ones_in_satellite_mask++;
} }
@ -226,9 +226,9 @@ void Galileo_Cnav_Message::read_MT1_body(const std::string& message_string)
msg = message.substr(0, HAS_MSG_SIGNAL_MASK_LENGTH); msg = message.substr(0, HAS_MSG_SIGNAL_MASK_LENGTH);
d_HAS_data.signal_mask[i] = read_has_message_body_uint16(msg); d_HAS_data.signal_mask[i] = read_has_message_body_uint16(msg);
int ones_in_signal_mask = 0; int ones_in_signal_mask = 0;
for (size_t i = 0; i < msg.length(); i++) for (char c : msg)
{ {
if (msg[i] == '1') if (c == '1')
{ {
ones_in_signal_mask++; ones_in_signal_mask++;
} }

View File

@ -49,6 +49,7 @@
#include <cuda_runtime.h> #include <cuda_runtime.h>
#endif #endif
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -67,6 +68,8 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
#if GFLAGS_OLD_NAMESPACE #if GFLAGS_OLD_NAMESPACE
namespace gflags namespace gflags
{ {

View File

@ -24,6 +24,7 @@
#include <matio.h> #include <matio.h>
#include <array> #include <array>
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -42,6 +43,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
TEST(MatioTest, WriteAndReadDoubles) TEST(MatioTest, WriteAndReadDoubles)
{ {

View File

@ -29,6 +29,8 @@ bool Tlm_Dump_Reader::read_binary_obs()
d_dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol), sizeof(double)); d_dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&Tracking_sample_counter), sizeof(uint64_t)); d_dump_file.read(reinterpret_cast<char *>(&Tracking_sample_counter), sizeof(uint64_t));
d_dump_file.read(reinterpret_cast<char *>(&d_TOW_at_Preamble), sizeof(double)); d_dump_file.read(reinterpret_cast<char *>(&d_TOW_at_Preamble), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&nav_symbol), sizeof(int32_t));
d_dump_file.read(reinterpret_cast<char *>(&prn), sizeof(int32_t));
} }
catch (const std::ifstream::failure &e) catch (const std::ifstream::failure &e)
{ {
@ -53,8 +55,9 @@ bool Tlm_Dump_Reader::restart()
int64_t Tlm_Dump_Reader::num_epochs() int64_t Tlm_Dump_Reader::num_epochs()
{ {
std::ifstream::pos_type size; std::ifstream::pos_type size;
int number_of_vars_in_epoch = 2; int number_of_double_vars_in_epoch = 2;
int epoch_size_bytes = sizeof(double) * number_of_vars_in_epoch + sizeof(uint64_t); int number_of_int_vars_in_epoch = 2;
int epoch_size_bytes = sizeof(double) * number_of_double_vars_in_epoch + sizeof(uint64_t) + sizeof(int32_t) * number_of_int_vars_in_epoch;
std::ifstream tmpfile(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); std::ifstream tmpfile(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
if (tmpfile.is_open()) if (tmpfile.is_open())
{ {

View File

@ -38,6 +38,8 @@ public:
double TOW_at_current_symbol; double TOW_at_current_symbol;
uint64_t Tracking_sample_counter; uint64_t Tracking_sample_counter;
double d_TOW_at_Preamble; double d_TOW_at_Preamble;
int32_t nav_symbol;
int32_t prn;
private: private:
std::string d_dump_filename; std::string d_dump_filename;

View File

@ -24,6 +24,7 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -42,6 +43,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
class NmeaPrinterTest : public ::testing::Test class NmeaPrinterTest : public ::testing::Test
{ {

View File

@ -23,6 +23,7 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
// clang-format off
#if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM
#include <system_error> #include <system_error>
namespace errorlib = std; namespace errorlib = std;
@ -41,6 +42,7 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace errorlib = boost::system; namespace errorlib = boost::system;
#endif #endif
// clang-format on
class RinexPrinterTest : public ::testing::Test class RinexPrinterTest : public ::testing::Test
{ {

View File

@ -21,9 +21,11 @@ function [telemetry] = gps_l1_ca_read_telemetry_dump (filename, count)
%% %%
m = nargchk (1,2,nargin); m = nargchk (1,2,nargin);
num_double_vars=4; num_double_vars=3;
double_size_bytes=8; double_size_bytes=8;
skip_bytes_each_read=double_size_bytes*num_double_vars; num_int_vars=2;
int_size_bytes=4;
skip_bytes_each_read=double_size_bytes*num_double_vars+num_int_vars*int_size_bytes;
bytes_shift=0; bytes_shift=0;
if (m) if (m)
usage (m); usage (m);
@ -32,34 +34,27 @@ end
if (nargin < 3) if (nargin < 3)
count = Inf; count = Inf;
end end
%loops_counter = fread (f, count, 'uint32',4*12);
f = fopen (filename, 'rb'); f = fopen (filename, 'rb');
if (f < 0) if (f < 0)
else else
telemetry.tow_current_symbol_ms = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); [x, loops_counter] = fread (f,skip_bytes_each_read);
bytes_shift=bytes_shift+double_size_bytes; fseek(f,0,-1);
fseek(f,bytes_shift,'bof'); % move to next interleaved for i=1:min(count, loops_counter),
telemetry.tracking_sample_counter = fread (f, count, 'uint64',skip_bytes_each_read-double_size_bytes); telemetry(i).tow_current_symbol_ms = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes; bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved fseek(f,bytes_shift,'bof'); % move to next interleaved
telemetry.tow = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); telemetry(i).tracking_sample_counter = fread (f, count, 'uint64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes; bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved fseek(f,bytes_shift,'bof'); % move to next interleaved
telemetry.required_symbols = fread (f, count, 'uint64',skip_bytes_each_read-double_size_bytes); telemetry(i).tow = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes);
bytes_shift=bytes_shift+double_size_bytes; bytes_shift=bytes_shift+double_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved fseek(f,bytes_shift,'bof'); % move to next interleaved
telemetry(i).nav_simbols = fread (f, count, 'int32',skip_bytes_each_read-int_size_bytes);
bytes_shift=bytes_shift+int_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
telemetry(i).prn = fread (f, count, 'int32',skip_bytes_each_read-int_size_bytes);
bytes_shift=bytes_shift+int_size_bytes;
fseek(f,bytes_shift,'bof'); % move to next interleaved
end
fclose (f); fclose (f);
%%%%%%%% output vars %%%%%%%%
% {
% double tmp_double;
% tmp_double = current_synchro_data.Preamble_delay_ms;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_synchro_data.Prn_delay_ms;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% tmp_double = current_synchro_data.Preamble_symbol_counter;
% d_dump_file.write((char*)&tmp_double, sizeof(double));
% }
end end