mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2026-04-24 15:51:26 +00:00
bds_b3i: merging new changes, fixing small bugs
This commit is contained in:
@@ -20,12 +20,12 @@
|
||||
set(TELEMETRY_DECODER_ADAPTER_SOURCES
|
||||
gps_l1_ca_telemetry_decoder.cc
|
||||
gps_l2c_telemetry_decoder.cc
|
||||
gps_l5_telemetry_decoder.cc
|
||||
gps_l5_telemetry_decoder.cc
|
||||
galileo_e1b_telemetry_decoder.cc
|
||||
sbas_l1_telemetry_decoder.cc
|
||||
galileo_e5a_telemetry_decoder.cc
|
||||
glonass_l1_ca_telemetry_decoder.cc
|
||||
glonass_l2_ca_telemetry_decoder.cc
|
||||
glonass_l2_ca_telemetry_decoder.cc
|
||||
beidou_b1i_telemetry_decoder.cc
|
||||
beidou_b3i_telemetry_decoder.cc
|
||||
)
|
||||
@@ -33,7 +33,7 @@ set(TELEMETRY_DECODER_ADAPTER_SOURCES
|
||||
set(TELEMETRY_DECODER_ADAPTER_HEADERS
|
||||
gps_l1_ca_telemetry_decoder.h
|
||||
gps_l2c_telemetry_decoder.h
|
||||
gps_l5_telemetry_decoder.h
|
||||
gps_l5_telemetry_decoder.h
|
||||
galileo_e1b_telemetry_decoder.h
|
||||
sbas_l1_telemetry_decoder.h
|
||||
galileo_e5a_telemetry_decoder.h
|
||||
@@ -55,16 +55,29 @@ add_library(telemetry_decoder_adapters
|
||||
|
||||
target_link_libraries(telemetry_decoder_adapters
|
||||
PUBLIC
|
||||
telemetry_decoder_gr_blocks
|
||||
gnss_system_parameters
|
||||
gnss_rx
|
||||
telemetry_decoder_gr_blocks
|
||||
core_system_parameters
|
||||
PRIVATE
|
||||
Gflags::gflags
|
||||
Glog::glog
|
||||
Gnuradio::runtime
|
||||
telemetry_decoder_lib
|
||||
telemetry_decoder_libs
|
||||
)
|
||||
|
||||
target_include_directories(telemetry_decoder_adapters
|
||||
PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/src/core/interfaces
|
||||
)
|
||||
|
||||
if(ENABLE_CLANG_TIDY)
|
||||
if(CLANG_TIDY_EXE)
|
||||
set_target_properties(telemetry_decoder_adapters
|
||||
PROPERTIES
|
||||
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_property(TARGET telemetry_decoder_adapters
|
||||
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
|
||||
@@ -17,26 +17,26 @@
|
||||
#
|
||||
|
||||
set(TELEMETRY_DECODER_GR_BLOCKS_SOURCES
|
||||
gps_l1_ca_telemetry_decoder_cc.cc
|
||||
gps_l2c_telemetry_decoder_cc.cc
|
||||
gps_l5_telemetry_decoder_cc.cc
|
||||
sbas_l1_telemetry_decoder_cc.cc
|
||||
glonass_l1_ca_telemetry_decoder_cc.cc
|
||||
glonass_l2_ca_telemetry_decoder_cc.cc
|
||||
galileo_telemetry_decoder_cc.cc
|
||||
beidou_b1i_telemetry_decoder_cc.cc
|
||||
gps_l1_ca_telemetry_decoder_cc.cc
|
||||
gps_l2c_telemetry_decoder_cc.cc
|
||||
gps_l5_telemetry_decoder_cc.cc
|
||||
sbas_l1_telemetry_decoder_cc.cc
|
||||
glonass_l1_ca_telemetry_decoder_cc.cc
|
||||
glonass_l2_ca_telemetry_decoder_cc.cc
|
||||
galileo_telemetry_decoder_cc.cc
|
||||
beidou_b1i_telemetry_decoder_cc.cc
|
||||
beidou_b3i_telemetry_decoder_cc.cc
|
||||
)
|
||||
|
||||
set(TELEMETRY_DECODER_GR_BLOCKS_HEADERS
|
||||
gps_l1_ca_telemetry_decoder_cc.h
|
||||
gps_l2c_telemetry_decoder_cc.h
|
||||
gps_l5_telemetry_decoder_cc.h
|
||||
sbas_l1_telemetry_decoder_cc.h
|
||||
glonass_l1_ca_telemetry_decoder_cc.h
|
||||
glonass_l2_ca_telemetry_decoder_cc.h
|
||||
galileo_telemetry_decoder_cc.h
|
||||
beidou_b1i_telemetry_decoder_cc.h
|
||||
gps_l1_ca_telemetry_decoder_cc.h
|
||||
gps_l2c_telemetry_decoder_cc.h
|
||||
gps_l5_telemetry_decoder_cc.h
|
||||
sbas_l1_telemetry_decoder_cc.h
|
||||
glonass_l1_ca_telemetry_decoder_cc.h
|
||||
glonass_l2_ca_telemetry_decoder_cc.h
|
||||
galileo_telemetry_decoder_cc.h
|
||||
beidou_b1i_telemetry_decoder_cc.h
|
||||
beidou_b3i_telemetry_decoder_cc.h
|
||||
)
|
||||
|
||||
@@ -52,18 +52,26 @@ add_library(telemetry_decoder_gr_blocks
|
||||
|
||||
target_link_libraries(telemetry_decoder_gr_blocks
|
||||
PUBLIC
|
||||
telemetry_decoder_libswiftcnav
|
||||
telemetry_decoder_lib
|
||||
gnss_system_parameters
|
||||
gnss_rx
|
||||
Gnuradio::runtime
|
||||
Volkgnsssdr::volkgnsssdr
|
||||
telemetry_decoder_libswiftcnav
|
||||
telemetry_decoder_libs
|
||||
core_system_parameters
|
||||
PRIVATE
|
||||
Boost::boost
|
||||
Gflags::gflags
|
||||
Glog::glog
|
||||
)
|
||||
|
||||
if(ENABLE_CLANG_TIDY)
|
||||
if(CLANG_TIDY_EXE)
|
||||
set_target_properties(telemetry_decoder_gr_blocks
|
||||
PROPERTIES
|
||||
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_property(TARGET telemetry_decoder_gr_blocks
|
||||
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@@ -33,7 +33,6 @@
|
||||
|
||||
|
||||
#include "beidou_b1i_telemetry_decoder_cc.h"
|
||||
#include "control_message_factory.h"
|
||||
#include "convolutional.h"
|
||||
#include "display.h"
|
||||
#include "gnss_synchro.h"
|
||||
@@ -74,7 +73,6 @@ beidou_b1i_telemetry_decoder_cc::beidou_b1i_telemetry_decoder_cc(
|
||||
d_secondary_code_symbols = static_cast<int32_t *>(volk_gnsssdr_malloc(BEIDOU_B1I_SECONDARY_CODE_LENGTH * sizeof(int32_t), volk_gnsssdr_get_alignment()));
|
||||
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
|
||||
d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol;
|
||||
d_subframe_length_symbols = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS;
|
||||
|
||||
// Setting samples of secondary code
|
||||
for (int32_t i = 0; i < BEIDOU_B1I_SECONDARY_CODE_LENGTH; i++)
|
||||
@@ -116,7 +114,7 @@ beidou_b1i_telemetry_decoder_cc::beidou_b1i_telemetry_decoder_cc(
|
||||
}
|
||||
}
|
||||
|
||||
d_subframe_symbols = static_cast<double *>(volk_gnsssdr_malloc(d_subframe_length_symbols * sizeof(double), volk_gnsssdr_get_alignment()));
|
||||
d_subframe_symbols = static_cast<double *>(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), volk_gnsssdr_get_alignment()));
|
||||
d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + d_samples_per_preamble;
|
||||
|
||||
// Generic settings
|
||||
@@ -125,6 +123,7 @@ beidou_b1i_telemetry_decoder_cc::beidou_b1i_telemetry_decoder_cc(
|
||||
d_preamble_index = 0;
|
||||
d_flag_frame_sync = false;
|
||||
d_TOW_at_current_symbol_ms = 0;
|
||||
d_TOW_at_Preamble_ms = 0U;
|
||||
Flag_valid_word = false;
|
||||
d_CRC_error_counter = 0;
|
||||
d_flag_preamble = false;
|
||||
@@ -155,15 +154,15 @@ beidou_b1i_telemetry_decoder_cc::~beidou_b1i_telemetry_decoder_cc()
|
||||
|
||||
void beidou_b1i_telemetry_decoder_cc::decode_bch15_11_01(const int32_t *bits, int32_t *decbits)
|
||||
{
|
||||
int bit, err, reg[4] = {1, 1, 1, 1};
|
||||
int errind[15] = {14, 13, 10, 12, 6, 9, 4, 11, 0, 5, 7, 8, 1, 3, 2};
|
||||
int32_t bit, err, reg[4] = {1, 1, 1, 1};
|
||||
int32_t errind[15] = {14, 13, 10, 12, 6, 9, 4, 11, 0, 5, 7, 8, 1, 3, 2};
|
||||
|
||||
for (unsigned int i = 0; i < 15; i++)
|
||||
for (uint32_t i = 0; i < 15; i++)
|
||||
{
|
||||
decbits[i] = bits[i];
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < 15; i++)
|
||||
for (uint32_t i = 0; i < 15; i++)
|
||||
{
|
||||
bit = reg[3];
|
||||
reg[3] = reg[2];
|
||||
@@ -191,31 +190,31 @@ void beidou_b1i_telemetry_decoder_cc::decode_word(
|
||||
|
||||
if (word_counter == 1)
|
||||
{
|
||||
for (unsigned int j = 0; j < 30; j++)
|
||||
for (uint32_t j = 0; j < 30; j++)
|
||||
{
|
||||
dec_word_symbols[j] = (int32_t)(enc_word_symbols[j] > 0) ? (1) : (-1);
|
||||
dec_word_symbols[j] = static_cast<int32_t>(enc_word_symbols[j] > 0) ? (1) : (-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int r = 0; r < 2; r++)
|
||||
for (uint32_t r = 0; r < 2; r++)
|
||||
{
|
||||
for (unsigned int c = 0; c < 15; c++)
|
||||
for (uint32_t c = 0; c < 15; c++)
|
||||
{
|
||||
bitsbch[r * 15 + c] = (int32_t)(enc_word_symbols[c * 2 + r] > 0) ? (1) : (-1);
|
||||
bitsbch[r * 15 + c] = static_cast<int32_t>(enc_word_symbols[c * 2 + r] > 0) ? (1) : (-1);
|
||||
}
|
||||
}
|
||||
|
||||
decode_bch15_11_01(&bitsbch[0], first_branch);
|
||||
decode_bch15_11_01(&bitsbch[15], second_branch);
|
||||
|
||||
for (unsigned int j = 0; j < 11; j++)
|
||||
for (uint32_t j = 0; j < 11; j++)
|
||||
{
|
||||
dec_word_symbols[j] = first_branch[j];
|
||||
dec_word_symbols[j + 11] = second_branch[j];
|
||||
}
|
||||
|
||||
for (unsigned int j = 0; j < 4; j++)
|
||||
for (uint32_t j = 0; j < 4; j++)
|
||||
{
|
||||
dec_word_symbols[j + 22] = first_branch[11 + j];
|
||||
dec_word_symbols[j + 26] = second_branch[11 + j];
|
||||
@@ -289,9 +288,9 @@ void beidou_b1i_telemetry_decoder_cc::decode_subframe(double *frame_symbols, int
|
||||
}
|
||||
if (d_nav.have_new_almanac() == true)
|
||||
{
|
||||
// unsigned int slot_nbr = d_nav.i_alm_satellite_PRN;
|
||||
// std::shared_ptr<Beidou_Dnav_Almanac> tmp_obj = std::make_shared<Beidou_Dnav_Almanac>(d_nav.get_almanac(slot_nbr));
|
||||
// this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
|
||||
// uint32_t slot_nbr = d_nav.i_alm_satellite_PRN;
|
||||
// std::shared_ptr<Beidou_Dnav_Almanac> tmp_obj = std::make_shared<Beidou_Dnav_Almanac>(d_nav.get_almanac(slot_nbr));
|
||||
// this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
|
||||
LOG(INFO) << "BEIDOU DNAV Almanac have been received in channel" << d_channel << " from satellite " << d_satellite << std::endl;
|
||||
std::cout << "New BEIDOU B1I DNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << std::endl;
|
||||
}
|
||||
@@ -324,7 +323,6 @@ void beidou_b1i_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satell
|
||||
d_secondary_code_symbols = nullptr;
|
||||
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
|
||||
d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol;
|
||||
d_subframe_length_symbols = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS;
|
||||
|
||||
// Setting samples of preamble code
|
||||
int32_t n = 0;
|
||||
@@ -348,13 +346,13 @@ void beidou_b1i_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satell
|
||||
}
|
||||
}
|
||||
|
||||
d_subframe_symbols = static_cast<double *>(volk_gnsssdr_malloc(d_subframe_length_symbols * sizeof(double), volk_gnsssdr_get_alignment()));
|
||||
d_subframe_symbols = static_cast<double *>(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), volk_gnsssdr_get_alignment()));
|
||||
d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + d_samples_per_preamble;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void beidou_b1i_telemetry_decoder_cc::set_channel(int channel)
|
||||
void beidou_b1i_telemetry_decoder_cc::set_channel(int32_t channel)
|
||||
{
|
||||
d_channel = channel;
|
||||
LOG(INFO) << "Navigation channel set to " << channel;
|
||||
@@ -390,11 +388,11 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
auto **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
|
||||
const auto **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
|
||||
|
||||
Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block
|
||||
//1. Copy the current tracking output
|
||||
Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block
|
||||
// 1. Copy the current tracking output
|
||||
current_symbol = in[0][0];
|
||||
d_symbol_history.push_back(current_symbol.Prompt_I); //add new symbol to the symbol queue
|
||||
d_sample_counter++; //count for the processed samples
|
||||
d_symbol_history.push_back(current_symbol.Prompt_I); // add new symbol to the symbol queue
|
||||
d_sample_counter++; // count for the processed samples
|
||||
consume_each(1);
|
||||
|
||||
d_flag_preamble = false;
|
||||
@@ -402,7 +400,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
if (d_symbol_history.size() > d_required_symbols)
|
||||
{
|
||||
//******* preamble correlation ********
|
||||
for (int i = 0; i < d_samples_per_preamble; i++)
|
||||
for (int32_t i = 0; i < d_samples_per_preamble; i++)
|
||||
{
|
||||
if (d_symbol_history.at(i) < 0) // symbols clipping
|
||||
{
|
||||
@@ -416,7 +414,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
}
|
||||
|
||||
//******* frame sync ******************
|
||||
if (d_stat == 0) //no preamble information
|
||||
if (d_stat == 0) // no preamble information
|
||||
{
|
||||
if (abs(corr_value) >= d_samples_per_preamble)
|
||||
{
|
||||
@@ -431,11 +429,11 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
{
|
||||
if (abs(corr_value) >= d_samples_per_preamble)
|
||||
{
|
||||
//check preamble separation
|
||||
// check preamble separation
|
||||
preamble_diff = static_cast<int32_t>(d_sample_counter - d_preamble_index);
|
||||
if (abs(preamble_diff - d_preamble_period_samples) == 0)
|
||||
{
|
||||
//try to decode frame
|
||||
// try to decode frame
|
||||
LOG(INFO) << "Starting BeiDou DNAV frame decoding for BeiDou B1I SAT " << this->d_satellite;
|
||||
d_preamble_index = d_sample_counter; //record the preamble sample stamp
|
||||
d_stat = 2;
|
||||
@@ -454,14 +452,14 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
{
|
||||
if (d_sample_counter == d_preamble_index + static_cast<uint64_t>(d_preamble_period_samples))
|
||||
{
|
||||
//******* SAMPLES TO SYMBOLS *******
|
||||
// ******* SAMPLES TO SYMBOLS *******
|
||||
if (corr_value > 0) //normal PLL lock
|
||||
{
|
||||
int k = 0;
|
||||
for (uint32_t i = 0; i < d_subframe_length_symbols; i++)
|
||||
int32_t k = 0;
|
||||
for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++)
|
||||
{
|
||||
d_subframe_symbols[i] = 0;
|
||||
//integrate samples into symbols
|
||||
// integrate samples into symbols
|
||||
for (uint32_t m = 0; m < d_samples_per_symbol; m++)
|
||||
{
|
||||
if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6)
|
||||
@@ -479,13 +477,13 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
}
|
||||
}
|
||||
}
|
||||
else //180 deg. inverted carrier phase PLL lock
|
||||
else // 180 deg. inverted carrier phase PLL lock
|
||||
{
|
||||
int k = 0;
|
||||
for (uint32_t i = 0; i < d_subframe_length_symbols; i++)
|
||||
int32_t k = 0;
|
||||
for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++)
|
||||
{
|
||||
d_subframe_symbols[i] = 0;
|
||||
//integrate samples into symbols
|
||||
// integrate samples into symbols
|
||||
for (uint32_t m = 0; m < d_samples_per_symbol; m++)
|
||||
{
|
||||
if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6)
|
||||
@@ -504,14 +502,14 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
}
|
||||
}
|
||||
|
||||
//call the decoder
|
||||
// call the decoder
|
||||
decode_subframe(d_subframe_symbols, d_subframe_length_symbols);
|
||||
|
||||
if (d_nav.flag_crc_test == true)
|
||||
{
|
||||
d_CRC_error_counter = 0;
|
||||
d_flag_preamble = true; //valid preamble indicator (initialized to false every work())
|
||||
d_preamble_index = d_sample_counter; //record the preamble sample stamp (t_P)
|
||||
d_flag_preamble = true; // valid preamble indicator (initialized to false every work())
|
||||
d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P)
|
||||
if (!d_flag_frame_sync)
|
||||
{
|
||||
d_flag_frame_sync = true;
|
||||
@@ -521,7 +519,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
else
|
||||
{
|
||||
d_CRC_error_counter++;
|
||||
d_preamble_index = d_sample_counter; //record the preamble sample stamp
|
||||
d_preamble_index = d_sample_counter; // record the preamble sample stamp
|
||||
if (d_CRC_error_counter > CRC_ERROR_LIMIT)
|
||||
{
|
||||
LOG(INFO) << "BeiDou DNAV frame sync lost for SAT " << this->d_satellite;
|
||||
@@ -534,9 +532,9 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
}
|
||||
|
||||
// UPDATE GNSS SYNCHRO DATA
|
||||
//2. Add the telemetry decoder information
|
||||
// 2. Add the telemetry decoder information
|
||||
if (this->d_flag_preamble == true and d_nav.flag_new_SOW_available == true)
|
||||
//update TOW at the preamble instant
|
||||
// update TOW at the preamble instant
|
||||
{
|
||||
// Reporting sow as gps time of week
|
||||
d_TOW_at_Preamble_ms = static_cast<uint32_t>((d_nav.d_SOW + 14) * 1000.0);
|
||||
@@ -544,7 +542,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
flag_SOW_set = true;
|
||||
d_nav.flag_new_SOW_available = false;
|
||||
}
|
||||
else //if there is not a new preamble, we define the TOW of the current symbol
|
||||
else // if there is not a new preamble, we define the TOW of the current symbol
|
||||
{
|
||||
d_TOW_at_current_symbol_ms += static_cast<uint32_t>(BEIDOU_B1I_CODE_PERIOD_MS);
|
||||
}
|
||||
@@ -568,11 +566,11 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
try
|
||||
{
|
||||
double tmp_double;
|
||||
unsigned long int tmp_ulong_int;
|
||||
uint64_t tmp_ulong_int;
|
||||
tmp_double = d_TOW_at_current_symbol_ms;
|
||||
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
|
||||
tmp_ulong_int = current_symbol.Tracking_sample_counter;
|
||||
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(unsigned long int));
|
||||
d_dump_file.write(reinterpret_cast<char *>(&tmp_ulong_int), sizeof(uint64_t));
|
||||
tmp_double = 0;
|
||||
d_dump_file.write(reinterpret_cast<char *>(&tmp_double), sizeof(double));
|
||||
}
|
||||
@@ -587,7 +585,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_
|
||||
{
|
||||
d_symbol_history.pop_front();
|
||||
}
|
||||
//3. Make the output (copy the object contents to the GNURadio reserved memory)
|
||||
// 3. Make the output (copy the object contents to the GNURadio reserved memory)
|
||||
*out[0] = current_symbol;
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@@ -27,7 +27,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
class beidou_b1i_telemetry_decoder_cc;
|
||||
|
||||
typedef boost::shared_ptr<beidou_b1i_telemetry_decoder_cc> beidou_b1i_telemetry_decoder_cc_sptr;
|
||||
using beidou_b1i_telemetry_decoder_cc_sptr = boost::shared_ptr<beidou_b1i_telemetry_decoder_cc>;
|
||||
|
||||
beidou_b1i_telemetry_decoder_cc_sptr beidou_b1i_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
|
||||
@@ -64,7 +64,7 @@ beidou_b1i_telemetry_decoder_cc_sptr beidou_b1i_make_telemetry_decoder_cc(const
|
||||
class beidou_b1i_telemetry_decoder_cc : public gr::block
|
||||
{
|
||||
public:
|
||||
~beidou_b1i_telemetry_decoder_cc(); //!< Class destructor
|
||||
~beidou_b1i_telemetry_decoder_cc(); //!< Class destructor
|
||||
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
|
||||
void set_channel(int channel); //!< Set receiver's channel
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
|
||||
private:
|
||||
friend beidou_b1i_telemetry_decoder_cc_sptr
|
||||
beidou_b1i_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
beidou_b1i_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
beidou_b1i_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
|
||||
void decode_subframe(double *symbols, int32_t frame_length);
|
||||
@@ -84,29 +84,29 @@ private:
|
||||
void decode_bch15_11_01(const int32_t *bits, int32_t *decbits);
|
||||
|
||||
|
||||
//!< Preamble decoding
|
||||
unsigned short int d_preambles_symbols[BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS];
|
||||
int32_t *d_preamble_samples;
|
||||
int32_t *d_secondary_code_symbols;
|
||||
uint32_t d_samples_per_symbol;
|
||||
int32_t d_symbols_per_preamble;
|
||||
int32_t d_samples_per_preamble;
|
||||
int32_t d_preamble_period_samples;
|
||||
double *d_subframe_symbols;
|
||||
uint32_t d_subframe_length_symbols;
|
||||
uint32_t d_required_symbols;
|
||||
// Preamble decoding
|
||||
uint16_t d_preambles_symbols[BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS];
|
||||
int32_t *d_preamble_samples;
|
||||
int32_t *d_secondary_code_symbols;
|
||||
uint32_t d_samples_per_symbol;
|
||||
int32_t d_symbols_per_preamble;
|
||||
int32_t d_samples_per_preamble;
|
||||
int32_t d_preamble_period_samples;
|
||||
double *d_subframe_symbols;
|
||||
uint32_t d_subframe_length_symbols;
|
||||
uint32_t d_required_symbols;
|
||||
|
||||
//!< Storage for incoming data
|
||||
// Storage for incoming data
|
||||
std::deque<float> d_symbol_history;
|
||||
|
||||
//!< Variables for internal functionality
|
||||
uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed
|
||||
uint64_t d_preamble_index; //!< Index of sample number where preamble was found
|
||||
uint32_t d_stat; //!< Status of decoder
|
||||
bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved
|
||||
bool d_flag_preamble; //!< Flag indicating when preamble was found
|
||||
int32_t d_CRC_error_counter; //!< Number of failed CRC operations
|
||||
bool flag_SOW_set; //!< Indicates when time of week is set
|
||||
// Variables for internal functionality
|
||||
uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed
|
||||
uint64_t d_preamble_index; // Index of sample number where preamble was found
|
||||
uint32_t d_stat; // Status of decoder
|
||||
bool d_flag_frame_sync; // Indicate when a frame sync is achieved
|
||||
bool d_flag_preamble; // Flag indicating when preamble was found
|
||||
int32_t d_CRC_error_counter; // Number of failed CRC operations
|
||||
bool flag_SOW_set; // Indicates when time of week is set
|
||||
|
||||
//!< Navigation Message variable
|
||||
Beidou_Dnav_Navigation_Message d_nav;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@@ -24,14 +24,13 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "beidou_b3i_telemetry_decoder_cc.h"
|
||||
#include "control_message_factory.h"
|
||||
#include "convolutional.h"
|
||||
#include "display.h"
|
||||
#include "gnss_synchro.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@@ -24,7 +24,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
class beidou_b3i_telemetry_decoder_cc;
|
||||
|
||||
typedef boost::shared_ptr<beidou_b3i_telemetry_decoder_cc> beidou_b3i_telemetry_decoder_cc_sptr;
|
||||
using beidou_b3i_telemetry_decoder_cc_sptr = boost::shared_ptr<beidou_b3i_telemetry_decoder_cc>;
|
||||
|
||||
beidou_b3i_telemetry_decoder_cc_sptr beidou_b3i_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
|
||||
|
||||
//!< Preamble decoding
|
||||
unsigned short int d_preambles_symbols[BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS];
|
||||
uint16_t d_preambles_symbols[BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS];
|
||||
int32_t *d_preamble_samples;
|
||||
int32_t *d_secondary_code_symbols;
|
||||
uint32_t d_samples_per_symbol;
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
|
||||
#include "galileo_telemetry_decoder_cc.h"
|
||||
#include "control_message_factory.h"
|
||||
#include "convolutional.h"
|
||||
#include "display.h"
|
||||
#include "gnss_synchro.h"
|
||||
@@ -89,8 +88,8 @@ galileo_telemetry_decoder_cc::galileo_telemetry_decoder_cc(
|
||||
{
|
||||
case 1: // INAV
|
||||
{
|
||||
d_PRN_code_period_ms = static_cast<uint32_t>(GALILEO_E1_CODE_PERIOD_MS);
|
||||
d_samples_per_symbol = Galileo_E1_B_SAMPLES_PER_SYMBOL;
|
||||
d_PRN_code_period_ms = static_cast<uint32_t>(GALILEO_E5A_CODE_PERIOD_MS);
|
||||
d_samples_per_symbol = GALILEO_E1_B_SAMPLES_PER_SYMBOL;
|
||||
d_bits_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS;
|
||||
// set the preamble
|
||||
d_samples_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS * d_samples_per_symbol;
|
||||
@@ -106,7 +105,7 @@ galileo_telemetry_decoder_cc::galileo_telemetry_decoder_cc(
|
||||
}
|
||||
case 2: // FNAV
|
||||
{
|
||||
d_PRN_code_period_ms = static_cast<uint32_t>(GALILEO_E5a_CODE_PERIOD_MS);
|
||||
d_PRN_code_period_ms = static_cast<uint32_t>(GALILEO_E5A_CODE_PERIOD_MS);
|
||||
d_samples_per_symbol = GALILEO_FNAV_CODES_PER_SYMBOL;
|
||||
d_bits_per_preamble = GALILEO_FNAV_PREAMBLE_LENGTH_BITS;
|
||||
// set the preamble
|
||||
@@ -115,13 +114,13 @@ galileo_telemetry_decoder_cc::galileo_telemetry_decoder_cc(
|
||||
d_required_symbols = static_cast<uint32_t>(GALILEO_FNAV_SYMBOLS_PER_PAGE) * d_samples_per_symbol + d_samples_per_preamble;
|
||||
// preamble bits to sampled symbols
|
||||
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
|
||||
d_secondary_code_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(Galileo_E5a_I_SECONDARY_CODE_LENGTH * sizeof(int32_t), volk_gnsssdr_get_alignment()));
|
||||
d_secondary_code_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(GALILEO_E5A_I_SECONDARY_CODE_LENGTH * sizeof(int32_t), volk_gnsssdr_get_alignment()));
|
||||
d_frame_length_symbols = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS;
|
||||
CodeLength = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS;
|
||||
DataLength = (CodeLength / nn) - mm;
|
||||
for (int32_t i = 0; i < Galileo_E5a_I_SECONDARY_CODE_LENGTH; i++)
|
||||
for (int32_t i = 0; i < GALILEO_E5A_I_SECONDARY_CODE_LENGTH; i++)
|
||||
{
|
||||
if (Galileo_E5a_I_SECONDARY_CODE.at(i) == '1')
|
||||
if (GALILEO_E5A_I_SECONDARY_CODE.at(i) == '1')
|
||||
{
|
||||
d_secondary_code_samples[i] = 1;
|
||||
}
|
||||
@@ -184,7 +183,7 @@ galileo_telemetry_decoder_cc::galileo_telemetry_decoder_cc(
|
||||
d_preamble_samples[n] = d_secondary_code_samples[m];
|
||||
n++;
|
||||
m++;
|
||||
m = m % Galileo_E5a_I_SECONDARY_CODE_LENGTH;
|
||||
m = m % GALILEO_E5A_I_SECONDARY_CODE_LENGTH;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -194,7 +193,7 @@ galileo_telemetry_decoder_cc::galileo_telemetry_decoder_cc(
|
||||
d_preamble_samples[n] = -d_secondary_code_samples[m];
|
||||
n++;
|
||||
m++;
|
||||
m = m % Galileo_E5a_I_SECONDARY_CODE_LENGTH;
|
||||
m = m % GALILEO_E5A_I_SECONDARY_CODE_LENGTH;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -564,7 +563,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
|
||||
{
|
||||
d_page_part_symbols[i] += static_cast<float>(d_secondary_code_samples[k]) * d_symbol_history.at(i * d_samples_per_symbol + d_samples_per_preamble + m); // because last symbol of the preamble is just received now!
|
||||
k++;
|
||||
k = k % Galileo_E5a_I_SECONDARY_CODE_LENGTH;
|
||||
k = k % GALILEO_E5A_I_SECONDARY_CODE_LENGTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -578,7 +577,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
|
||||
{
|
||||
d_page_part_symbols[i] -= static_cast<float>(d_secondary_code_samples[k]) * d_symbol_history.at(i * d_samples_per_symbol + d_samples_per_preamble + m); // because last symbol of the preamble is just received now!
|
||||
k++;
|
||||
k = k % Galileo_E5a_I_SECONDARY_CODE_LENGTH;
|
||||
k = k % GALILEO_E5A_I_SECONDARY_CODE_LENGTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -635,7 +634,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
|
||||
{
|
||||
// TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay
|
||||
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_inav_nav.TOW_5 * 1000.0);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS);
|
||||
d_inav_nav.flag_TOW_5 = false;
|
||||
}
|
||||
|
||||
@@ -643,13 +642,13 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
|
||||
{
|
||||
// TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay
|
||||
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_inav_nav.TOW_6 * 1000.0);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS);
|
||||
d_inav_nav.flag_TOW_6 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this page has no timing information
|
||||
d_TOW_at_current_symbol_ms += static_cast<uint32_t>(GALILEO_E1_CODE_PERIOD_MS); // + GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD;
|
||||
d_TOW_at_current_symbol_ms += static_cast<uint32_t>(GALILEO_E5A_CODE_PERIOD_MS); // + GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -661,7 +660,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
|
||||
if (d_fnav_nav.flag_TOW_1 == true)
|
||||
{
|
||||
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_fnav_nav.FNAV_TOW_1 * 1000.0);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((d_required_symbols + 1) * GALILEO_E5a_CODE_PERIOD_MS);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS);
|
||||
//d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS);
|
||||
d_fnav_nav.flag_TOW_1 = false;
|
||||
}
|
||||
@@ -669,26 +668,26 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
|
||||
{
|
||||
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_fnav_nav.FNAV_TOW_2 * 1000.0);
|
||||
//d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((d_required_symbols + 1) * GALILEO_E5a_CODE_PERIOD_MS);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS);
|
||||
d_fnav_nav.flag_TOW_2 = false;
|
||||
}
|
||||
else if (d_fnav_nav.flag_TOW_3 == true)
|
||||
{
|
||||
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_fnav_nav.FNAV_TOW_3 * 1000.0);
|
||||
//d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((d_required_symbols + 1) * GALILEO_E5a_CODE_PERIOD_MS);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS);
|
||||
d_fnav_nav.flag_TOW_3 = false;
|
||||
}
|
||||
else if (d_fnav_nav.flag_TOW_4 == true)
|
||||
{
|
||||
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_fnav_nav.FNAV_TOW_4 * 1000.0);
|
||||
//d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((d_required_symbols + 1) * GALILEO_E5a_CODE_PERIOD_MS);
|
||||
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast<uint32_t>((d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS);
|
||||
d_fnav_nav.flag_TOW_4 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_TOW_at_current_symbol_ms += static_cast<uint32_t>(GALILEO_E5a_CODE_PERIOD_MS);
|
||||
d_TOW_at_current_symbol_ms += static_cast<uint32_t>(GALILEO_E5A_CODE_PERIOD_MS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
class galileo_telemetry_decoder_cc;
|
||||
|
||||
typedef boost::shared_ptr<galileo_telemetry_decoder_cc> galileo_telemetry_decoder_cc_sptr;
|
||||
using galileo_telemetry_decoder_cc_sptr = boost::shared_ptr<galileo_telemetry_decoder_cc>;
|
||||
|
||||
galileo_telemetry_decoder_cc_sptr galileo_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, int frame_type, bool dump);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
class glonass_l1_ca_telemetry_decoder_cc;
|
||||
|
||||
typedef boost::shared_ptr<glonass_l1_ca_telemetry_decoder_cc> glonass_l1_ca_telemetry_decoder_cc_sptr;
|
||||
using glonass_l1_ca_telemetry_decoder_cc_sptr = boost::shared_ptr<glonass_l1_ca_telemetry_decoder_cc>;
|
||||
|
||||
glonass_l1_ca_telemetry_decoder_cc_sptr glonass_l1_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
class glonass_l2_ca_telemetry_decoder_cc;
|
||||
|
||||
typedef boost::shared_ptr<glonass_l2_ca_telemetry_decoder_cc> glonass_l2_ca_telemetry_decoder_cc_sptr;
|
||||
using glonass_l2_ca_telemetry_decoder_cc_sptr = boost::shared_ptr<glonass_l2_ca_telemetry_decoder_cc>;
|
||||
|
||||
glonass_l2_ca_telemetry_decoder_cc_sptr glonass_l2_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
*/
|
||||
|
||||
#include "gps_l1_ca_telemetry_decoder_cc.h"
|
||||
#include "control_message_factory.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
@@ -204,7 +203,10 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe()
|
||||
if (symbol_accumulator_counter == 20)
|
||||
{
|
||||
// symbol to bit
|
||||
if (symbol_accumulator > 0) GPS_frame_4bytes += 1; // insert the telemetry bit in LSB
|
||||
if (symbol_accumulator > 0)
|
||||
{
|
||||
GPS_frame_4bytes += 1; // insert the telemetry bit in LSB
|
||||
}
|
||||
symbol_accumulator = 0;
|
||||
symbol_accumulator_counter = 0;
|
||||
|
||||
@@ -334,14 +336,14 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
|
||||
|
||||
// ******* preamble correlation ********
|
||||
int32_t corr_value = 0;
|
||||
if ((d_symbol_history.size() == GPS_CA_PREAMBLE_LENGTH_SYMBOLS)) // and (d_make_correlation or !d_flag_frame_sync))
|
||||
if ((d_symbol_history.size() == GPS_CA_PREAMBLE_LENGTH_SYMBOLS))
|
||||
{
|
||||
// std::cout << "-------\n";
|
||||
for (uint32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++)
|
||||
int i = 0;
|
||||
for (const auto &iter : d_symbol_history)
|
||||
{
|
||||
if (d_symbol_history[i].Flag_valid_symbol_output == true)
|
||||
if (iter.Flag_valid_symbol_output == true)
|
||||
{
|
||||
if (d_symbol_history[i].Prompt_I < 0) // symbols clipping
|
||||
if (iter.Prompt_I < 0) // symbols clipping
|
||||
{
|
||||
corr_value -= d_preambles_symbols[i];
|
||||
}
|
||||
@@ -350,6 +352,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
|
||||
corr_value += d_preambles_symbols[i];
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,6 +480,5 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
class gps_l1_ca_telemetry_decoder_cc;
|
||||
|
||||
typedef boost::shared_ptr<gps_l1_ca_telemetry_decoder_cc> gps_l1_ca_telemetry_decoder_cc_sptr;
|
||||
using gps_l1_ca_telemetry_decoder_cc_sptr = boost::shared_ptr<gps_l1_ca_telemetry_decoder_cc>;
|
||||
|
||||
gps_l1_ca_telemetry_decoder_cc_sptr
|
||||
gps_l1_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
|
||||
@@ -57,7 +57,7 @@ extern "C"
|
||||
|
||||
class gps_l2c_telemetry_decoder_cc;
|
||||
|
||||
typedef boost::shared_ptr<gps_l2c_telemetry_decoder_cc> gps_l2c_telemetry_decoder_cc_sptr;
|
||||
using gps_l2c_telemetry_decoder_cc_sptr = boost::shared_ptr<gps_l2c_telemetry_decoder_cc>;
|
||||
|
||||
gps_l2c_telemetry_decoder_cc_sptr
|
||||
gps_l2c_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
|
||||
@@ -68,9 +68,9 @@ gps_l5_telemetry_decoder_cc::gps_l5_telemetry_decoder_cc(
|
||||
d_TOW_at_Preamble_ms = 0U;
|
||||
// initialize the CNAV frame decoder (libswiftcnav)
|
||||
cnav_msg_decoder_init(&d_cnav_decoder);
|
||||
for (int32_t aux = 0; aux < GPS_L5i_NH_CODE_LENGTH; aux++)
|
||||
for (int32_t aux = 0; aux < GPS_L5I_NH_CODE_LENGTH; aux++)
|
||||
{
|
||||
if (GPS_L5i_NH_CODE[aux] == 0)
|
||||
if (GPS_L5I_NH_CODE[aux] == 0)
|
||||
{
|
||||
bits_NH[aux] = -1.0;
|
||||
}
|
||||
@@ -154,9 +154,9 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u
|
||||
int32_t symbol_value = 0;
|
||||
|
||||
// Search correlation with Neuman-Hofman Code (see IS-GPS-705D)
|
||||
if (sym_hist.size() == GPS_L5i_NH_CODE_LENGTH)
|
||||
if (sym_hist.size() == GPS_L5I_NH_CODE_LENGTH)
|
||||
{
|
||||
for (int32_t i = 0; i < GPS_L5i_NH_CODE_LENGTH; i++)
|
||||
for (int32_t i = 0; i < GPS_L5I_NH_CODE_LENGTH; i++)
|
||||
{
|
||||
if ((bits_NH[i] * sym_hist.at(i)) > 0.0)
|
||||
{
|
||||
@@ -167,7 +167,7 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u
|
||||
corr_NH -= 1;
|
||||
}
|
||||
}
|
||||
if (abs(corr_NH) == GPS_L5i_NH_CODE_LENGTH)
|
||||
if (abs(corr_NH) == GPS_L5I_NH_CODE_LENGTH)
|
||||
{
|
||||
sync_NH = true;
|
||||
if (corr_NH > 0)
|
||||
@@ -241,12 +241,12 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u
|
||||
// delay by the formulae:
|
||||
// \code
|
||||
// symbolTime_ms = msg->tow * 6000 + *pdelay * 10 + (12 * 10); 12 symbols of the encoder's transitory
|
||||
d_TOW_at_current_symbol_ms = msg.tow * 6000 + (delay + 12) * GPS_L5i_SYMBOL_PERIOD_MS;
|
||||
d_TOW_at_current_symbol_ms = msg.tow * 6000 + (delay + 12) * GPS_L5I_SYMBOL_PERIOD_MS;
|
||||
d_flag_valid_word = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_TOW_at_current_symbol_ms += GPS_L5i_PERIOD_MS;
|
||||
d_TOW_at_current_symbol_ms += GPS_L5I_PERIOD_MS;
|
||||
if (current_synchro_data.Flag_valid_symbol_output == false)
|
||||
{
|
||||
d_flag_valid_word = false;
|
||||
|
||||
@@ -53,7 +53,7 @@ extern "C"
|
||||
|
||||
class gps_l5_telemetry_decoder_cc;
|
||||
|
||||
typedef boost::shared_ptr<gps_l5_telemetry_decoder_cc> gps_l5_telemetry_decoder_cc_sptr;
|
||||
using gps_l5_telemetry_decoder_cc_sptr = boost::shared_ptr<gps_l5_telemetry_decoder_cc>;
|
||||
|
||||
gps_l5_telemetry_decoder_cc_sptr
|
||||
gps_l5_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
@@ -90,7 +90,7 @@ private:
|
||||
bool d_flag_valid_word;
|
||||
|
||||
Gps_CNAV_Navigation_Message d_CNAV_Message;
|
||||
double bits_NH[GPS_L5i_NH_CODE_LENGTH]{};
|
||||
double bits_NH[GPS_L5I_NH_CODE_LENGTH]{};
|
||||
std::deque<double> sym_hist;
|
||||
bool sync_NH;
|
||||
bool new_sym;
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
*/
|
||||
|
||||
#include "sbas_l1_telemetry_decoder_cc.h"
|
||||
#include "control_message_factory.h"
|
||||
#include "gnss_synchro.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <glog/logging.h>
|
||||
@@ -65,7 +64,7 @@ sbas_l1_telemetry_decoder_cc::sbas_l1_telemetry_decoder_cc(
|
||||
d_dump = dump;
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
LOG(INFO) << "SBAS L1 TELEMETRY PROCESSING: satellite " << d_satellite;
|
||||
d_block_size = d_samples_per_symbol * d_symbols_per_bit * d_block_size_in_bits;
|
||||
d_block_size = D_SAMPLES_PER_SYMBOL * D_SYMBOLS_PER_BIT * D_BLOCK_SIZE_IN_BITS;
|
||||
d_channel = 0;
|
||||
set_output_multiple(1);
|
||||
}
|
||||
@@ -102,7 +101,7 @@ void sbas_l1_telemetry_decoder_cc::set_channel(int32_t channel)
|
||||
|
||||
|
||||
// ### helper class for sample alignment ###
|
||||
sbas_l1_telemetry_decoder_cc::sample_aligner::sample_aligner()
|
||||
sbas_l1_telemetry_decoder_cc::Sample_Aligner::Sample_Aligner()
|
||||
{
|
||||
d_n_smpls_in_history = 3;
|
||||
d_iir_par = 0.05;
|
||||
@@ -110,10 +109,10 @@ sbas_l1_telemetry_decoder_cc::sample_aligner::sample_aligner()
|
||||
}
|
||||
|
||||
|
||||
sbas_l1_telemetry_decoder_cc::sample_aligner::~sample_aligner() = default;
|
||||
sbas_l1_telemetry_decoder_cc::Sample_Aligner::~Sample_Aligner() = default;
|
||||
|
||||
|
||||
void sbas_l1_telemetry_decoder_cc::sample_aligner::reset()
|
||||
void sbas_l1_telemetry_decoder_cc::Sample_Aligner::reset()
|
||||
{
|
||||
d_past_sample = 0;
|
||||
d_corr_paired = 0;
|
||||
@@ -125,7 +124,7 @@ void sbas_l1_telemetry_decoder_cc::sample_aligner::reset()
|
||||
/*
|
||||
* samples length must be a multiple of two
|
||||
*/
|
||||
bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector<double> &samples, std::vector<double> &symbols)
|
||||
bool sbas_l1_telemetry_decoder_cc::Sample_Aligner::get_symbols(const std::vector<double> &samples, std::vector<double> &symbols)
|
||||
{
|
||||
double smpls[3] = {};
|
||||
double corr_diff;
|
||||
@@ -135,12 +134,12 @@ bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector
|
||||
VLOG(FLOW) << "get_symbols(): "
|
||||
<< "d_past_sample=" << d_past_sample << "\tsamples size=" << samples.size();
|
||||
|
||||
for (uint32_t i_sym = 0; i_sym < samples.size() / sbas_l1_telemetry_decoder_cc::d_samples_per_symbol; i_sym++)
|
||||
for (uint32_t i_sym = 0; i_sym < samples.size() / sbas_l1_telemetry_decoder_cc::D_SAMPLES_PER_SYMBOL; i_sym++)
|
||||
{
|
||||
// get the next samples
|
||||
for (int32_t i = 0; i < d_n_smpls_in_history; i++)
|
||||
{
|
||||
smpls[i] = static_cast<int32_t>(i_sym) * sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1 == -1 ? d_past_sample : samples[i_sym * sbas_l1_telemetry_decoder_cc::d_samples_per_symbol + i - 1];
|
||||
smpls[i] = static_cast<int32_t>(i_sym) * sbas_l1_telemetry_decoder_cc::D_SAMPLES_PER_SYMBOL + i - 1 == -1 ? d_past_sample : samples[i_sym * sbas_l1_telemetry_decoder_cc::D_SAMPLES_PER_SYMBOL + i - 1];
|
||||
}
|
||||
|
||||
// update the pseudo correlations (IIR method) of the two possible alignments
|
||||
@@ -183,7 +182,7 @@ bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector
|
||||
|
||||
|
||||
// ### helper class for symbol alignment and viterbi decoding ###
|
||||
sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::symbol_aligner_and_decoder()
|
||||
sbas_l1_telemetry_decoder_cc::Symbol_Aligner_And_Decoder::Symbol_Aligner_And_Decoder()
|
||||
{
|
||||
// convolutional code properties
|
||||
d_KK = 7;
|
||||
@@ -198,14 +197,14 @@ sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::symbol_aligner_and_dec
|
||||
}
|
||||
|
||||
|
||||
sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::~symbol_aligner_and_decoder()
|
||||
sbas_l1_telemetry_decoder_cc::Symbol_Aligner_And_Decoder::~Symbol_Aligner_And_Decoder()
|
||||
{
|
||||
delete d_vd1;
|
||||
delete d_vd2;
|
||||
}
|
||||
|
||||
|
||||
void sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::reset()
|
||||
void sbas_l1_telemetry_decoder_cc::Symbol_Aligner_And_Decoder::reset()
|
||||
{
|
||||
d_past_symbol = 0;
|
||||
d_vd1->reset();
|
||||
@@ -213,10 +212,10 @@ void sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::reset()
|
||||
}
|
||||
|
||||
|
||||
bool sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::get_bits(const std::vector<double> &symbols, std::vector<int32_t> &bits)
|
||||
bool sbas_l1_telemetry_decoder_cc::Symbol_Aligner_And_Decoder::get_bits(const std::vector<double> &symbols, std::vector<int32_t> &bits)
|
||||
{
|
||||
const int32_t traceback_depth = 5 * d_KK;
|
||||
int32_t nbits_requested = symbols.size() / d_symbols_per_bit;
|
||||
int32_t nbits_requested = symbols.size() / D_SYMBOLS_PER_BIT;
|
||||
int32_t nbits_decoded;
|
||||
// fill two vectors with the two possible symbol alignments
|
||||
std::vector<double> symbols_vd1(symbols); // aligned symbol vector -> copy input symbol vector
|
||||
@@ -252,13 +251,13 @@ bool sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::get_bits(const st
|
||||
|
||||
|
||||
// ### helper class for detecting the preamble and collect the corresponding message candidates ###
|
||||
void sbas_l1_telemetry_decoder_cc::frame_detector::reset()
|
||||
void sbas_l1_telemetry_decoder_cc::Frame_Detector::reset()
|
||||
{
|
||||
d_buffer.clear();
|
||||
}
|
||||
|
||||
|
||||
void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const std::vector<int32_t> &bits, std::vector<std::pair<int32_t, std::vector<int32_t>>> &msg_candidates)
|
||||
void sbas_l1_telemetry_decoder_cc::Frame_Detector::get_frame_candidates(const std::vector<int32_t> &bits, std::vector<std::pair<int32_t, std::vector<int32_t>>> &msg_candidates)
|
||||
{
|
||||
std::stringstream ss;
|
||||
uint32_t sbas_msg_length = 250;
|
||||
@@ -300,13 +299,17 @@ void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const st
|
||||
{
|
||||
// invert bits
|
||||
for (int &candidate_bit_it : candidate)
|
||||
candidate_bit_it = candidate_bit_it == 0 ? 1 : 0;
|
||||
{
|
||||
candidate_bit_it = candidate_bit_it == 0 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
msg_candidates.emplace_back(relative_preamble_start, candidate);
|
||||
ss.str("");
|
||||
ss << "preamble " << preample_it - preambles.begin() << (inv_preamble_detected ? " inverted" : " normal") << " detected! candidate=";
|
||||
for (auto bit_it = candidate.begin(); bit_it < candidate.end(); ++bit_it)
|
||||
ss << *bit_it;
|
||||
{
|
||||
ss << *bit_it;
|
||||
}
|
||||
VLOG(EVENT) << ss.str();
|
||||
}
|
||||
}
|
||||
@@ -318,12 +321,12 @@ void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const st
|
||||
|
||||
|
||||
// ### helper class for checking the CRC of the message candidates ###
|
||||
void sbas_l1_telemetry_decoder_cc::crc_verifier::reset()
|
||||
void sbas_l1_telemetry_decoder_cc::Crc_Verifier::reset()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void sbas_l1_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vector<msg_candiate_int_t> &msg_candidates, std::vector<msg_candiate_char_t> &valid_msgs)
|
||||
void sbas_l1_telemetry_decoder_cc::Crc_Verifier::get_valid_frames(const std::vector<msg_candiate_int_t> &msg_candidates, std::vector<msg_candiate_char_t> &valid_msgs)
|
||||
{
|
||||
std::stringstream ss;
|
||||
VLOG(FLOW) << "get_valid_frames(): "
|
||||
@@ -361,7 +364,7 @@ void sbas_l1_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vec
|
||||
}
|
||||
|
||||
|
||||
void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_bytes(const std::vector<int> &msg_candidate, std::vector<uint8_t> &bytes)
|
||||
void sbas_l1_telemetry_decoder_cc::Crc_Verifier::zerropad_back_and_convert_to_bytes(const std::vector<int> &msg_candidate, std::vector<uint8_t> &bytes)
|
||||
{
|
||||
std::stringstream ss;
|
||||
const size_t bits_per_byte = 8;
|
||||
@@ -388,7 +391,7 @@ void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_by
|
||||
}
|
||||
|
||||
|
||||
void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_front_and_convert_to_bytes(const std::vector<int32_t> &msg_candidate, std::vector<uint8_t> &bytes)
|
||||
void sbas_l1_telemetry_decoder_cc::Crc_Verifier::zerropad_front_and_convert_to_bytes(const std::vector<int32_t> &msg_candidate, std::vector<uint8_t> &bytes)
|
||||
{
|
||||
std::stringstream ss;
|
||||
const size_t bits_per_byte = 8;
|
||||
@@ -463,7 +466,7 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
|
||||
for (const auto &valid_msg : valid_msgs)
|
||||
{
|
||||
int32_t message_sample_offset =
|
||||
(sample_alignment ? 0 : -1) + d_samples_per_symbol * (symbol_alignment ? -1 : 0) + d_samples_per_symbol * d_symbols_per_bit * valid_msg.first;
|
||||
(sample_alignment ? 0 : -1) + D_SAMPLES_PER_SYMBOL * (symbol_alignment ? -1 : 0) + D_SAMPLES_PER_SYMBOL * D_SYMBOLS_PER_BIT * valid_msg.first;
|
||||
double message_sample_stamp = sample_stamp + static_cast<double>(message_sample_offset) / 1000.0;
|
||||
VLOG(EVENT) << "message_sample_stamp=" << message_sample_stamp
|
||||
<< " (sample_stamp=" << sample_stamp
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
class sbas_l1_telemetry_decoder_cc;
|
||||
|
||||
typedef boost::shared_ptr<sbas_l1_telemetry_decoder_cc> sbas_l1_telemetry_decoder_cc_sptr;
|
||||
using sbas_l1_telemetry_decoder_cc_sptr = boost::shared_ptr<sbas_l1_telemetry_decoder_cc>;
|
||||
|
||||
sbas_l1_telemetry_decoder_cc_sptr
|
||||
sbas_l1_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
|
||||
@@ -76,9 +76,9 @@ private:
|
||||
void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits);
|
||||
void align_samples();
|
||||
|
||||
static const int32_t d_samples_per_symbol = 2;
|
||||
static const int32_t d_symbols_per_bit = 2;
|
||||
static const int32_t d_block_size_in_bits = 30;
|
||||
static const int32_t D_SAMPLES_PER_SYMBOL = 2;
|
||||
static const int32_t D_SYMBOLS_PER_BIT = 2;
|
||||
static const int32_t D_BLOCK_SIZE_IN_BITS = 30;
|
||||
|
||||
bool d_dump;
|
||||
Gnss_Satellite d_satellite;
|
||||
@@ -94,11 +94,11 @@ private:
|
||||
typedef std::pair<int32_t, std::vector<uint8_t>> msg_candiate_char_t;
|
||||
|
||||
// helper class for sample alignment
|
||||
class sample_aligner
|
||||
class Sample_Aligner
|
||||
{
|
||||
public:
|
||||
sample_aligner();
|
||||
~sample_aligner();
|
||||
Sample_Aligner();
|
||||
~Sample_Aligner();
|
||||
void reset();
|
||||
/*
|
||||
* samples length must be a multiple of two
|
||||
@@ -116,11 +116,11 @@ private:
|
||||
} d_sample_aligner;
|
||||
|
||||
// helper class for symbol alignment and Viterbi decoding
|
||||
class symbol_aligner_and_decoder
|
||||
class Symbol_Aligner_And_Decoder
|
||||
{
|
||||
public:
|
||||
symbol_aligner_and_decoder();
|
||||
~symbol_aligner_and_decoder();
|
||||
Symbol_Aligner_And_Decoder();
|
||||
~Symbol_Aligner_And_Decoder();
|
||||
void reset();
|
||||
bool get_bits(const std::vector<double> &symbols, std::vector<int32_t> &bits);
|
||||
|
||||
@@ -133,7 +133,7 @@ private:
|
||||
|
||||
|
||||
// helper class for detecting the preamble and collect the corresponding message candidates
|
||||
class frame_detector
|
||||
class Frame_Detector
|
||||
{
|
||||
public:
|
||||
void reset();
|
||||
@@ -145,7 +145,7 @@ private:
|
||||
|
||||
|
||||
// helper class for checking the CRC of the message candidates
|
||||
class crc_verifier
|
||||
class Crc_Verifier
|
||||
{
|
||||
public:
|
||||
void reset();
|
||||
|
||||
@@ -33,21 +33,27 @@ list(SORT TELEMETRY_DECODER_LIB_SOURCES)
|
||||
|
||||
source_group(Headers FILES ${TELEMETRY_DECODER_LIB_HEADERS})
|
||||
|
||||
add_library(telemetry_decoder_lib
|
||||
add_library(telemetry_decoder_libs
|
||||
${TELEMETRY_DECODER_LIB_SOURCES}
|
||||
${TELEMETRY_DECODER_LIB_HEADERS}
|
||||
)
|
||||
|
||||
target_link_libraries(telemetry_decoder_lib
|
||||
PUBLIC
|
||||
gnss_system_parameters
|
||||
gnss_rx
|
||||
target_link_libraries(telemetry_decoder_libs
|
||||
PRIVATE
|
||||
Gflags::gflags
|
||||
Glog::glog
|
||||
)
|
||||
|
||||
set_property(TARGET telemetry_decoder_lib
|
||||
if(ENABLE_CLANG_TIDY)
|
||||
if(CLANG_TIDY_EXE)
|
||||
set_target_properties(telemetry_decoder_libs
|
||||
PROPERTIES
|
||||
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_property(TARGET telemetry_decoder_libs
|
||||
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
)
|
||||
|
||||
@@ -88,7 +88,7 @@ inline static int parity_counter(int symbol, int length)
|
||||
inline static int nsc_enc_bit(int state_out_p[],
|
||||
int input,
|
||||
int state_in,
|
||||
int g[],
|
||||
const int g[],
|
||||
int KK,
|
||||
int nn)
|
||||
{
|
||||
@@ -144,7 +144,7 @@ inline static void nsc_transit(int output_p[],
|
||||
* \param[in] nn The length of the received vector
|
||||
*
|
||||
*/
|
||||
inline static float Gamma(float rec_array[],
|
||||
inline static float Gamma(const float rec_array[],
|
||||
int symbol,
|
||||
int nn)
|
||||
{
|
||||
@@ -155,7 +155,9 @@ inline static float Gamma(float rec_array[],
|
||||
for (i = 0; i < nn; i++)
|
||||
{
|
||||
if (symbol & mask)
|
||||
rm += rec_array[nn - i - 1];
|
||||
{
|
||||
rm += rec_array[nn - i - 1];
|
||||
}
|
||||
mask = mask << 1;
|
||||
}
|
||||
return (rm);
|
||||
@@ -175,11 +177,11 @@ inline static float Gamma(float rec_array[],
|
||||
*
|
||||
*/
|
||||
inline static void Viterbi(int output_u_int[],
|
||||
int out0[],
|
||||
int state0[],
|
||||
int out1[],
|
||||
int state1[],
|
||||
double input_c[],
|
||||
const int out0[],
|
||||
const int state0[],
|
||||
const int out1[],
|
||||
const int state1[],
|
||||
const double input_c[],
|
||||
int KK,
|
||||
int nn,
|
||||
int LL)
|
||||
@@ -219,11 +221,15 @@ inline static void Viterbi(int output_u_int[],
|
||||
for (t = 0; t < LL + mm; t++)
|
||||
{
|
||||
for (i = 0; i < nn; i++)
|
||||
rec_array[i] = static_cast<float>(input_c[nn * t + i]);
|
||||
{
|
||||
rec_array[i] = static_cast<float>(input_c[nn * t + i]);
|
||||
}
|
||||
|
||||
/* precompute all possible branch metrics */
|
||||
for (i = 0; i < number_symbols; i++)
|
||||
metric_c[i] = Gamma(rec_array, i, nn);
|
||||
{
|
||||
metric_c[i] = Gamma(rec_array, i, nn);
|
||||
}
|
||||
|
||||
/* step through all states */
|
||||
for (state = 0; state < states; state++)
|
||||
|
||||
@@ -30,12 +30,11 @@
|
||||
*/
|
||||
|
||||
#include "bits.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static const u8 bitn[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
|
||||
static const uint8_t BITN[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
|
||||
|
||||
/** \defgroup bits Bit Utils
|
||||
* Bit field packing, unpacking and utility functions.
|
||||
@@ -50,7 +49,7 @@ static const u8 bitn[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
|
||||
* \return 1 if there are an odd number of bits set.
|
||||
* 0 if there are an even number of bits set.
|
||||
*/
|
||||
u8 parity(u32 x)
|
||||
uint8_t parity(uint32_t x)
|
||||
{
|
||||
x ^= x >> 16;
|
||||
x ^= x >> 8;
|
||||
@@ -69,14 +68,14 @@ u8 parity(u32 x)
|
||||
* \param len Length of bit field in bits.
|
||||
* \return Bit field as an unsigned value.
|
||||
*/
|
||||
u32 getbitu(const u8 *buff, u32 pos, u8 len)
|
||||
uint32_t getbitu(const uint8_t *buff, uint32_t pos, uint8_t len)
|
||||
{
|
||||
u32 bits = 0;
|
||||
u32 i=0;
|
||||
uint32_t bits = 0;
|
||||
uint32_t i = 0;
|
||||
for (i = pos; i < pos + len; i++)
|
||||
{
|
||||
bits = (bits << 1) +
|
||||
((buff[i/8] >> (7 - i%8)) & 1u);
|
||||
((buff[i / 8] >> (7 - i % 8)) & 1u);
|
||||
}
|
||||
|
||||
return bits;
|
||||
@@ -93,14 +92,14 @@ u32 getbitu(const u8 *buff, u32 pos, u8 len)
|
||||
* \param len Length of bit field in bits.
|
||||
* \return Bit field as a signed value.
|
||||
*/
|
||||
s32 getbits(const u8 *buff, u32 pos, u8 len)
|
||||
int32_t getbits(const uint8_t *buff, uint32_t pos, uint8_t len)
|
||||
{
|
||||
s32 bits = (s32)getbitu(buff, pos, len);
|
||||
int32_t bits = (int32_t)getbitu(buff, pos, len);
|
||||
|
||||
/* Sign extend, taken from:
|
||||
* http://graphics.stanford.edu/~seander/bithacks.html#VariableSignExtend
|
||||
*/
|
||||
s32 m = 1u << (len - 1);
|
||||
int32_t m = 1u << (len - 1);
|
||||
return (bits ^ m) - m;
|
||||
}
|
||||
|
||||
@@ -113,19 +112,25 @@ s32 getbits(const u8 *buff, u32 pos, u8 len)
|
||||
* \param len Length of bit field in bits.
|
||||
* \param data Unsigned integer to be packed into bit field.
|
||||
*/
|
||||
void setbitu(u8 *buff, u32 pos, u32 len, u32 data)
|
||||
void setbitu(uint8_t *buff, uint32_t pos, uint32_t len, uint32_t data)
|
||||
{
|
||||
u32 mask = 1u << (len - 1);
|
||||
uint32_t mask = 1u << (len - 1);
|
||||
|
||||
if (len <= 0 || 32 < len)
|
||||
return;
|
||||
u32 i = 0;
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint32_t i = 0;
|
||||
for (i = pos; i < pos + len; i++, mask >>= 1)
|
||||
{
|
||||
if (data & mask)
|
||||
buff[i/8] |= 1u << (7 - i % 8);
|
||||
{
|
||||
buff[i / 8] |= 1u << (7 - i % 8);
|
||||
}
|
||||
else
|
||||
buff[i/8] &= ~(1u << (7 - i % 8));
|
||||
{
|
||||
buff[i / 8] &= ~(1u << (7 - i % 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +143,9 @@ void setbitu(u8 *buff, u32 pos, u32 len, u32 data)
|
||||
* \param len Length of bit field in bits.
|
||||
* \param data Signed integer to be packed into bit field.
|
||||
*/
|
||||
void setbits(u8 *buff, u32 pos, u32 len, s32 data)
|
||||
void setbits(uint8_t *buff, uint32_t pos, uint32_t len, int32_t data)
|
||||
{
|
||||
setbitu(buff, pos, len, (u32)data);
|
||||
setbitu(buff, pos, len, (uint32_t)data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +158,7 @@ void setbits(u8 *buff, u32 pos, u32 len, s32 data)
|
||||
*
|
||||
* \return None
|
||||
*/
|
||||
void bitshl(void *buf, u32 size, u32 shift)
|
||||
void bitshl(void *buf, uint32_t size, uint32_t shift)
|
||||
{
|
||||
if (shift > size * CHAR_BIT)
|
||||
{
|
||||
@@ -162,12 +167,12 @@ void bitshl(void *buf, u32 size, u32 shift)
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char *dst = buf; /* Destination byte. */
|
||||
unsigned char *dst = buf; /* Destination byte. */
|
||||
const unsigned char *src = dst + shift / CHAR_BIT; /* First source byte, possibly incomplete. */
|
||||
|
||||
u32 copy_bits = size * CHAR_BIT - shift; /* Number of bits to move */
|
||||
u32 byte_shift = copy_bits % CHAR_BIT; /* Shift of data */
|
||||
u32 full_bytes = copy_bits / CHAR_BIT; /* Number of bytes to move */
|
||||
uint32_t copy_bits = size * CHAR_BIT - shift; /* Number of bits to move */
|
||||
uint32_t byte_shift = copy_bits % CHAR_BIT; /* Shift of data */
|
||||
uint32_t full_bytes = copy_bits / CHAR_BIT; /* Number of bytes to move */
|
||||
|
||||
if (0 == byte_shift)
|
||||
{
|
||||
@@ -179,8 +184,8 @@ void bitshl(void *buf, u32 size, u32 shift)
|
||||
else
|
||||
{
|
||||
/* Create an accumulator: it will hold a value of two consecutive bytes */
|
||||
u32 acc = *src++;
|
||||
u32 i = 0;
|
||||
uint32_t acc = *src++;
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < full_bytes; ++i)
|
||||
{
|
||||
acc = (acc << CHAR_BIT) | *src++;
|
||||
@@ -210,22 +215,22 @@ void bitshl(void *buf, u32 size, u32 shift)
|
||||
* \todo This function can be optimized for copying aligned data and using
|
||||
* proper native type like long.
|
||||
*/
|
||||
void bitcopy(void *dst, u32 dst_index, const void *src, u32 src_index,
|
||||
u32 count)
|
||||
void bitcopy(void *dst, uint32_t dst_index, const void *src, uint32_t src_index,
|
||||
uint32_t count)
|
||||
{
|
||||
u32 limit1 = count / 32;
|
||||
u32 limit2 = count % 32;
|
||||
u32 idx = 0;
|
||||
uint32_t limit1 = count / 32;
|
||||
uint32_t limit2 = count % 32;
|
||||
uint32_t idx = 0;
|
||||
for (idx = 0; idx < limit1; ++idx)
|
||||
{
|
||||
u32 tmp = getbitu(src, src_index, 32);
|
||||
uint32_t tmp = getbitu(src, src_index, 32);
|
||||
setbitu(dst, dst_index, 32, tmp);
|
||||
src_index += 32;
|
||||
dst_index += 32;
|
||||
}
|
||||
if (0 != limit2)
|
||||
{
|
||||
u32 tmp = getbitu(src, src_index, limit2);
|
||||
uint32_t tmp = getbitu(src, src_index, limit2);
|
||||
setbitu(dst, dst_index, limit2, tmp);
|
||||
}
|
||||
}
|
||||
@@ -238,12 +243,14 @@ void bitcopy(void *dst, u32 dst_index, const void *src, u32 src_index,
|
||||
*
|
||||
* \return Number of bits set to one or zero.
|
||||
*/
|
||||
u8 count_bits_u64(u64 v, u8 bv)
|
||||
uint8_t count_bits_u64(uint64_t v, uint8_t bv)
|
||||
{
|
||||
u8 r = 0;
|
||||
uint8_t r = 0;
|
||||
int i = 0;
|
||||
for (i = 0; i < 16; i++)
|
||||
r += bitn[(v >> (i*4)) & 0xf];
|
||||
{
|
||||
r += BITN[(v >> (i * 4)) & 0xf];
|
||||
}
|
||||
return bv == 1 ? r : 64 - r;
|
||||
}
|
||||
|
||||
@@ -255,12 +262,14 @@ u8 count_bits_u64(u64 v, u8 bv)
|
||||
*
|
||||
* \return Number of bits set to one or zero.
|
||||
*/
|
||||
u8 count_bits_u32(u32 v, u8 bv)
|
||||
uint8_t count_bits_u32(uint32_t v, uint8_t bv)
|
||||
{
|
||||
u8 r = 0;
|
||||
uint8_t r = 0;
|
||||
int i = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
r += bitn[(v >> (i*4)) & 0xf];
|
||||
{
|
||||
r += BITN[(v >> (i * 4)) & 0xf];
|
||||
}
|
||||
return bv == 1 ? r : 32 - r;
|
||||
}
|
||||
|
||||
@@ -272,12 +281,14 @@ u8 count_bits_u32(u32 v, u8 bv)
|
||||
*
|
||||
* \return Number of bits set to one or zero.
|
||||
*/
|
||||
u8 count_bits_u16(u16 v, u8 bv)
|
||||
uint8_t count_bits_u16(uint16_t v, uint8_t bv)
|
||||
{
|
||||
u8 r = 0;
|
||||
uint8_t r = 0;
|
||||
int i = 0;
|
||||
for (i= 0; i < 4; i++)
|
||||
r += bitn[(v >> (i*4)) & 0xf];
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
r += BITN[(v >> (i * 4)) & 0xf];
|
||||
}
|
||||
return bv == 1 ? r : 16 - r;
|
||||
}
|
||||
|
||||
@@ -289,12 +300,14 @@ u8 count_bits_u16(u16 v, u8 bv)
|
||||
*
|
||||
* \return Number of bits set to one or zero.
|
||||
*/
|
||||
u8 count_bits_u8(u8 v, u8 bv)
|
||||
uint8_t count_bits_u8(uint8_t v, uint8_t bv)
|
||||
{
|
||||
u8 r = 0;
|
||||
uint8_t r = 0;
|
||||
int i = 0;
|
||||
for (i = 0; i < 2; i++)
|
||||
r += bitn[(v >> (i*4)) & 0xf];
|
||||
{
|
||||
r += BITN[(v >> (i * 4)) & 0xf];
|
||||
}
|
||||
return bv == 1 ? r : 8 - r;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,17 +34,17 @@
|
||||
|
||||
#include "swift_common.h"
|
||||
|
||||
u8 parity(u32 x);
|
||||
u32 getbitu(const u8 *buff, u32 pos, u8 len);
|
||||
s32 getbits(const u8 *buff, u32 pos, u8 len);
|
||||
void setbitu(u8 *buff, u32 pos, u32 len, u32 data);
|
||||
void setbits(u8 *buff, u32 pos, u32 len, s32 data);
|
||||
void bitcopy(void *dst, u32 dst_index,
|
||||
const void *src, u32 src_index, u32 count);
|
||||
void bitshl(void *buf, u32 size, u32 shift);
|
||||
u8 count_bits_u64(u64 v, u8 bv);
|
||||
u8 count_bits_u32(u32 v, u8 bv);
|
||||
u8 count_bits_u16(u16 v, u8 bv);
|
||||
u8 count_bits_u8(u8 v, u8 bv);
|
||||
uint8_t parity(uint32_t x);
|
||||
uint32_t getbitu(const uint8_t *buff, uint32_t pos, uint8_t len);
|
||||
int32_t getbits(const uint8_t *buff, uint32_t pos, uint8_t len);
|
||||
void setbitu(uint8_t *buff, uint32_t pos, uint32_t len, uint32_t data);
|
||||
void setbits(uint8_t *buff, uint32_t pos, uint32_t len, int32_t data);
|
||||
void bitcopy(void *dst, uint32_t dst_index,
|
||||
const void *src, uint32_t src_index, uint32_t count);
|
||||
void bitshl(void *buf, uint32_t size, uint32_t shift);
|
||||
uint8_t count_bits_u64(uint64_t v, uint8_t bv);
|
||||
uint8_t count_bits_u32(uint32_t v, uint8_t bv);
|
||||
uint8_t count_bits_u16(uint16_t v, uint8_t bv);
|
||||
uint8_t count_bits_u8(uint8_t v, uint8_t bv);
|
||||
|
||||
#endif /* LIBSWIFTNAV_BITS_H */
|
||||
|
||||
@@ -56,9 +56,9 @@
|
||||
*/
|
||||
|
||||
/** GPS L2C preamble */
|
||||
const u32 GPS_CNAV_PREAMBLE1 = 0x8Bu; /* (0b10001011u) */
|
||||
const uint32_t GPS_CNAV_PREAMBLE1 = 0x8Bu; /* (0b10001011u) */
|
||||
/** Inverted GPS L2C preamble */
|
||||
const u32 GPS_CNAV_PREAMBLE2 = 0x74u; /* (0b01110100u) */
|
||||
const uint32_t GPS_CNAV_PREAMBLE2 = 0x74u; /* (0b01110100u) */
|
||||
/** GPS L2C preamble length in bits */
|
||||
#define GPS_CNAV_PREAMBLE_LENGTH (8)
|
||||
/** GPS L2C CNAV message length in bits */
|
||||
@@ -81,9 +81,9 @@ const u32 GPS_CNAV_PREAMBLE2 = 0x74u; /* (0b01110100u) */
|
||||
*
|
||||
* \private
|
||||
*/
|
||||
static u32 _cnav_compute_crc(cnav_v27_part_t *part)
|
||||
static uint32_t _cnav_compute_crc(cnav_v27_part_t *part)
|
||||
{
|
||||
u32 crc = crc24q_bits(0, part->decoded, GPS_CNAV_MSG_DATA_LENGTH,
|
||||
uint32_t crc = crc24q_bits(0, part->decoded, GPS_CNAV_MSG_DATA_LENGTH,
|
||||
part->invert);
|
||||
|
||||
return crc;
|
||||
@@ -100,9 +100,9 @@ static u32 _cnav_compute_crc(cnav_v27_part_t *part)
|
||||
*
|
||||
* \private
|
||||
*/
|
||||
static u32 _cnav_extract_crc(const cnav_v27_part_t *part)
|
||||
static uint32_t _cnav_extract_crc(const cnav_v27_part_t *part)
|
||||
{
|
||||
u32 crc = getbitu(part->decoded, GPS_CNAV_MSG_DATA_LENGTH,
|
||||
uint32_t crc = getbitu(part->decoded, GPS_CNAV_MSG_DATA_LENGTH,
|
||||
GPS_CNAV_MSG_CRC_LENGTH);
|
||||
if (part->invert)
|
||||
{
|
||||
@@ -136,7 +136,7 @@ static void _cnav_rescan_preamble(cnav_v27_part_t *part)
|
||||
size_t j = 0;
|
||||
for (i = 1, j = part->n_decoded - GPS_CNAV_PREAMBLE_LENGTH; i < j; ++i)
|
||||
{
|
||||
u32 c = getbitu(part->decoded, i, GPS_CNAV_PREAMBLE_LENGTH);
|
||||
uint32_t c = getbitu(part->decoded, i, GPS_CNAV_PREAMBLE_LENGTH);
|
||||
if (GPS_CNAV_PREAMBLE1 == c || GPS_CNAV_PREAMBLE2 == c)
|
||||
{
|
||||
part->preamble_seen = true;
|
||||
@@ -171,7 +171,7 @@ static void _cnav_rescan_preamble(cnav_v27_part_t *part)
|
||||
*
|
||||
* \private
|
||||
*/
|
||||
static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch)
|
||||
static void _cnav_add_symbol(cnav_v27_part_t *part, uint8_t ch)
|
||||
{
|
||||
part->symbols[part->n_symbols++] = ch;
|
||||
|
||||
@@ -240,8 +240,8 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch)
|
||||
{
|
||||
/* We have collected 300 bits starting from message preamble. Now try
|
||||
* to compute CRC-24Q */
|
||||
u32 crc = _cnav_compute_crc(part);
|
||||
u32 crc2 = _cnav_extract_crc(part);
|
||||
uint32_t crc = _cnav_compute_crc(part);
|
||||
uint32_t crc2 = _cnav_extract_crc(part);
|
||||
|
||||
if (part->message_lock)
|
||||
{
|
||||
@@ -332,7 +332,7 @@ static void _cnav_msg_invert(cnav_v27_part_t *part)
|
||||
*
|
||||
* \private
|
||||
*/
|
||||
static bool _cnav_msg_decode(cnav_v27_part_t *part, cnav_msg_t *msg, u32 *delay)
|
||||
static bool _cnav_msg_decode(cnav_v27_part_t *part, cnav_msg_t *msg, uint32_t *delay)
|
||||
{
|
||||
bool res = false;
|
||||
if (GPS_CNAV_MSG_LENGTH <= part->n_decoded)
|
||||
@@ -425,9 +425,9 @@ void cnav_msg_decoder_init(cnav_msg_decoder_t *dec)
|
||||
* \retval false More data is required.
|
||||
*/
|
||||
bool cnav_msg_decoder_add_symbol(cnav_msg_decoder_t *dec,
|
||||
u8 symbol,
|
||||
uint8_t symbol,
|
||||
cnav_msg_t *msg,
|
||||
u32 *pdelay)
|
||||
uint32_t *pdelay)
|
||||
{
|
||||
_cnav_add_symbol(&dec->part1, symbol);
|
||||
_cnav_add_symbol(&dec->part2, symbol);
|
||||
|
||||
@@ -60,11 +60,11 @@
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
u8 prn; /**< SV PRN. 0..31 */
|
||||
u8 msg_id; /**< Message id. 0..31 */
|
||||
u32 tow; /**< GPS ToW in 6-second units. Multiply to 6 to get seconds. */
|
||||
bool alert; /**< CNAV message alert flag */
|
||||
u8 raw_msg[GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS]; /**< RAW MSG for GNSS-SDR */
|
||||
uint8_t prn; /**< SV PRN. 0..31 */
|
||||
uint8_t msg_id; /**< Message id. 0..31 */
|
||||
uint32_t tow; /**< GPS ToW in 6-second units. Multiply to 6 to get seconds. */
|
||||
bool alert; /**< CNAV message alert flag */
|
||||
uint8_t raw_msg[GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS]; /**< RAW MSG for GNSS-SDR */
|
||||
} cnav_msg_t;
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ void cnav_msg_decoder_init(cnav_msg_decoder_t *dec);
|
||||
bool cnav_msg_decoder_add_symbol(cnav_msg_decoder_t *dec,
|
||||
unsigned char symbol,
|
||||
cnav_msg_t *msg,
|
||||
u32 *delay);
|
||||
uint32_t *delay);
|
||||
|
||||
/** \} */
|
||||
/** \} */
|
||||
|
||||
@@ -39,40 +39,39 @@
|
||||
* Cyclic redundancy checks.
|
||||
* \{ */
|
||||
|
||||
static const u32 crc24qtab[256] = {
|
||||
0x000000, 0x864CFB, 0x8AD50D, 0x0C99F6, 0x93E6E1, 0x15AA1A, 0x1933EC, 0x9F7F17,
|
||||
0xA18139, 0x27CDC2, 0x2B5434, 0xAD18CF, 0x3267D8, 0xB42B23, 0xB8B2D5, 0x3EFE2E,
|
||||
0xC54E89, 0x430272, 0x4F9B84, 0xC9D77F, 0x56A868, 0xD0E493, 0xDC7D65, 0x5A319E,
|
||||
0x64CFB0, 0xE2834B, 0xEE1ABD, 0x685646, 0xF72951, 0x7165AA, 0x7DFC5C, 0xFBB0A7,
|
||||
0x0CD1E9, 0x8A9D12, 0x8604E4, 0x00481F, 0x9F3708, 0x197BF3, 0x15E205, 0x93AEFE,
|
||||
0xAD50D0, 0x2B1C2B, 0x2785DD, 0xA1C926, 0x3EB631, 0xB8FACA, 0xB4633C, 0x322FC7,
|
||||
0xC99F60, 0x4FD39B, 0x434A6D, 0xC50696, 0x5A7981, 0xDC357A, 0xD0AC8C, 0x56E077,
|
||||
0x681E59, 0xEE52A2, 0xE2CB54, 0x6487AF, 0xFBF8B8, 0x7DB443, 0x712DB5, 0xF7614E,
|
||||
0x19A3D2, 0x9FEF29, 0x9376DF, 0x153A24, 0x8A4533, 0x0C09C8, 0x00903E, 0x86DCC5,
|
||||
0xB822EB, 0x3E6E10, 0x32F7E6, 0xB4BB1D, 0x2BC40A, 0xAD88F1, 0xA11107, 0x275DFC,
|
||||
0xDCED5B, 0x5AA1A0, 0x563856, 0xD074AD, 0x4F0BBA, 0xC94741, 0xC5DEB7, 0x43924C,
|
||||
0x7D6C62, 0xFB2099, 0xF7B96F, 0x71F594, 0xEE8A83, 0x68C678, 0x645F8E, 0xE21375,
|
||||
0x15723B, 0x933EC0, 0x9FA736, 0x19EBCD, 0x8694DA, 0x00D821, 0x0C41D7, 0x8A0D2C,
|
||||
0xB4F302, 0x32BFF9, 0x3E260F, 0xB86AF4, 0x2715E3, 0xA15918, 0xADC0EE, 0x2B8C15,
|
||||
0xD03CB2, 0x567049, 0x5AE9BF, 0xDCA544, 0x43DA53, 0xC596A8, 0xC90F5E, 0x4F43A5,
|
||||
0x71BD8B, 0xF7F170, 0xFB6886, 0x7D247D, 0xE25B6A, 0x641791, 0x688E67, 0xEEC29C,
|
||||
0x3347A4, 0xB50B5F, 0xB992A9, 0x3FDE52, 0xA0A145, 0x26EDBE, 0x2A7448, 0xAC38B3,
|
||||
0x92C69D, 0x148A66, 0x181390, 0x9E5F6B, 0x01207C, 0x876C87, 0x8BF571, 0x0DB98A,
|
||||
0xF6092D, 0x7045D6, 0x7CDC20, 0xFA90DB, 0x65EFCC, 0xE3A337, 0xEF3AC1, 0x69763A,
|
||||
0x578814, 0xD1C4EF, 0xDD5D19, 0x5B11E2, 0xC46EF5, 0x42220E, 0x4EBBF8, 0xC8F703,
|
||||
0x3F964D, 0xB9DAB6, 0xB54340, 0x330FBB, 0xAC70AC, 0x2A3C57, 0x26A5A1, 0xA0E95A,
|
||||
0x9E1774, 0x185B8F, 0x14C279, 0x928E82, 0x0DF195, 0x8BBD6E, 0x872498, 0x016863,
|
||||
0xFAD8C4, 0x7C943F, 0x700DC9, 0xF64132, 0x693E25, 0xEF72DE, 0xE3EB28, 0x65A7D3,
|
||||
0x5B59FD, 0xDD1506, 0xD18CF0, 0x57C00B, 0xC8BF1C, 0x4EF3E7, 0x426A11, 0xC426EA,
|
||||
0x2AE476, 0xACA88D, 0xA0317B, 0x267D80, 0xB90297, 0x3F4E6C, 0x33D79A, 0xB59B61,
|
||||
0x8B654F, 0x0D29B4, 0x01B042, 0x87FCB9, 0x1883AE, 0x9ECF55, 0x9256A3, 0x141A58,
|
||||
0xEFAAFF, 0x69E604, 0x657FF2, 0xE33309, 0x7C4C1E, 0xFA00E5, 0xF69913, 0x70D5E8,
|
||||
0x4E2BC6, 0xC8673D, 0xC4FECB, 0x42B230, 0xDDCD27, 0x5B81DC, 0x57182A, 0xD154D1,
|
||||
0x26359F, 0xA07964, 0xACE092, 0x2AAC69, 0xB5D37E, 0x339F85, 0x3F0673, 0xB94A88,
|
||||
0x87B4A6, 0x01F85D, 0x0D61AB, 0x8B2D50, 0x145247, 0x921EBC, 0x9E874A, 0x18CBB1,
|
||||
0xE37B16, 0x6537ED, 0x69AE1B, 0xEFE2E0, 0x709DF7, 0xF6D10C, 0xFA48FA, 0x7C0401,
|
||||
0x42FA2F, 0xC4B6D4, 0xC82F22, 0x4E63D9, 0xD11CCE, 0x575035, 0x5BC9C3, 0xDD8538
|
||||
};
|
||||
static const uint32_t CRC24QTAB[256] = {
|
||||
0x000000, 0x864CFB, 0x8AD50D, 0x0C99F6, 0x93E6E1, 0x15AA1A, 0x1933EC, 0x9F7F17,
|
||||
0xA18139, 0x27CDC2, 0x2B5434, 0xAD18CF, 0x3267D8, 0xB42B23, 0xB8B2D5, 0x3EFE2E,
|
||||
0xC54E89, 0x430272, 0x4F9B84, 0xC9D77F, 0x56A868, 0xD0E493, 0xDC7D65, 0x5A319E,
|
||||
0x64CFB0, 0xE2834B, 0xEE1ABD, 0x685646, 0xF72951, 0x7165AA, 0x7DFC5C, 0xFBB0A7,
|
||||
0x0CD1E9, 0x8A9D12, 0x8604E4, 0x00481F, 0x9F3708, 0x197BF3, 0x15E205, 0x93AEFE,
|
||||
0xAD50D0, 0x2B1C2B, 0x2785DD, 0xA1C926, 0x3EB631, 0xB8FACA, 0xB4633C, 0x322FC7,
|
||||
0xC99F60, 0x4FD39B, 0x434A6D, 0xC50696, 0x5A7981, 0xDC357A, 0xD0AC8C, 0x56E077,
|
||||
0x681E59, 0xEE52A2, 0xE2CB54, 0x6487AF, 0xFBF8B8, 0x7DB443, 0x712DB5, 0xF7614E,
|
||||
0x19A3D2, 0x9FEF29, 0x9376DF, 0x153A24, 0x8A4533, 0x0C09C8, 0x00903E, 0x86DCC5,
|
||||
0xB822EB, 0x3E6E10, 0x32F7E6, 0xB4BB1D, 0x2BC40A, 0xAD88F1, 0xA11107, 0x275DFC,
|
||||
0xDCED5B, 0x5AA1A0, 0x563856, 0xD074AD, 0x4F0BBA, 0xC94741, 0xC5DEB7, 0x43924C,
|
||||
0x7D6C62, 0xFB2099, 0xF7B96F, 0x71F594, 0xEE8A83, 0x68C678, 0x645F8E, 0xE21375,
|
||||
0x15723B, 0x933EC0, 0x9FA736, 0x19EBCD, 0x8694DA, 0x00D821, 0x0C41D7, 0x8A0D2C,
|
||||
0xB4F302, 0x32BFF9, 0x3E260F, 0xB86AF4, 0x2715E3, 0xA15918, 0xADC0EE, 0x2B8C15,
|
||||
0xD03CB2, 0x567049, 0x5AE9BF, 0xDCA544, 0x43DA53, 0xC596A8, 0xC90F5E, 0x4F43A5,
|
||||
0x71BD8B, 0xF7F170, 0xFB6886, 0x7D247D, 0xE25B6A, 0x641791, 0x688E67, 0xEEC29C,
|
||||
0x3347A4, 0xB50B5F, 0xB992A9, 0x3FDE52, 0xA0A145, 0x26EDBE, 0x2A7448, 0xAC38B3,
|
||||
0x92C69D, 0x148A66, 0x181390, 0x9E5F6B, 0x01207C, 0x876C87, 0x8BF571, 0x0DB98A,
|
||||
0xF6092D, 0x7045D6, 0x7CDC20, 0xFA90DB, 0x65EFCC, 0xE3A337, 0xEF3AC1, 0x69763A,
|
||||
0x578814, 0xD1C4EF, 0xDD5D19, 0x5B11E2, 0xC46EF5, 0x42220E, 0x4EBBF8, 0xC8F703,
|
||||
0x3F964D, 0xB9DAB6, 0xB54340, 0x330FBB, 0xAC70AC, 0x2A3C57, 0x26A5A1, 0xA0E95A,
|
||||
0x9E1774, 0x185B8F, 0x14C279, 0x928E82, 0x0DF195, 0x8BBD6E, 0x872498, 0x016863,
|
||||
0xFAD8C4, 0x7C943F, 0x700DC9, 0xF64132, 0x693E25, 0xEF72DE, 0xE3EB28, 0x65A7D3,
|
||||
0x5B59FD, 0xDD1506, 0xD18CF0, 0x57C00B, 0xC8BF1C, 0x4EF3E7, 0x426A11, 0xC426EA,
|
||||
0x2AE476, 0xACA88D, 0xA0317B, 0x267D80, 0xB90297, 0x3F4E6C, 0x33D79A, 0xB59B61,
|
||||
0x8B654F, 0x0D29B4, 0x01B042, 0x87FCB9, 0x1883AE, 0x9ECF55, 0x9256A3, 0x141A58,
|
||||
0xEFAAFF, 0x69E604, 0x657FF2, 0xE33309, 0x7C4C1E, 0xFA00E5, 0xF69913, 0x70D5E8,
|
||||
0x4E2BC6, 0xC8673D, 0xC4FECB, 0x42B230, 0xDDCD27, 0x5B81DC, 0x57182A, 0xD154D1,
|
||||
0x26359F, 0xA07964, 0xACE092, 0x2AAC69, 0xB5D37E, 0x339F85, 0x3F0673, 0xB94A88,
|
||||
0x87B4A6, 0x01F85D, 0x0D61AB, 0x8B2D50, 0x145247, 0x921EBC, 0x9E874A, 0x18CBB1,
|
||||
0xE37B16, 0x6537ED, 0x69AE1B, 0xEFE2E0, 0x709DF7, 0xF6D10C, 0xFA48FA, 0x7C0401,
|
||||
0x42FA2F, 0xC4B6D4, 0xC82F22, 0x4E63D9, 0xD11CCE, 0x575035, 0x5BC9C3, 0xDD8538};
|
||||
|
||||
/** Calculate Qualcomm 24-bit Cyclical Redundancy Check (CRC-24Q).
|
||||
*
|
||||
@@ -89,11 +88,13 @@ static const u32 crc24qtab[256] = {
|
||||
*
|
||||
* \return CRC-24Q value
|
||||
*/
|
||||
u32 crc24q(const u8 *buf, u32 len, u32 crc)
|
||||
uint32_t crc24q(const uint8_t *buf, uint32_t len, uint32_t crc)
|
||||
{
|
||||
u32 i = 0;
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < len; i++)
|
||||
crc = ((crc << 8) & 0xFFFFFF) ^ crc24qtab[((crc >> 16) ^ buf[i]) & 0xff];
|
||||
{
|
||||
crc = ((crc << 8) & 0xFFFFFF) ^ CRC24QTAB[((crc >> 16) ^ buf[i]) & 0xff];
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
@@ -112,30 +113,30 @@ u32 crc24q(const u8 *buf, u32 len, u32 crc)
|
||||
*
|
||||
* \return CRC-24Q value
|
||||
*/
|
||||
u32 crc24q_bits(u32 crc, const u8 *buf, u32 n_bits, bool invert)
|
||||
uint32_t crc24q_bits(uint32_t crc, const uint8_t *buf, uint32_t n_bits, bool invert)
|
||||
{
|
||||
u16 acc = 0;
|
||||
u8 b = 0;
|
||||
u32 shift = 8 - n_bits % 8;
|
||||
uint16_t acc = 0;
|
||||
uint8_t b = 0;
|
||||
uint32_t shift = 8 - n_bits % 8;
|
||||
|
||||
u32 i = 0;
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < n_bits / 8; ++i)
|
||||
{
|
||||
acc = (acc << 8) | *buf++;
|
||||
acc = (acc << 8) | *buf++;
|
||||
if (invert)
|
||||
{
|
||||
acc ^= 0xFFu;
|
||||
}
|
||||
b = (acc >> shift) & 0xFFu;
|
||||
crc = ((crc << 8) & 0xFFFFFFu) ^ crc24qtab[((crc >> 16) ^ b) & 0xFFu];
|
||||
b = (acc >> shift) & 0xFFu;
|
||||
crc = ((crc << 8) & 0xFFFFFFu) ^ CRC24QTAB[((crc >> 16) ^ b) & 0xFFu];
|
||||
}
|
||||
acc = (acc << 8) | *buf;
|
||||
acc = (acc << 8) | *buf;
|
||||
if (invert)
|
||||
{
|
||||
acc ^= 0xFFu;
|
||||
}
|
||||
b = (acc >> shift) & 0xFFu;
|
||||
crc = ((crc << 8) & 0xFFFFFFu) ^ crc24qtab[((crc >> 16) ^ b) & 0xFFu];
|
||||
b = (acc >> shift) & 0xFFu;
|
||||
crc = ((crc << 8) & 0xFFFFFFu) ^ CRC24QTAB[((crc >> 16) ^ b) & 0xFFu];
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "swift_common.h"
|
||||
|
||||
u32 crc24q(const u8 *buf, u32 len, u32 crc);
|
||||
u32 crc24q_bits(u32 crc, const u8 *buf, u32 n_bits, bool invert);
|
||||
uint32_t crc24q(const uint8_t *buf, uint32_t len, uint32_t crc);
|
||||
uint32_t crc24q_bits(uint32_t crc, const uint8_t *buf, uint32_t n_bits, bool invert);
|
||||
|
||||
#endif /* LIBSWIFTNAV_EDC_H */
|
||||
|
||||
@@ -48,37 +48,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef COMMON_INT_TYPES
|
||||
#define COMMON_INT_TYPES
|
||||
|
||||
/** \defgroup common_inttypes Integer types
|
||||
* Specified-width integer type definitions for shorter and nicer code.
|
||||
*
|
||||
* These should be used in preference to unspecified width types such as
|
||||
* `int` which can lead to portability issues between different platforms.
|
||||
* \{ */
|
||||
|
||||
/** Signed 8-bit integer. */
|
||||
typedef int8_t s8;
|
||||
/** Signed 16-bit integer. */
|
||||
typedef int16_t s16;
|
||||
/** Signed 32-bit integer. */
|
||||
typedef int32_t s32;
|
||||
/** Signed 64-bit integer. */
|
||||
typedef int64_t s64;
|
||||
/** Unsigned 8-bit integer. */
|
||||
typedef uint8_t u8;
|
||||
/** Unsigned 16-bit integer. */
|
||||
typedef uint16_t u16;
|
||||
/** Unsigned 32-bit integer. */
|
||||
typedef uint32_t u32;
|
||||
/** Unsigned 64-bit integer. */
|
||||
typedef uint64_t u64;
|
||||
|
||||
#endif
|
||||
|
||||
/** \} */
|
||||
|
||||
/** \} */
|
||||
|
||||
#endif /* LIBSWIFTNAV_COMMON_H */
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "fec.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static inline int parity(int x)
|
||||
{
|
||||
@@ -52,10 +52,10 @@ void v27_poly_init(v27_poly_t *poly, const signed char polynomial[2])
|
||||
{
|
||||
int state;
|
||||
|
||||
for(state = 0; state < 32; state++)
|
||||
for (state = 0; state < 32; state++)
|
||||
{
|
||||
poly->c0[state] = (polynomial[0] < 0) ^ parity((2*state) & abs(polynomial[0])) ? 255 : 0;
|
||||
poly->c1[state] = (polynomial[1] < 0) ^ parity((2*state) & abs(polynomial[1])) ? 255 : 0;
|
||||
poly->c0[state] = (polynomial[0] < 0) ^ parity((2 * state) & abs(polynomial[0])) ? 255 : 0;
|
||||
poly->c1[state] = (polynomial[1] < 0) ^ parity((2 * state) & abs(polynomial[1])) ? 255 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void v27_poly_init(v27_poly_t *poly, const signed char polynomial[2])
|
||||
* \param initial_state Initial state of the decoder shift register. Usually zero.
|
||||
*/
|
||||
void v27_init(v27_t *v, v27_decision_t *decisions, unsigned int decisions_count,
|
||||
const v27_poly_t *poly, unsigned char initial_state)
|
||||
const v27_poly_t *poly, unsigned char initial_state)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -83,28 +83,31 @@ void v27_init(v27_t *v, v27_decision_t *decisions, unsigned int decisions_count,
|
||||
v->decisions_index = 0;
|
||||
v->decisions_count = decisions_count;
|
||||
|
||||
for(i = 0; i < 64; i++)
|
||||
v->old_metrics[i] = 63;
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
v->old_metrics[i] = 63;
|
||||
}
|
||||
|
||||
v->old_metrics[initial_state & 63] = 0; /* Bias known start state */
|
||||
}
|
||||
|
||||
|
||||
/* C-language butterfly */
|
||||
#define BFLY(i) {\
|
||||
unsigned int metric,m0,m1,decision;\
|
||||
metric = (v->poly->c0[i] ^ sym0) + (v->poly->c1[i] ^ sym1);\
|
||||
m0 = v->old_metrics[i] + metric;\
|
||||
m1 = v->old_metrics[(i)+32] + (510 - metric);\
|
||||
decision = (signed int)(m0-m1) > 0;\
|
||||
v->new_metrics[2*(i)] = decision ? m1 : m0;\
|
||||
d->w[(i)/16] |= decision << ((2*(i))&31);\
|
||||
m0 -= (metric+metric-510);\
|
||||
m1 += (metric+metric-510);\
|
||||
decision = (signed int)(m0-m1) > 0;\
|
||||
v->new_metrics[2*(i)+1] = decision ? m1 : m0;\
|
||||
d->w[(i)/16] |= decision << ((2*(i)+1)&31);\
|
||||
}
|
||||
#define BFLY(i) \
|
||||
{ \
|
||||
unsigned int metric, m0, m1, decision; \
|
||||
metric = (v->poly->c0[i] ^ sym0) + (v->poly->c1[i] ^ sym1); \
|
||||
m0 = v->old_metrics[i] + metric; \
|
||||
m1 = v->old_metrics[(i) + 32] + (510 - metric); \
|
||||
decision = (signed int)(m0 - m1) > 0; \
|
||||
v->new_metrics[2 * (i)] = decision ? m1 : m0; \
|
||||
d->w[(i) / 16] |= decision << ((2 * (i)) & 31); \
|
||||
m0 -= (metric + metric - 510); \
|
||||
m1 += (metric + metric - 510); \
|
||||
decision = (signed int)(m0 - m1) > 0; \
|
||||
v->new_metrics[2 * (i) + 1] = decision ? m1 : m0; \
|
||||
d->w[(i) / 16] |= decision << ((2 * (i) + 1) & 31); \
|
||||
}
|
||||
|
||||
/** Update a v27_t decoder with a block of symbols.
|
||||
*
|
||||
@@ -119,7 +122,7 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits)
|
||||
unsigned int *tmp;
|
||||
int normalize = 0;
|
||||
|
||||
while(nbits--)
|
||||
while (nbits--)
|
||||
{
|
||||
v27_decision_t *d = &v->decisions[v->decisions_index];
|
||||
|
||||
@@ -161,26 +164,32 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits)
|
||||
BFLY(31);
|
||||
|
||||
/* Normalize metrics if they are nearing overflow */
|
||||
if(v->new_metrics[0] > (1 << 30))
|
||||
if (v->new_metrics[0] > (1 << 30))
|
||||
{
|
||||
int i;
|
||||
unsigned int minmetric = 1 << 31;
|
||||
|
||||
for(i = 0; i < 64; i++)
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
if(v->new_metrics[i] < minmetric)
|
||||
minmetric = v->new_metrics[i];
|
||||
if (v->new_metrics[i] < minmetric)
|
||||
{
|
||||
minmetric = v->new_metrics[i];
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < 64; i++)
|
||||
v->new_metrics[i] -= minmetric;
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
v->new_metrics[i] -= minmetric;
|
||||
}
|
||||
|
||||
normalize += minmetric;
|
||||
}
|
||||
|
||||
/* Advance decision index */
|
||||
if(++v->decisions_index >= v->decisions_count)
|
||||
v->decisions_index = 0;
|
||||
if (++v->decisions_index >= v->decisions_count)
|
||||
{
|
||||
v->decisions_index = 0;
|
||||
}
|
||||
|
||||
/* Swap pointers to old and new metrics */
|
||||
tmp = v->old_metrics;
|
||||
@@ -199,7 +208,7 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits)
|
||||
* \param final_state Known final state of the decoder shift register.
|
||||
*/
|
||||
void v27_chainback_fixed(v27_t *v, unsigned char *data, unsigned int nbits,
|
||||
unsigned char final_state)
|
||||
unsigned char final_state)
|
||||
{
|
||||
int k;
|
||||
unsigned int decisions_index = v->decisions_index;
|
||||
@@ -207,12 +216,10 @@ void v27_chainback_fixed(v27_t *v, unsigned char *data, unsigned int nbits,
|
||||
final_state %= 64;
|
||||
final_state <<= 2;
|
||||
|
||||
while(nbits-- != 0)
|
||||
while (nbits-- != 0)
|
||||
{
|
||||
|
||||
/* Decrement decision index */
|
||||
decisions_index = (decisions_index == 0) ?
|
||||
v->decisions_count-1 : decisions_index-1;
|
||||
decisions_index = (decisions_index == 0) ? v->decisions_count - 1 : decisions_index - 1;
|
||||
|
||||
v27_decision_t *d = &v->decisions[decisions_index];
|
||||
k = (d->w[(final_state >> 2) / 32] >> ((final_state >> 2) % 32)) & 1;
|
||||
@@ -239,9 +246,9 @@ void v27_chainback_likely(v27_t *v, unsigned char *data, unsigned int nbits)
|
||||
int i;
|
||||
unsigned int best_metric = 0xffffffff;
|
||||
unsigned char best_state = 0;
|
||||
for(i = 0; i < 64; i++)
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
if(v->new_metrics[i] < best_metric)
|
||||
if (v->new_metrics[i] < best_metric)
|
||||
{
|
||||
best_metric = v->new_metrics[i];
|
||||
best_state = i;
|
||||
|
||||
@@ -199,7 +199,9 @@ int Viterbi_Decoder::do_acs(const double sym[], int nbits)
|
||||
{
|
||||
/* Temporarily store the received symbols current decoding step */
|
||||
for (i = 0; i < d_nn; i++)
|
||||
d_rec_array[i] = static_cast<float>(sym[d_nn * t + i]);
|
||||
{
|
||||
d_rec_array[i] = static_cast<float>(sym[d_nn * t + i]);
|
||||
}
|
||||
|
||||
/* precompute all possible branch metrics */
|
||||
for (i = 0; i < d_number_symbols; i++)
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
*/
|
||||
float decode_block(const double input_c[], int* output_u_int, const int LL);
|
||||
|
||||
float decode_continuous(const double sym[], const int traceback_depth, int output_u_int[],
|
||||
float decode_continuous(const double sym[], const int traceback_depth, int bits[],
|
||||
const int nbits_requested, int& nbits_decoded);
|
||||
|
||||
private:
|
||||
@@ -113,7 +113,7 @@ private:
|
||||
void init_trellis_state();
|
||||
int do_acs(const double sym[], int nbits);
|
||||
int do_traceback(std::size_t traceback_length);
|
||||
int do_tb_and_decode(int traceback_length, int requested_decoding_length, int state, int bits[], float& indicator_metric);
|
||||
int do_tb_and_decode(int traceback_length, int requested_decoding_length, int state, int output_u_int[], float& indicator_metric);
|
||||
|
||||
// branch metric function
|
||||
float gamma(const float rec_array[], int symbol, int nn);
|
||||
|
||||
Reference in New Issue
Block a user