1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-24 22:13:15 +00:00

Add more extensive use of cstdint typenames

This commit is contained in:
Carles Fernandez 2018-08-13 13:03:01 +02:00
parent 65a0804084
commit 6cee58bdc1
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
16 changed files with 369 additions and 371 deletions

View File

@ -53,18 +53,18 @@ galileo_e1b_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump
}
void galileo_e1b_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int *page_part_bits)
void galileo_e1b_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits)
{
Viterbi(page_part_bits, out0, state0, out1, state1,
page_part_symbols, KK, nn, DataLength);
}
void galileo_e1b_telemetry_decoder_cc::deinterleaver(int rows, int cols, double *in, double *out)
void galileo_e1b_telemetry_decoder_cc::deinterleaver(int32_t rows, int32_t cols, double *in, double *out)
{
for (int r = 0; r < rows; r++)
for (int32_t r = 0; r < rows; r++)
{
for (int c = 0; c < cols; c++)
for (int32_t c = 0; c < cols; c++)
{
out[c * rows + r] = in[r * cols + c];
}
@ -86,18 +86,18 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc(
d_samples_per_symbol = (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS) / Galileo_E1_B_SYMBOL_RATE_BPS;
// set the preamble
unsigned short int preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS] = GALILEO_INAV_PREAMBLE;
uint16_t preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS] = GALILEO_INAV_PREAMBLE;
d_symbols_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS * d_samples_per_symbol;
memcpy(static_cast<unsigned short int *>(this->d_preambles_bits), static_cast<unsigned short int *>(preambles_bits), GALILEO_INAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int));
memcpy(static_cast<uint16_t *>(this->d_preambles_bits), static_cast<uint16_t *>(preambles_bits), GALILEO_INAV_PREAMBLE_LENGTH_BITS * sizeof(uint16_t));
// preamble bits to sampled symbols
d_preambles_symbols = static_cast<int *>(volk_gnsssdr_malloc(d_symbols_per_preamble * sizeof(int), volk_gnsssdr_get_alignment()));
int n = 0;
for (int i = 0; i < GALILEO_INAV_PREAMBLE_LENGTH_BITS; i++)
d_preambles_symbols = static_cast<int32_t *>(volk_gnsssdr_malloc(d_symbols_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
int32_t n = 0;
for (int32_t i = 0; i < GALILEO_INAV_PREAMBLE_LENGTH_BITS; i++)
{
for (unsigned int j = 0; j < d_samples_per_symbol; j++)
for (uint32_t j = 0; j < d_samples_per_symbol; j++)
{
if (d_preambles_bits[i] == 1)
{
@ -110,9 +110,9 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc(
n++;
}
}
d_sample_counter = 0;
d_sample_counter = 0ULL;
d_stat = 0;
d_preamble_index = 0;
d_preamble_index = 0ULL;
d_flag_frame_sync = false;
@ -127,14 +127,14 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc(
flag_TOW_set = false;
// vars for Viterbi decoder
int max_states = 1 << mm; /* 2^mm */
g_encoder[0] = 121; // Polynomial G1
g_encoder[1] = 91; // Polynomial G2
out0 = static_cast<int *>(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment()));
out1 = static_cast<int *>(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment()));
state0 = static_cast<int *>(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment()));
state1 = static_cast<int *>(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment()));
/* create appropriate transition matrices */
int32_t max_states = 1 << mm; // 2^mm
g_encoder[0] = 121; // Polynomial G1
g_encoder[1] = 91; // Polynomial G2
out0 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
out1 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
state0 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
state1 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
// create appropriate transition matrices
nsc_transit(out0, state0, 0, g_encoder, KK, nn);
nsc_transit(out1, state1, 1, g_encoder, KK, nn);
}
@ -161,7 +161,7 @@ galileo_e1b_telemetry_decoder_cc::~galileo_e1b_telemetry_decoder_cc()
}
void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, int frame_length)
void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, int32_t frame_length)
{
double page_part_symbols_deint[frame_length];
// 1. De-interleave
@ -169,8 +169,8 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in
// 2. Viterbi decoder
// 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder)
// 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180<EFBFBD>
for (int i = 0; i < frame_length; i++)
// 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180º
for (int32_t i = 0; i < frame_length; i++)
{
if ((i + 1) % 2 == 0)
{
@ -178,12 +178,12 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in
}
}
int page_part_bits[frame_length / 2];
int32_t page_part_bits[frame_length / 2];
viterbi_decoder(page_part_symbols_deint, page_part_bits);
// 3. Call the Galileo page decoder
std::string page_String;
for (int i = 0; i < (frame_length / 2); i++)
for (int32_t i = 0; i < (frame_length / 2); i++)
{
if (page_part_bits[i] > 0)
{
@ -268,7 +268,7 @@ void galileo_e1b_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satel
}
void galileo_e1b_telemetry_decoder_cc::set_channel(int channel)
void galileo_e1b_telemetry_decoder_cc::set_channel(int32_t channel)
{
d_channel = channel;
LOG(INFO) << "Navigation channel set to " << channel;
@ -298,8 +298,8 @@ void galileo_e1b_telemetry_decoder_cc::set_channel(int channel)
int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
int corr_value = 0;
int preamble_diff = 0;
int32_t corr_value = 0;
int32_t preamble_diff = 0;
Gnss_Synchro **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
const Gnss_Synchro **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
@ -312,13 +312,13 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute
consume_each(1);
d_flag_preamble = false;
unsigned int required_symbols = GALILEO_INAV_PAGE_SYMBOLS + d_symbols_per_preamble;
uint32_t required_symbols = GALILEO_INAV_PAGE_SYMBOLS + d_symbols_per_preamble;
if (d_symbol_history.size() > required_symbols)
{
// TODO Optimize me!
// ******* preamble correlation ********
for (int i = 0; i < d_symbols_per_preamble; i++)
for (int32_t i = 0; i < d_symbols_per_preamble; i++)
{
if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping
{
@ -346,7 +346,7 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute
if (abs(corr_value) >= d_symbols_per_preamble)
{
// check preamble separation
preamble_diff = d_sample_counter - d_preamble_index;
preamble_diff = static_cast<int32_t>(d_sample_counter - d_preamble_index);
if (abs(preamble_diff - GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) == 0)
{
// try to decode frame
@ -365,14 +365,14 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute
}
else if (d_stat == 2)
{
if (d_sample_counter == d_preamble_index + GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS)
if (d_sample_counter == d_preamble_index + static_cast<uint64_t>(GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS))
{
// NEW Galileo page part is received
// 0. fetch the symbols into an array
int frame_length = GALILEO_INAV_PAGE_PART_SYMBOLS - d_symbols_per_preamble;
int32_t frame_length = GALILEO_INAV_PAGE_PART_SYMBOLS - d_symbols_per_preamble;
double page_part_symbols[frame_length];
for (int i = 0; i < frame_length; i++)
for (int32_t i = 0; i < frame_length; i++)
{
if (corr_value > 0)
{
@ -423,7 +423,7 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute
if (d_nav.flag_TOW_5 == true) // page 5 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec)
{
// 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<unsigned int>(d_nav.TOW_5 * 1000.0);
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_nav.TOW_5 * 1000.0);
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + GALILEO_INAV_PAGE_PART_MS + (required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS;
d_nav.flag_TOW_5 = false;
}
@ -431,7 +431,7 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute
else if (d_nav.flag_TOW_6 == true) // page 6 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec)
{
// 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<unsigned int>(d_nav.TOW_6 * 1000.0);
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_nav.TOW_6 * 1000.0);
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + GALILEO_INAV_PAGE_PART_MS + (required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS;
d_nav.flag_TOW_6 = false;
}

View File

@ -61,8 +61,8 @@ class galileo_e1b_telemetry_decoder_cc : public gr::block
public:
~galileo_e1b_telemetry_decoder_cc();
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
void set_channel(int channel); //!< Set receiver's channel
int flag_even_word_arrived;
void set_channel(int32_t channel); //!< Set receiver's channel
int32_t flag_even_word_arrived;
/*!
* \brief This is where all signal processing takes place
@ -75,38 +75,38 @@ private:
galileo_e1b_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
galileo_e1b_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
void viterbi_decoder(double *page_part_symbols, int *page_part_bits);
void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits);
void deinterleaver(int rows, int cols, double *in, double *out);
void deinterleaver(int32_t rows, int32_t cols, double *in, double *out);
void decode_word(double *symbols, int frame_length);
void decode_word(double *symbols, int32_t frame_length);
unsigned short int d_preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS];
uint16_t d_preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS];
int *d_preambles_symbols;
unsigned int d_samples_per_symbol;
int d_symbols_per_preamble;
int32_t *d_preambles_symbols;
uint32_t d_samples_per_symbol;
int32_t d_symbols_per_preamble;
std::deque<Gnss_Synchro> d_symbol_history;
uint64_t d_sample_counter;
uint64_t d_preamble_index;
unsigned int d_stat;
uint32_t d_stat;
bool d_flag_frame_sync;
bool d_flag_parity;
bool d_flag_preamble;
int d_CRC_error_counter;
int32_t d_CRC_error_counter;
// navigation message vars
Galileo_Navigation_Message d_nav;
bool d_dump;
Gnss_Satellite d_satellite;
int d_channel;
int32_t d_channel;
unsigned int d_TOW_at_Preamble_ms;
unsigned int d_TOW_at_current_symbol_ms;
uint32_t d_TOW_at_Preamble_ms;
uint32_t d_TOW_at_current_symbol_ms;
bool flag_TOW_set;
double delta_t; //GPS-GALILEO time offset
@ -115,13 +115,13 @@ private:
std::ofstream d_dump_file;
// vars for Viterbi decoder
int *out0, *out1, *state0, *state1;
int g_encoder[2];
const int nn = 2; // Coding rate 1/n
const int KK = 7; // Constraint Length
int mm = KK - 1;
const int CodeLength = 240;
int DataLength = (CodeLength / nn) - mm;
int32_t *out0, *out1, *state0, *state1;
int32_t g_encoder[2];
const int32_t nn = 2; // Coding rate 1/n
const int32_t KK = 7; // Constraint Length
int32_t mm = KK - 1;
const int32_t CodeLength = 240;
int32_t DataLength = (CodeLength / nn) - mm;
};
#endif

View File

@ -58,18 +58,18 @@ galileo_e5a_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump
}
void galileo_e5a_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int *page_part_bits)
void galileo_e5a_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits)
{
Viterbi(page_part_bits, out0, state0, out1, state1,
page_part_symbols, KK, nn, DataLength);
}
void galileo_e5a_telemetry_decoder_cc::deinterleaver(int rows, int cols, double *in, double *out)
void galileo_e5a_telemetry_decoder_cc::deinterleaver(int32_t rows, int32_t cols, double *in, double *out)
{
for (int r = 0; r < rows; r++)
for (int32_t r = 0; r < rows; r++)
{
for (int c = 0; c < cols; c++)
for (int32_t c = 0; c < cols; c++)
{
out[c * rows + r] = in[r * cols + c];
}
@ -77,7 +77,7 @@ void galileo_e5a_telemetry_decoder_cc::deinterleaver(int rows, int cols, double
}
void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int frame_length)
void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int32_t frame_length)
{
double page_symbols_deint[frame_length];
// 1. De-interleave
@ -86,19 +86,19 @@ void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int fra
// 2. Viterbi decoder
// 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder)
// 2.2 Take into account the possible inversion of the polarity due to PLL lock at 180<38>
for (int i = 0; i < frame_length; i++)
for (int32_t i = 0; i < frame_length; i++)
{
if ((i + 1) % 2 == 0)
{
page_symbols_deint[i] = -page_symbols_deint[i];
}
}
int page_bits[frame_length / 2];
int32_t page_bits[frame_length / 2];
viterbi_decoder(page_symbols_deint, page_bits);
// 3. Call the Galileo page decoder
std::string page_String;
for (int i = 0; i < frame_length; i++)
for (int32_t i = 0; i < frame_length; i++)
{
if (page_bits[i] > 0)
{
@ -156,7 +156,7 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc(
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
// set the preamble
for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
for (int32_t i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
{
if (GALILEO_FNAV_PREAMBLE.at(i) == '0')
{
@ -167,19 +167,19 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc(
d_preambles_bits[i] = -1;
}
}
for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
for (int32_t i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
{
for (int k = 0; k < GALILEO_FNAV_CODES_PER_SYMBOL; k++)
for (int32_t k = 0; k < GALILEO_FNAV_CODES_PER_SYMBOL; k++)
{
d_preamble_samples[(i * GALILEO_FNAV_CODES_PER_SYMBOL) + k] = d_preambles_bits[i];
}
}
d_sample_counter = 0;
d_sample_counter = 0ULL;
d_stat = 0;
corr_value = 0;
d_flag_preamble = false;
d_preamble_index = 0;
d_preamble_index = 0ULL;
d_flag_frame_sync = false;
d_TOW_at_current_symbol_ms = 0;
d_TOW_at_Preamble_ms = 0;
@ -194,13 +194,13 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc(
required_symbols = GALILEO_FNAV_SYMBOLS_PER_PAGE + GALILEO_FNAV_PREAMBLE_LENGTH_BITS;
// vars for Viterbi decoder
int max_states = 1 << mm; // 2^mm
g_encoder[0] = 121; // Polynomial G1
g_encoder[1] = 91; // Polynomial G2
out0 = static_cast<int *>(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment()));
out1 = static_cast<int *>(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment()));
state0 = static_cast<int *>(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment()));
state1 = static_cast<int *>(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment()));
int32_t max_states = 1 << mm; // 2^mm
g_encoder[0] = 121; // Polynomial G1
g_encoder[1] = 91; // Polynomial G2
out0 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
out1 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
state0 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
state1 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
// create appropriate transition matrices
nsc_transit(out0, state0, 0, g_encoder, KK, nn);
nsc_transit(out1, state1, 1, g_encoder, KK, nn);
@ -235,7 +235,7 @@ void galileo_e5a_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satel
}
void galileo_e5a_telemetry_decoder_cc::set_channel(int channel)
void galileo_e5a_telemetry_decoder_cc::set_channel(int32_t channel)
{
d_channel = channel;
LOG(INFO) << "Navigation channel set to " << channel;
@ -265,7 +265,7 @@ void galileo_e5a_telemetry_decoder_cc::set_channel(int channel)
int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
int preamble_diff = 0;
int32_t preamble_diff = 0;
Gnss_Synchro *out = reinterpret_cast<Gnss_Synchro *>(output_items[0]); // Get the output buffer pointer
const Gnss_Synchro *in = reinterpret_cast<const Gnss_Synchro *>(input_items[0]); // Get the input buffer pointer
@ -298,8 +298,8 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
if (d_preamble_init.size() == GALILEO_FNAV_CODES_PER_PREAMBLE)
{
std::deque<int>::iterator iter;
int k = 0;
std::deque<int32_t>::iterator iter;
int32_t k = 0;
corr_value = 0;
for (iter = d_preamble_init.begin(); iter != d_preamble_init.end(); iter++)
{
@ -330,7 +330,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
{
// ****************** Preamble orrelation ******************
corr_value = 0;
for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
for (int32_t i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
{
if (d_symbol_history.at(i).Prompt_I < 0.0) // symbols clipping
{
@ -357,7 +357,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
if (abs(corr_value) == GALILEO_FNAV_PREAMBLE_LENGTH_BITS)
{
// check preamble separation
preamble_diff = d_sample_counter - d_preamble_index;
preamble_diff = static_cast<int32_t>(d_sample_counter - d_preamble_index);
if (preamble_diff == GALILEO_FNAV_CODES_PER_PAGE)
{
// try to decode frame
@ -375,11 +375,11 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
}
else if ((d_stat == 2) && new_symbol)
{
if (d_sample_counter == (d_preamble_index + GALILEO_FNAV_CODES_PER_PAGE))
if (d_sample_counter == (d_preamble_index + static_cast<uint64_t>(GALILEO_FNAV_CODES_PER_PAGE)))
{
// NEW Galileo page part is received
// 0. fetch the symbols into an array
int frame_length = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS;
int32_t frame_length = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS;
double corr_sign = 0.0;
if (corr_value > 0)
{
@ -389,7 +389,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
{
corr_sign = 1.0;
}
for (int i = 0; i < frame_length; i++)
for (int32_t i = 0; i < frame_length; i++)
{
page_symbols[i] = corr_sign * d_symbol_history.at(i + GALILEO_FNAV_PREAMBLE_LENGTH_BITS).Prompt_I; // because last symbol of the preamble is just received now!
}
@ -435,25 +435,25 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
{
if (d_nav.flag_TOW_1 == true)
{
d_TOW_at_Preamble_ms = static_cast<unsigned int>(d_nav.FNAV_TOW_1 * 1000.0);
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_nav.FNAV_TOW_1 * 1000.0);
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS;
d_nav.flag_TOW_1 = false;
}
else if (d_nav.flag_TOW_2 == true)
{
d_TOW_at_Preamble_ms = static_cast<unsigned int>(d_nav.FNAV_TOW_2 * 1000.0);
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_nav.FNAV_TOW_2 * 1000.0);
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS;
d_nav.flag_TOW_2 = false;
}
else if (d_nav.flag_TOW_3 == true)
{
d_TOW_at_Preamble_ms = static_cast<unsigned int>(d_nav.FNAV_TOW_3 * 1000.0);
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_nav.FNAV_TOW_3 * 1000.0);
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS;
d_nav.flag_TOW_3 = false;
}
else if (d_nav.flag_TOW_4 == true)
{
d_TOW_at_Preamble_ms = static_cast<unsigned int>(d_nav.FNAV_TOW_4 * 1000.0);
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_nav.FNAV_TOW_4 * 1000.0);
d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS;
d_nav.flag_TOW_4 = false;
}

View File

@ -67,7 +67,7 @@ class galileo_e5a_telemetry_decoder_cc : public gr::block
public:
~galileo_e5a_telemetry_decoder_cc();
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
void set_channel(int channel); //!< Set receiver's channel
void set_channel(int32_t channel); //!< Set receiver's channel
/*!
* \brief This is where all signal processing takes place
*/
@ -79,21 +79,21 @@ private:
galileo_e5a_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
galileo_e5a_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
void viterbi_decoder(double *page_part_symbols, int *page_part_bits);
void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits);
void deinterleaver(int rows, int cols, double *in, double *out);
void deinterleaver(int32_t rows, int32_t cols, double *in, double *out);
void decode_word(double *page_symbols, int frame_length);
void decode_word(double *page_symbols, int32_t frame_length);
int d_preambles_bits[GALILEO_FNAV_PREAMBLE_LENGTH_BITS];
int d_preamble_samples[GALILEO_FNAV_CODES_PER_PREAMBLE];
int32_t d_preambles_bits[GALILEO_FNAV_PREAMBLE_LENGTH_BITS];
int32_t d_preamble_samples[GALILEO_FNAV_CODES_PER_PREAMBLE];
std::deque<int> d_preamble_init;
int d_stat;
int d_CRC_error_counter;
int d_channel;
int d_symbol_counter;
int corr_value;
unsigned int required_symbols;
int32_t d_stat;
int32_t d_CRC_error_counter;
int32_t d_channel;
int32_t d_symbol_counter;
int32_t corr_value;
uint32_t required_symbols;
uint64_t d_sample_counter;
uint64_t d_preamble_index;
bool d_flag_frame_sync;
@ -104,8 +104,8 @@ private:
bool new_symbol;
double d_prompt_acum;
double page_symbols[GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS];
unsigned int d_TOW_at_Preamble_ms;
unsigned int d_TOW_at_current_symbol_ms;
uint32_t d_TOW_at_Preamble_ms;
uint32_t d_TOW_at_current_symbol_ms;
double delta_t; //GPS-GALILEO time offset
std::string d_dump_filename;
std::ofstream d_dump_file;
@ -115,13 +115,13 @@ private:
Galileo_Fnav_Message d_nav;
// vars for Viterbi decoder
int *out0, *out1, *state0, *state1;
int g_encoder[2];
const int nn = 2; // Coding rate 1/n
const int KK = 7; // Constraint Length
int mm = KK - 1;
const int CodeLength = 488;
int DataLength = (CodeLength / nn) - mm;
int32_t *out0, *out1, *state0, *state1;
int32_t g_encoder[2];
const int32_t nn = 2; // Coding rate 1/n
const int32_t KK = 7; // Constraint Length
int32_t mm = KK - 1;
const int32_t CodeLength = 488;
int32_t DataLength = (CodeLength / nn) - mm;
};
#endif /* GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_CC_H_ */

View File

@ -65,18 +65,18 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc(
d_samples_per_symbol = (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS) / GLONASS_L1_CA_SYMBOL_RATE_BPS;
// Set the preamble information
unsigned short int preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE;
uint16_t preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE;
// Since preamble rate is different than navigation data rate we use a constant
d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS;
memcpy(static_cast<unsigned short int *>(this->d_preambles_bits), static_cast<unsigned short int *>(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int));
memcpy(static_cast<uint16_t *>(this->d_preambles_bits), static_cast<uint16_t *>(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(uint16_t));
// preamble bits to sampled symbols
d_preambles_symbols = static_cast<signed int *>(malloc(sizeof(signed int) * d_symbols_per_preamble));
int n = 0;
for (int i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++)
d_preambles_symbols = static_cast<int32_t *>(malloc(sizeof(int32_t) * d_symbols_per_preamble));
int32_t n = 0;
for (int32_t i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++)
{
for (unsigned int j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++)
for (uint32_t j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++)
{
if (d_preambles_bits[i] == 1)
{
@ -89,9 +89,9 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc(
n++;
}
}
d_sample_counter = 0;
d_sample_counter = 0ULL;
d_stat = 0;
d_preamble_index = 0;
d_preamble_index = 0ULL;
d_flag_frame_sync = false;
@ -124,10 +124,10 @@ glonass_l1_ca_telemetry_decoder_cc::~glonass_l1_ca_telemetry_decoder_cc()
}
void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int frame_length)
void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int32_t frame_length)
{
double chip_acc = 0.0;
int chip_acc_counter = 0;
int32_t chip_acc_counter = 0;
// 1. Transform from symbols to bits
std::string bi_binary_code;
@ -135,7 +135,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
std::string data_bits;
// Group samples into bi-binary code
for (int i = 0; i < (frame_length); i++)
for (int32_t i = 0; i < (frame_length); i++)
{
chip_acc += frame_symbols[i];
chip_acc_counter += 1;
@ -157,7 +157,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
}
}
// Convert from bi-binary code to relative code
for (int i = 0; i < (GLONASS_GNAV_STRING_BITS); i++)
for (int32_t i = 0; i < (GLONASS_GNAV_STRING_BITS); i++)
{
if (bi_binary_code[2 * i] == '1' && bi_binary_code[2 * i + 1] == '0')
{
@ -170,7 +170,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
}
// Convert from relative code to data bits
data_bits.push_back('0');
for (int i = 1; i < (GLONASS_GNAV_STRING_BITS); i++)
for (int32_t i = 1; i < (GLONASS_GNAV_STRING_BITS); i++)
{
data_bits.push_back(((relative_code[i - 1] - '0') ^ (relative_code[i] - '0')) + '0');
}
@ -207,7 +207,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
}
if (d_nav.have_new_almanac() == true)
{
unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number;
uint32_t slot_nbr = d_nav.i_alm_satellite_slot_number;
std::shared_ptr<Glonass_Gnav_Almanac> tmp_obj = std::make_shared<Glonass_Gnav_Almanac>(d_nav.get_almanac(slot_nbr));
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
LOG(INFO) << "GLONASS GNAV Almanac have been received in channel" << d_channel << " in slot number " << slot_nbr;
@ -232,7 +232,7 @@ void glonass_l1_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &sat
}
void glonass_l1_ca_telemetry_decoder_cc::set_channel(int channel)
void glonass_l1_ca_telemetry_decoder_cc::set_channel(int32_t channel)
{
d_channel = channel;
LOG(INFO) << "Navigation channel set to " << channel;
@ -262,8 +262,8 @@ void glonass_l1_ca_telemetry_decoder_cc::set_channel(int channel)
int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
int corr_value = 0;
int preamble_diff = 0;
int32_t corr_value = 0;
int32_t preamble_diff = 0;
Gnss_Synchro **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
const Gnss_Synchro **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
@ -276,12 +276,12 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu
consume_each(1);
d_flag_preamble = false;
unsigned int required_symbols = GLONASS_GNAV_STRING_SYMBOLS;
uint32_t required_symbols = GLONASS_GNAV_STRING_SYMBOLS;
if (d_symbol_history.size() > required_symbols)
{
// ******* preamble correlation ********
for (int i = 0; i < d_symbols_per_preamble; i++)
for (int32_t i = 0; i < d_symbols_per_preamble; i++)
{
if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping
{
@ -312,9 +312,9 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu
if (abs(corr_value) >= d_symbols_per_preamble)
{
// check preamble separation
preamble_diff = d_sample_counter - d_preamble_index;
preamble_diff = static_cast<int32_t>(d_sample_counter - d_preamble_index);
// Record the PRN start sample index associated to the preamble
d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter;
d_preamble_time_samples = static_cast<double>(d_symbol_history.at(0).Tracking_sample_counter);
if (abs(preamble_diff - GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) == 0)
{
// try to decode frame
@ -335,15 +335,15 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu
else if (d_stat == 2)
{
// FIXME: The preamble index marks the first symbol of the string count. Here I just wait for another full string to be received before processing
if (d_sample_counter == d_preamble_index + GLONASS_GNAV_STRING_SYMBOLS)
if (d_sample_counter == d_preamble_index + static_cast<uint64_t>(GLONASS_GNAV_STRING_SYMBOLS))
{
// NEW GLONASS string received
// 0. fetch the symbols into an array
int string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble;
int32_t string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble;
double string_symbols[GLONASS_GNAV_DATA_SYMBOLS] = {0};
// ******* SYMBOL TO BIT *******
for (int i = 0; i < string_length; i++)
for (int32_t i = 0; i < string_length; i++)
{
if (corr_value > 0)
{
@ -415,7 +415,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu
current_symbol.PRN = this->d_satellite.get_PRN();
current_symbol.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0);
// todo: glonass time to gps time should be done in observables block
// current_symbol.TOW_at_current_symbol_ms -= -= static_cast<unsigned int>(delta_t) * 1000; // Galileo to GPS TOW
// current_symbol.TOW_at_current_symbol_ms -= -= static_cast<uint32_t>(delta_t) * 1000; // Galileo to GPS TOW
if (d_dump == true)
{

View File

@ -63,7 +63,7 @@ class glonass_l1_ca_telemetry_decoder_cc : public gr::block
public:
~glonass_l1_ca_telemetry_decoder_cc(); //!< Class destructor
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
void set_channel(int channel); //!< Set receiver's channel
void set_channel(int32_t channel); //!< Set receiver's channel
/*!
* \brief This is where all signal processing takes place
@ -76,30 +76,30 @@ private:
glonass_l1_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
glonass_l1_ca_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
void decode_string(double *symbols, int frame_length);
void decode_string(double *symbols, int32_t frame_length);
//!< Help with coherent tracking
double d_preamble_time_samples;
//!< Preamble decoding
unsigned short int d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS];
int *d_preambles_symbols;
unsigned int d_samples_per_symbol;
int d_symbols_per_preamble;
uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS];
int32_t *d_preambles_symbols;
uint32_t d_samples_per_symbol;
int32_t d_symbols_per_preamble;
//!< Storage for incoming data
std::deque<Gnss_Synchro> 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
unsigned int d_stat; //!< Status of decoder
bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved
bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check)
bool d_flag_preamble; //!< Flag indicating when preamble was found
int d_CRC_error_counter; //!< Number of failed CRC operations
bool flag_TOW_set; //!< Indicates when time of week is set
double delta_t; //!< GPS-GLONASS time offset
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_parity; //!< Flag indicating when parity check was achieved (crc check)
bool d_flag_preamble; //!< Flag indicating when preamble was found
int32_t d_CRC_error_counter; //!< Number of failed CRC operations
bool flag_TOW_set; //!< Indicates when time of week is set
double delta_t; //!< GPS-GLONASS time offset
//!< Navigation Message variable
Glonass_Gnav_Navigation_Message d_nav;
@ -110,7 +110,7 @@ private:
//!< Satellite Information and logging capacity
Gnss_Satellite d_satellite;
int d_channel;
int32_t d_channel;
bool d_dump;
std::string d_dump_filename;
std::ofstream d_dump_file;

View File

@ -65,18 +65,18 @@ glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc(
d_samples_per_symbol = (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS) / GLONASS_L2_CA_SYMBOL_RATE_BPS;
// Set the preamble information
unsigned short int preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE;
uint16_t preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE;
// Since preamble rate is different than navigation data rate we use a constant
d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS;
memcpy(static_cast<unsigned short int *>(this->d_preambles_bits), static_cast<unsigned short int *>(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int));
memcpy(static_cast<uint16_t *>(this->d_preambles_bits), static_cast<uint16_t *>(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(uint16_t));
// preamble bits to sampled symbols
d_preambles_symbols = static_cast<signed int *>(malloc(sizeof(signed int) * d_symbols_per_preamble));
int n = 0;
for (int i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++)
d_preambles_symbols = static_cast<int32_t *>(malloc(sizeof(int32_t) * d_symbols_per_preamble));
int32_t n = 0;
for (int32_t i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++)
{
for (unsigned int j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++)
for (uint32_t j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++)
{
if (d_preambles_bits[i] == 1)
{
@ -89,9 +89,9 @@ glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc(
n++;
}
}
d_sample_counter = 0;
d_sample_counter = 0ULL;
d_stat = 0;
d_preamble_index = 0;
d_preamble_index = 0ULL;
d_flag_frame_sync = false;
@ -124,10 +124,10 @@ glonass_l2_ca_telemetry_decoder_cc::~glonass_l2_ca_telemetry_decoder_cc()
}
void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int frame_length)
void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int32_t frame_length)
{
double chip_acc = 0.0;
int chip_acc_counter = 0;
int32_t chip_acc_counter = 0;
// 1. Transform from symbols to bits
std::string bi_binary_code;
@ -135,7 +135,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
std::string data_bits;
// Group samples into bi-binary code
for (int i = 0; i < (frame_length); i++)
for (int32_t i = 0; i < (frame_length); i++)
{
chip_acc += frame_symbols[i];
chip_acc_counter += 1;
@ -157,7 +157,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
}
}
// Convert from bi-binary code to relative code
for (int i = 0; i < (GLONASS_GNAV_STRING_BITS); i++)
for (int32_t i = 0; i < (GLONASS_GNAV_STRING_BITS); i++)
{
if (bi_binary_code[2 * i] == '1' && bi_binary_code[2 * i + 1] == '0')
{
@ -170,7 +170,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
}
// Convert from relative code to data bits
data_bits.push_back('0');
for (int i = 1; i < (GLONASS_GNAV_STRING_BITS); i++)
for (int32_t i = 1; i < (GLONASS_GNAV_STRING_BITS); i++)
{
data_bits.push_back(((relative_code[i - 1] - '0') ^ (relative_code[i] - '0')) + '0');
}
@ -207,7 +207,7 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
}
if (d_nav.have_new_almanac() == true)
{
unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number;
uint32_t slot_nbr = d_nav.i_alm_satellite_slot_number;
std::shared_ptr<Glonass_Gnav_Almanac> tmp_obj = std::make_shared<Glonass_Gnav_Almanac>(d_nav.get_almanac(slot_nbr));
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
LOG(INFO) << "GLONASS GNAV Almanac have been received in channel" << d_channel << " in slot number " << slot_nbr;
@ -232,7 +232,7 @@ void glonass_l2_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &sat
}
void glonass_l2_ca_telemetry_decoder_cc::set_channel(int channel)
void glonass_l2_ca_telemetry_decoder_cc::set_channel(int32_t channel)
{
d_channel = channel;
LOG(INFO) << "Navigation channel set to " << channel;
@ -262,8 +262,8 @@ void glonass_l2_ca_telemetry_decoder_cc::set_channel(int channel)
int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
int corr_value = 0;
int preamble_diff = 0;
int32_t corr_value = 0;
int32_t preamble_diff = 0;
Gnss_Synchro **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
const Gnss_Synchro **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
@ -276,12 +276,12 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu
consume_each(1);
d_flag_preamble = false;
unsigned int required_symbols = GLONASS_GNAV_STRING_SYMBOLS;
uint32_t required_symbols = GLONASS_GNAV_STRING_SYMBOLS;
if (d_symbol_history.size() > required_symbols)
{
// ******* preamble correlation ********
for (int i = 0; i < d_symbols_per_preamble; i++)
for (int32_t i = 0; i < d_symbols_per_preamble; i++)
{
if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping
{
@ -312,9 +312,9 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu
if (abs(corr_value) >= d_symbols_per_preamble)
{
// check preamble separation
preamble_diff = d_sample_counter - d_preamble_index;
preamble_diff = static_cast<int32_t>(d_sample_counter - d_preamble_index);
// Record the PRN start sample index associated to the preamble
d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter;
d_preamble_time_samples = static_cast<double>(d_symbol_history.at(0).Tracking_sample_counter);
if (abs(preamble_diff - GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) == 0)
{
// try to decode frame
@ -335,15 +335,15 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu
else if (d_stat == 2)
{
// FIXME: The preamble index marks the first symbol of the string count. Here I just wait for another full string to be received before processing
if (d_sample_counter == d_preamble_index + GLONASS_GNAV_STRING_SYMBOLS)
if (d_sample_counter == d_preamble_index + static_cast<uint64_t>(GLONASS_GNAV_STRING_SYMBOLS))
{
// NEW GLONASS string received
// 0. fetch the symbols into an array
int string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble;
int32_t string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble;
double string_symbols[GLONASS_GNAV_DATA_SYMBOLS] = {0};
// ******* SYMBOL TO BIT *******
for (int i = 0; i < string_length; i++)
for (int32_t i = 0; i < string_length; i++)
{
if (corr_value > 0)
{
@ -415,7 +415,7 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu
current_symbol.PRN = this->d_satellite.get_PRN();
current_symbol.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0);
// todo: glonass time to gps time should be done in observables block
// current_symbol.TOW_at_current_symbol_ms -= static_cast<unsigned int>(delta_t) * 1000;
// current_symbol.TOW_at_current_symbol_ms -= static_cast<uint32_t>(delta_t) * 1000;
if (d_dump == true)
{

View File

@ -61,7 +61,7 @@ class glonass_l2_ca_telemetry_decoder_cc : public gr::block
public:
~glonass_l2_ca_telemetry_decoder_cc(); //!< Class destructor
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
void set_channel(int channel); //!< Set receiver's channel
void set_channel(int32_t channel); //!< Set receiver's channel
/*!
* \brief This is where all signal processing takes place
@ -74,30 +74,30 @@ private:
glonass_l2_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
glonass_l2_ca_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
void decode_string(double *symbols, int frame_length);
void decode_string(double *symbols, int32_t frame_length);
//!< Help with coherent tracking
double d_preamble_time_samples;
//!< Preamble decoding
unsigned short int d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS];
int *d_preambles_symbols;
unsigned int d_samples_per_symbol;
int d_symbols_per_preamble;
uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS];
int32_t *d_preambles_symbols;
uint32_t d_samples_per_symbol;
int32_t d_symbols_per_preamble;
//!< Storage for incoming data
std::deque<Gnss_Synchro> 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
unsigned int d_stat; //!< Status of decoder
bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved
bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check)
bool d_flag_preamble; //!< Flag indicating when preamble was found
int d_CRC_error_counter; //!< Number of failed CRC operations
bool flag_TOW_set; //!< Indicates when time of week is set
double delta_t; //!< GPS-GLONASS time offset
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_parity; //!< Flag indicating when parity check was achieved (crc check)
bool d_flag_preamble; //!< Flag indicating when preamble was found
int32_t d_CRC_error_counter; //!< Number of failed CRC operations
bool flag_TOW_set; //!< Indicates when time of week is set
double delta_t; //!< GPS-GLONASS time offset
//!< Navigation Message variable
Glonass_Gnav_Navigation_Message d_nav;
@ -108,7 +108,7 @@ private:
//!< Satellite Information and logging capacity
Gnss_Satellite d_satellite;
int d_channel;
int32_t d_channel;
bool d_dump;
std::string d_dump_filename;
std::ofstream d_dump_file;

View File

@ -62,14 +62,14 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
// set the preamble
unsigned short int preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE;
uint16_t preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE;
// preamble bits to sampled symbols
d_preambles_symbols = static_cast<int *>(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int), volk_gnsssdr_get_alignment()));
int n = 0;
for (int i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++)
d_preambles_symbols = static_cast<int32_t *>(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment()));
int32_t n = 0;
for (int32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++)
{
for (unsigned int j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++)
for (uint32_t j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++)
{
if (preambles_bits[i] == 1)
{
@ -91,7 +91,7 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(
d_flag_new_tow_available = false;
d_channel = 0;
flag_PLL_180_deg_phase_locked = false;
d_preamble_time_samples = 0;
d_preamble_time_samples = 0ULL;
d_TOW_at_current_symbol_ms = 0;
d_symbol_history.resize(GPS_CA_PREAMBLE_LENGTH_SYMBOLS); // Change fixed buffer size
d_symbol_history.clear(); // Clear all the elements in the buffer
@ -117,13 +117,13 @@ gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc()
}
bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword)
bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(uint32_t gpsword)
{
unsigned int d1, d2, d3, d4, d5, d6, d7, t, parity;
/* XOR as many bits in parallel as possible. The magic constants pick
up bits which are to be XOR'ed together to implement the GPS parity
check algorithm described in IS-GPS-200E. This avoids lengthy shift-
and-xor loops. */
uint32_t d1, d2, d3, d4, d5, d6, d7, t, parity;
// XOR as many bits in parallel as possible. The magic constants pick
// up bits which are to be XOR'ed together to implement the GPS parity
// check algorithm described in IS-GPS-200E. This avoids lengthy shift-
// and-xor loops.
d1 = gpsword & 0xFBFFBF00;
d2 = _rotl(gpsword, 1) & 0x07FFBF01;
d3 = _rotl(gpsword, 2) & 0xFC0F8100;
@ -152,7 +152,7 @@ void gps_l1_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satelli
}
void gps_l1_ca_telemetry_decoder_cc::set_channel(int channel)
void gps_l1_ca_telemetry_decoder_cc::set_channel(int32_t channel)
{
d_channel = channel;
d_nav.i_channel_ID = channel;
@ -185,28 +185,28 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe()
{
char subframe[GPS_SUBFRAME_LENGTH];
int symbol_accumulator_counter = 0;
int frame_bit_index = 0;
int word_index = 0;
int32_t symbol_accumulator_counter = 0;
int32_t frame_bit_index = 0;
int32_t word_index = 0;
uint32_t GPS_frame_4bytes = 0;
float symbol_accumulator = 0;
bool subframe_synchro_confirmation = false;
bool CRC_ok = true;
for (int n = 0; n < GPS_SUBFRAME_MS; n++)
for (int32_t n = 0; n < GPS_SUBFRAME_MS; n++)
{
//******* SYMBOL TO BIT *******
// ******* SYMBOL TO BIT *******
// extended correlation to bit period is enabled in tracking!
symbol_accumulator += d_subframe_symbols[n]; // accumulate the input value in d_symbol_accumulator
symbol_accumulator_counter++;
if (symbol_accumulator_counter == 20)
{
//symbol to bit
if (symbol_accumulator > 0) GPS_frame_4bytes += 1; //insert the telemetry bit in LSB
// symbol to bit
if (symbol_accumulator > 0) GPS_frame_4bytes += 1; // insert the telemetry bit in LSB
symbol_accumulator = 0;
symbol_accumulator_counter = 0;
//******* bits to words ******
// ******* bits to words ******
frame_bit_index++;
if (frame_bit_index == 30)
{
@ -224,8 +224,8 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe()
{
GPS_frame_4bytes = GPS_frame_4bytes | 0x80000000;
}
/* Check that the 2 most recently logged words pass parity. Have to first
invert the data bits according to bit 30 of the previous word. */
// Check that the 2 most recently logged words pass parity. Have to first
// invert the data bits according to bit 30 of the previous word.
if (GPS_frame_4bytes & 0x40000000)
{
GPS_frame_4bytes ^= 0x3FFFFFC0; // invert the data bits (using XOR)
@ -236,10 +236,10 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe()
}
else
{
//std::cout << "word invalid sat " << this->d_satellite << std::endl;
// std::cout << "word invalid sat " << this->d_satellite << std::endl;
CRC_ok = false;
}
//add word to subframe
// add word to subframe
// insert the word in the correct position of the subframe
std::memcpy(&subframe[word_index * GPS_WORD_LENGTH], &GPS_frame_4bytes, sizeof(uint32_t));
word_index++;
@ -248,17 +248,16 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe()
}
else
{
GPS_frame_4bytes <<= 1; //shift 1 bit left the telemetry word
GPS_frame_4bytes <<= 1; // shift 1 bit left the telemetry word
}
}
}
//decode subframe
// decode subframe
// NEW GPS SUBFRAME HAS ARRIVED!
if (CRC_ok)
{
int subframe_ID = d_nav.subframe_decoder(subframe); //decode the subframe
int32_t subframe_ID = d_nav.subframe_decoder(subframe); //d ecode the subframe
if (subframe_ID > 0 and subframe_ID < 6)
{
std::cout << "New GPS NAV message received in channel " << this->d_channel << ": "
@ -268,7 +267,7 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe()
switch (subframe_ID)
{
case 3: //we have a new set of ephemeris data for the current SV
case 3: // we have a new set of ephemeris data for the current SV
if (d_nav.satellite_validation() == true)
{
// get ephemeris object for this SV (mandatory)
@ -306,37 +305,37 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe()
return subframe_synchro_confirmation;
}
int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
int preamble_diff_ms = 0;
int32_t preamble_diff_ms = 0;
Gnss_Synchro **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
const Gnss_Synchro **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];
//record the oldest subframe symbol before inserting a new symbol into the circular buffer
// record the oldest subframe symbol before inserting a new symbol into the circular buffer
if (d_current_subframe_symbol < GPS_SUBFRAME_MS and d_symbol_history.size() > 0)
{
d_subframe_symbols[d_current_subframe_symbol] = d_symbol_history.at(0).Prompt_I;
d_current_subframe_symbol++;
}
d_symbol_history.push_back(current_symbol); //add new symbol to the symbol queue
d_symbol_history.push_back(current_symbol); // add new symbol to the symbol queue
consume_each(1);
d_flag_preamble = false;
//******* preamble correlation ********
int corr_value = 0;
// ******* 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))
{
// std::cout << "-------\n";
for (unsigned int i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++)
// std::cout << "-------\n";
for (uint32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++)
{
if (d_symbol_history.at(i).Flag_valid_symbol_output == true)
{
@ -352,19 +351,18 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
}
}
//******* frame sync ******************
// ******* frame sync ******************
if (std::abs(corr_value) == GPS_CA_PREAMBLE_LENGTH_SYMBOLS)
{
//TODO: Rewrite with state machine
if (d_stat == 0)
{
//record the preamble sample stamp
// record the preamble sample stamp
d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; // record the preamble sample stamp
DLOG(INFO) << "Preamble detection for SAT " << this->d_satellite << "d_symbol_history.at(0).Tracking_sample_counter=" << d_symbol_history.at(0).Tracking_sample_counter;
d_stat = 1; // enter into frame pre-detection status
}
else if (d_stat == 1) //check 6 seconds of preamble separation
else if (d_stat == 1) // check 6 seconds of preamble separation
{
preamble_diff_ms = std::round(((static_cast<double>(d_symbol_history.at(0).Tracking_sample_counter) - d_preamble_time_samples) / static_cast<double>(d_symbol_history.at(0).fs)) * 1000.0);
if (std::abs(preamble_diff_ms - GPS_SUBFRAME_MS) % GPS_SUBFRAME_MS == 0)
@ -388,14 +386,14 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
<< static_cast<double>(d_preamble_time_samples) / static_cast<double>(d_symbol_history.at(0).fs) << " [s]";
}
//try to decode the subframe:
// try to decode the subframe:
if (decode_subframe() == false)
{
d_crc_error_synchronization_counter++;
if (d_crc_error_synchronization_counter > 3)
{
DLOG(INFO) << "TOO MANY CRC ERRORS: Lost of frame sync SAT " << this->d_satellite << std::endl;
d_stat = 0; //lost of frame sync
d_stat = 0; // lost of frame sync
d_flag_frame_sync = false;
flag_TOW_set = false;
d_crc_error_synchronization_counter = 0;
@ -413,8 +411,8 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
if (preamble_diff_ms > GPS_SUBFRAME_MS)
{
DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff_ms;
// std::cout << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff_ms << std::endl;
d_stat = 0; //lost of frame sync
// std::cout << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff_ms << std::endl;
d_stat = 0; // lost of frame sync
d_flag_frame_sync = false;
flag_TOW_set = false;
d_current_subframe_symbol = 0;
@ -424,11 +422,11 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
}
}
//2. Add the telemetry decoder information
// 2. Add the telemetry decoder information
if (this->d_flag_preamble == true and d_flag_new_tow_available == true)
{
d_TOW_at_current_symbol_ms = static_cast<unsigned int>(d_nav.d_TOW * 1000.0) + GPS_CA_PREAMBLE_DURATION_MS;
d_TOW_at_Preamble_ms = static_cast<unsigned int>(d_nav.d_TOW * 1000.0);
d_TOW_at_current_symbol_ms = static_cast<uint32_t>(d_nav.d_TOW * 1000.0) + GPS_CA_PREAMBLE_DURATION_MS;
d_TOW_at_Preamble_ms = static_cast<uint32_t>(d_nav.d_TOW * 1000.0);
flag_TOW_set = true;
d_flag_new_tow_available = false;
}
@ -447,7 +445,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
if (flag_PLL_180_deg_phase_locked == true)
{
//correct the accumulated phase for the Costas loop phase shift, if required
// correct the accumulated phase for the Costas loop phase shift, if required
current_symbol.Carrier_phase_rads += GPS_PI;
}
@ -471,7 +469,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
}
}
//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;

View File

@ -70,23 +70,23 @@ private:
gps_l1_ca_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
bool gps_word_parityCheck(unsigned int gpsword);
bool gps_word_parityCheck(uint32_t gpsword);
bool decode_subframe();
bool new_decoder();
int d_crc_error_synchronization_counter;
int *d_preambles_symbols;
unsigned int d_stat;
uint32_t d_stat;
bool d_flag_frame_sync;
// symbols
boost::circular_buffer<Gnss_Synchro> d_symbol_history;
float d_subframe_symbols[GPS_SUBFRAME_MS]; //symbols per subframe
float d_subframe_symbols[GPS_SUBFRAME_MS]; // symbols per subframe
int d_current_subframe_symbol;
//bits and frame
unsigned int d_prev_GPS_frame_4bytes;
// bits and frame
uint32_t d_prev_GPS_frame_4bytes;
bool d_flag_preamble;
bool d_flag_new_tow_available;
@ -99,8 +99,8 @@ private:
uint64_t d_preamble_time_samples;
unsigned int d_TOW_at_Preamble_ms;
unsigned int d_TOW_at_current_symbol_ms;
uint32_t d_TOW_at_Preamble_ms;
uint32_t d_TOW_at_current_symbol_ms;
bool flag_TOW_set;
bool flag_PLL_180_deg_phase_locked;

View File

@ -61,7 +61,7 @@ gps_l2c_telemetry_decoder_cc::gps_l2c_telemetry_decoder_cc(
d_dump = dump;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
DLOG(INFO) << "GPS L2C M TELEMETRY PROCESSING: satellite " << d_satellite;
//set_output_multiple (1);
// set_output_multiple (1);
d_channel = 0;
d_flag_valid_word = false;
d_TOW_at_current_symbol = 0;
@ -69,7 +69,7 @@ gps_l2c_telemetry_decoder_cc::gps_l2c_telemetry_decoder_cc(
d_state = 0; //initial state
d_crc_error_count = 0;
//initialize the CNAV frame decoder (libswiftcnav)
// initialize the CNAV frame decoder (libswiftcnav)
cnav_msg_decoder_init(&d_cnav_decoder);
}
@ -134,34 +134,34 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
bool flag_new_cnav_frame = false;
cnav_msg_t msg;
u32 delay = 0;
uint32_t delay = 0;
//add the symbol to the decoder
u8 symbol_clip = static_cast<u8>(in[0].Prompt_I > 0) * 255;
// add the symbol to the decoder
uint8_t symbol_clip = static_cast<uint8_t>(in[0].Prompt_I > 0) * 255;
flag_new_cnav_frame = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay);
consume_each(1); //one by one
consume_each(1); // one by one
// UPDATE GNSS SYNCHRO DATA
Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block
Gnss_Synchro current_synchro_data; // structure to save the synchronization information and send the output object to the next block
//1. Copy the current tracking output
// 1. Copy the current tracking output
current_synchro_data = in[0];
//2. Add the telemetry decoder information
//check if new CNAV frame is available
// 2. Add the telemetry decoder information
// check if new CNAV frame is available
if (flag_new_cnav_frame == true)
{
std::bitset<GPS_L2_CNAV_DATA_PAGE_BITS> raw_bits;
//Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder
for (u32 i = 0; i < GPS_L2_CNAV_DATA_PAGE_BITS; i++)
// Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder
for (uint32_t i = 0; i < GPS_L2_CNAV_DATA_PAGE_BITS; i++)
{
raw_bits[GPS_L2_CNAV_DATA_PAGE_BITS - 1 - i] = ((msg.raw_msg[i / 8] >> (7 - i % 8)) & 1u);
}
d_CNAV_Message.decode_page(raw_bits);
//Push the new navigation data to the queues
// Push the new navigation data to the queues
if (d_CNAV_Message.have_new_ephemeris() == true)
{
// get ephemeris object for this SV
@ -183,12 +183,12 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
//update TOW at the preamble instant
// update TOW at the preamble instant
d_TOW_at_Preamble = static_cast<double>(msg.tow);
//* The time of the last input symbol can be computed from the message ToW and
//* delay by the formulae:
//* \code
//* symbolTime_ms = msg->tow * 6000 + *pdelay * 20 + (12 * 20); 12 symbols of the encoder's transitory
// The time of the last input symbol can be computed from the message ToW and
// delay by the formulae:
// \code
// symbolTime_ms = msg->tow * 6000 + *pdelay * 20 + (12 * 20); 12 symbols of the encoder's transitory
d_TOW_at_current_symbol = static_cast<double>(msg.tow) * 6.0 + static_cast<double>(delay) * GPS_L2_M_PERIOD + 12 * GPS_L2_M_PERIOD;
//d_TOW_at_current_symbol = floor(d_TOW_at_current_symbol * 1000.0) / 1000.0;
d_flag_valid_word = true;
@ -224,7 +224,7 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
}
}
//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_synchro_data;
return 1;
}

View File

@ -38,6 +38,7 @@
#include "gps_cnav_iono.h"
#include <gnuradio/block.h>
#include <algorithm> // for copy
#include <cstdint>
#include <deque>
#include <fstream>
#include <string>
@ -70,7 +71,7 @@ class gps_l2c_telemetry_decoder_cc : public gr::block
public:
~gps_l2c_telemetry_decoder_cc();
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
void set_channel(int channel); //!< Set receiver's channel
void set_channel(int32_t channel); //!< Set receiver's channel
/*!
* \brief This is where all signal processing takes place
@ -78,7 +79,6 @@ public:
int general_work(int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
private:
friend gps_l2c_telemetry_decoder_cc_sptr
gps_l2c_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
@ -86,15 +86,15 @@ private:
bool d_dump;
Gnss_Satellite d_satellite;
int d_channel;
int32_t d_channel;
std::string d_dump_filename;
std::ofstream d_dump_file;
cnav_msg_decoder_t d_cnav_decoder;
int d_state;
int d_crc_error_count;
int32_t d_state;
int32_t d_crc_error_count;
double d_TOW_at_current_symbol;
double d_TOW_at_Preamble;

View File

@ -66,9 +66,9 @@ gps_l5_telemetry_decoder_cc::gps_l5_telemetry_decoder_cc(
d_flag_valid_word = false;
d_TOW_at_current_symbol_ms = 0;
d_TOW_at_Preamble_ms = 0;
//initialize the CNAV frame decoder (libswiftcnav)
// initialize the CNAV frame decoder (libswiftcnav)
cnav_msg_decoder_init(&d_cnav_decoder);
for (int 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)
{
@ -108,7 +108,7 @@ void gps_l5_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite)
}
void gps_l5_telemetry_decoder_cc::set_channel(int channel)
void gps_l5_telemetry_decoder_cc::set_channel(int32_t channel)
{
d_channel = channel;
d_CNAV_Message.reset();
@ -146,17 +146,17 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u
// UPDATE GNSS SYNCHRO DATA
Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block
//1. Copy the current tracking output
// 1. Copy the current tracking output
current_synchro_data = in[0];
consume_each(1); //one by one
sym_hist.push_back(in[0].Prompt_I);
int corr_NH = 0;
int symbol_value = 0;
int32_t corr_NH = 0;
int32_t symbol_value = 0;
//Search correlation with Neuman-Hofman Code (see IS-GPS-705D)
// Search correlation with Neuman-Hofman Code (see IS-GPS-705D)
if (sym_hist.size() == GPS_L5i_NH_CODE_LENGTH)
{
for (int 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)
{
@ -191,29 +191,29 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u
bool flag_new_cnav_frame = false;
cnav_msg_t msg;
u32 delay = 0;
uint32_t delay = 0;
//add the symbol to the decoder
// add the symbol to the decoder
if (new_sym)
{
u8 symbol_clip = static_cast<u8>(symbol_value > 0) * 255;
uint8_t symbol_clip = static_cast<uint8_t>(symbol_value > 0) * 255;
flag_new_cnav_frame = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay);
new_sym = false;
}
//2. Add the telemetry decoder information
//check if new CNAV frame is available
// 2. Add the telemetry decoder information
// check if new CNAV frame is available
if (flag_new_cnav_frame == true)
{
std::bitset<GPS_L5_CNAV_DATA_PAGE_BITS> raw_bits;
//Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder
for (u32 i = 0; i < GPS_L5_CNAV_DATA_PAGE_BITS; i++)
// Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder
for (uint32_t i = 0; i < GPS_L5_CNAV_DATA_PAGE_BITS; i++)
{
raw_bits[GPS_L5_CNAV_DATA_PAGE_BITS - 1 - i] = ((msg.raw_msg[i / 8] >> (7 - i % 8)) & 1u);
}
d_CNAV_Message.decode_page(raw_bits);
//Push the new navigation data to the queues
// Push the new navigation data to the queues
if (d_CNAV_Message.have_new_ephemeris() == true)
{
// get ephemeris object for this SV
@ -235,14 +235,12 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
//update TOW at the preamble instant
// update TOW at the preamble instant
d_TOW_at_Preamble_ms = msg.tow * 6000;
//* The time of the last input symbol can be computed from the message ToW and
//* 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;
// The time of the last input symbol can be computed from the message ToW and
// 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_flag_valid_word = true;
}
@ -280,7 +278,7 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u
}
}
//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_synchro_data;
return 1;
}

View File

@ -35,13 +35,15 @@
#include "gps_cnav_navigation_message.h"
#include <gnuradio/block.h>
#include <algorithm>
#include <cstdint>
#include <deque>
#include <fstream>
#include <string>
#include <utility>
#include <vector>
extern "C" {
extern "C"
{
#include "cnav_msg.h"
#include "edc.h"
#include "bits.h"
@ -65,11 +67,10 @@ class gps_l5_telemetry_decoder_cc : public gr::block
public:
~gps_l5_telemetry_decoder_cc();
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
void set_channel(int channel); //!< Set receiver's channel
void set_channel(int32_t channel); //!< Set receiver's channel
int general_work(int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
private:
friend gps_l5_telemetry_decoder_cc_sptr
gps_l5_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
@ -77,15 +78,15 @@ private:
bool d_dump;
Gnss_Satellite d_satellite;
int d_channel;
int32_t d_channel;
std::string d_dump_filename;
std::ofstream d_dump_file;
cnav_msg_decoder_t d_cnav_decoder;
unsigned int d_TOW_at_current_symbol_ms;
unsigned int d_TOW_at_Preamble_ms;
uint32_t d_TOW_at_current_symbol_ms;
uint32_t d_TOW_at_Preamble_ms;
bool d_flag_valid_word;
Gps_CNAV_Navigation_Message d_CNAV_Message;

View File

@ -94,7 +94,7 @@ void sbas_l1_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite
}
void sbas_l1_telemetry_decoder_cc::set_channel(int channel)
void sbas_l1_telemetry_decoder_cc::set_channel(int32_t channel)
{
d_channel = channel;
LOG(INFO) << "SBAS channel set to " << channel;
@ -137,12 +137,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 (unsigned int 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 (int i = 0; i < d_n_smpls_in_history; i++)
for (int32_t i = 0; i < d_n_smpls_in_history; i++)
{
smpls[i] = static_cast<int>(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
@ -158,7 +158,7 @@ bool sbas_l1_telemetry_decoder_cc::sample_aligner::get_symbols(const std::vector
}
// sum the correct pair of samples to a symbol, depending on the current alignment d_align
sym = smpls[0 + int(d_aligned) * 2] + smpls[1];
sym = smpls[0 + int32_t(d_aligned) * 2] + smpls[1];
symbols.push_back(sym);
// sample alignment debug output
@ -189,8 +189,8 @@ sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::symbol_aligner_and_dec
{
// convolutional code properties
d_KK = 7;
int nn = 2;
int g_encoder[nn];
int32_t nn = 2;
int32_t g_encoder[nn];
g_encoder[0] = 121;
g_encoder[1] = 91;
@ -215,11 +215,11 @@ 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<int> &bits)
bool sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::get_bits(const std::vector<double> symbols, std::vector<int32_t> &bits)
{
const int traceback_depth = 5 * d_KK;
int nbits_requested = symbols.size() / d_symbols_per_bit;
int nbits_decoded;
const int32_t traceback_depth = 5 * d_KK;
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
std::vector<double> symbols_vd2; // shifted symbol vector -> add past sample in front of input vector
@ -229,13 +229,13 @@ bool sbas_l1_telemetry_decoder_cc::symbol_aligner_and_decoder::get_bits(const st
symbols_vd2.push_back(*symbol_it);
}
// arrays for decoded bits
int *bits_vd1 = new int[nbits_requested];
int *bits_vd2 = new int[nbits_requested];
int32_t *bits_vd1 = new int32_t[nbits_requested];
int32_t *bits_vd2 = new int32_t[nbits_requested];
// decode
float metric_vd1 = d_vd1->decode_continuous(symbols_vd1.data(), traceback_depth, bits_vd1, nbits_requested, nbits_decoded);
float metric_vd2 = d_vd2->decode_continuous(symbols_vd2.data(), traceback_depth, bits_vd2, nbits_requested, nbits_decoded);
// choose the bits with the better metric
for (int i = 0; i < nbits_decoded; i++)
for (int32_t i = 0; i < nbits_decoded; i++)
{
if (metric_vd1 > metric_vd2)
{ // symbols aligned
@ -260,35 +260,35 @@ void sbas_l1_telemetry_decoder_cc::frame_detector::reset()
}
void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const std::vector<int> bits, std::vector<std::pair<int, std::vector<int>>> &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;
unsigned int sbas_msg_length = 250;
std::vector<std::vector<int>> preambles = {{0, 1, 0, 1, 0, 0, 1, 1},
uint32_t sbas_msg_length = 250;
std::vector<std::vector<int32_t>> preambles = {{0, 1, 0, 1, 0, 0, 1, 1},
{1, 0, 0, 1, 1, 0, 1, 0},
{1, 1, 0, 0, 0, 1, 1, 0}};
VLOG(FLOW) << "get_frame_candidates(): "
<< "d_buffer.size()=" << d_buffer.size() << "\tbits.size()=" << bits.size();
ss << "copy bits ";
int count = 0;
int32_t count = 0;
// copy new bits into the working buffer
for (std::vector<int>::const_iterator bit_it = bits.cbegin(); bit_it < bits.cend(); ++bit_it)
for (std::vector<int32_t>::const_iterator bit_it = bits.cbegin(); bit_it < bits.cend(); ++bit_it)
{
d_buffer.push_back(*bit_it);
ss << *bit_it;
count++;
}
VLOG(SAMP_SYNC) << ss.str() << " into working buffer (" << count << " bits)";
int relative_preamble_start = 0;
int32_t relative_preamble_start = 0;
while (d_buffer.size() >= sbas_msg_length)
{
// compare with all preambles
for (std::vector<std::vector<int>>::iterator preample_it = preambles.begin(); preample_it < preambles.end(); ++preample_it)
for (std::vector<std::vector<int32_t>>::iterator preample_it = preambles.begin(); preample_it < preambles.end(); ++preample_it)
{
bool preamble_detected = true;
bool inv_preamble_detected = true;
// compare the buffer bits with the preamble bits
for (std::vector<int>::iterator preample_bit_it = preample_it->begin(); preample_bit_it < preample_it->end(); ++preample_bit_it)
for (std::vector<int32_t>::iterator preample_bit_it = preample_it->begin(); preample_bit_it < preample_it->end(); ++preample_bit_it)
{
preamble_detected = *preample_bit_it == d_buffer[preample_bit_it - preample_it->begin()] ? preamble_detected : false;
inv_preamble_detected = *preample_bit_it != d_buffer[preample_bit_it - preample_it->begin()] ? inv_preamble_detected : false;
@ -296,18 +296,18 @@ void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const st
if (preamble_detected || inv_preamble_detected)
{
// copy candidate
std::vector<int> candidate;
std::vector<int32_t> candidate;
std::copy(d_buffer.begin(), d_buffer.begin() + sbas_msg_length, std::back_inserter(candidate));
if (inv_preamble_detected)
{
// invert bits
for (std::vector<int>::iterator candidate_bit_it = candidate.begin(); candidate_bit_it != candidate.end(); candidate_bit_it++)
for (std::vector<int32_t>::iterator candidate_bit_it = candidate.begin(); candidate_bit_it != candidate.end(); candidate_bit_it++)
*candidate_bit_it = *candidate_bit_it == 0 ? 1 : 0;
}
msg_candidates.push_back(std::pair<int, std::vector<int>>(relative_preamble_start, candidate));
msg_candidates.push_back(std::pair<int32_t, std::vector<int32_t>>(relative_preamble_start, candidate));
ss.str("");
ss << "preamble " << preample_it - preambles.begin() << (inv_preamble_detected ? " inverted" : " normal") << " detected! candidate=";
for (std::vector<int>::iterator bit_it = candidate.begin(); bit_it < candidate.end(); ++bit_it)
for (std::vector<int32_t>::iterator bit_it = candidate.begin(); bit_it < candidate.end(); ++bit_it)
ss << *bit_it;
VLOG(EVENT) << ss.str();
}
@ -334,12 +334,12 @@ void sbas_l1_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vec
for (std::vector<msg_candiate_int_t>::const_iterator candidate_it = msg_candidates.cbegin(); candidate_it < msg_candidates.cend(); ++candidate_it)
{
// convert to bytes
std::vector<unsigned char> candidate_bytes;
std::vector<uint8_t> candidate_bytes;
zerropad_back_and_convert_to_bytes(candidate_it->second, candidate_bytes);
// verify CRC
d_checksum_agent.reset(0);
d_checksum_agent.process_bytes(candidate_bytes.data(), candidate_bytes.size());
unsigned int crc = d_checksum_agent.checksum();
uint32_t crc = d_checksum_agent.checksum();
VLOG(SAMP_SYNC) << "candidate " << candidate_it - msg_candidates.begin()
<< ": final crc remainder= " << std::hex << crc
<< std::setfill(' ') << std::resetiosflags(std::ios::hex);
@ -354,66 +354,66 @@ void sbas_l1_telemetry_decoder_cc::crc_verifier::get_valid_frames(const std::vec
ss << "Not a valid message.";
}
ss << " Relbitoffset=" << candidate_it->first << " content=";
for (std::vector<unsigned char>::iterator byte_it = candidate_bytes.begin(); byte_it < candidate_bytes.end(); ++byte_it)
for (std::vector<uint8_t>::iterator byte_it = candidate_bytes.begin(); byte_it < candidate_bytes.end(); ++byte_it)
{
ss << std::setw(2) << std::setfill('0') << std::hex << static_cast<unsigned int>((*byte_it));
ss << std::setw(2) << std::setfill('0') << std::hex << static_cast<uint32_t>((*byte_it));
}
VLOG(SAMP_SYNC) << ss.str() << std::setfill(' ') << std::resetiosflags(std::ios::hex) << std::endl;
}
}
void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_back_and_convert_to_bytes(const std::vector<int> msg_candidate, std::vector<unsigned char> &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;
unsigned char byte = 0;
uint8_t byte = 0;
VLOG(LMORE) << "zerropad_back_and_convert_to_bytes():" << byte;
for (std::vector<int>::const_iterator candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it)
{
int idx_bit = candidate_bit_it - msg_candidate.begin();
int bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte);
byte |= static_cast<unsigned char>(*candidate_bit_it) << bit_pos_in_current_byte;
int32_t idx_bit = candidate_bit_it - msg_candidate.begin();
int32_t bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte);
byte |= static_cast<uint8_t>(*candidate_bit_it) << bit_pos_in_current_byte;
ss << *candidate_bit_it;
if (idx_bit % bits_per_byte == bits_per_byte - 1)
{
bytes.push_back(byte);
VLOG(LMORE) << ss.str() << " -> byte=" << std::setw(2) << std::setfill('0') << std::hex << static_cast<unsigned int>(byte);
VLOG(LMORE) << ss.str() << " -> byte=" << std::setw(2) << std::setfill('0') << std::hex << static_cast<uint32_t>(byte);
ss.str("");
byte = 0;
}
}
bytes.push_back(byte); // implies: insert 6 zeros at the end to fit the 250bits into a multiple of bytes
VLOG(LMORE) << " -> byte=" << std::setw(2)
<< std::setfill('0') << std::hex << static_cast<unsigned int>(byte)
<< std::setfill('0') << std::hex << static_cast<uint32_t>(byte)
<< std::setfill(' ') << std::resetiosflags(std::ios::hex);
}
void sbas_l1_telemetry_decoder_cc::crc_verifier::zerropad_front_and_convert_to_bytes(const std::vector<int> msg_candidate, std::vector<unsigned char> &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;
unsigned char byte = 0;
int idx_bit = 6; // insert 6 zeros at the front to fit the 250bits into a multiple of bytes
uint8_t byte = 0;
int32_t idx_bit = 6; // insert 6 zeros at the front to fit the 250bits into a multiple of bytes
VLOG(LMORE) << "zerropad_front_and_convert_to_bytes():" << byte;
for (std::vector<int>::const_iterator candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it)
for (std::vector<int32_t>::const_iterator candidate_bit_it = msg_candidate.cbegin(); candidate_bit_it < msg_candidate.cend(); ++candidate_bit_it)
{
int bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte);
byte |= static_cast<unsigned char>(*candidate_bit_it) << bit_pos_in_current_byte;
int32_t bit_pos_in_current_byte = (bits_per_byte - 1) - (idx_bit % bits_per_byte);
byte |= static_cast<uint8_t>(*candidate_bit_it) << bit_pos_in_current_byte;
ss << *candidate_bit_it;
if (idx_bit % bits_per_byte == bits_per_byte - 1)
{
bytes.push_back(byte);
VLOG(LMORE) << ss.str() << " -> byte=" << std::setw(2)
<< std::setfill('0') << std::hex << static_cast<unsigned int>(byte);
<< std::setfill('0') << std::hex << static_cast<uint32_t>(byte);
ss.str("");
byte = 0;
}
idx_bit++;
}
VLOG(LMORE) << " -> byte=" << std::setw(2)
<< std::setfill('0') << std::hex << static_cast<unsigned int>(byte)
<< std::setfill('0') << std::hex << static_cast<uint32_t>(byte)
<< std::setfill(' ') << std::resetiosflags(std::ios::hex);
}
@ -427,8 +427,8 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
Gnss_Synchro *out = reinterpret_cast<Gnss_Synchro *>(output_items[0]); // Get the output buffer pointer
const Gnss_Synchro *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];
// copy correlation samples into samples vector
d_sample_buf.push_back(current_symbol.Prompt_I); //add new symbol to the symbol queue
@ -446,7 +446,7 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
// align symbols in pairs
// and obtain the bits by decoding the symbol pairs
std::vector<int> bits;
std::vector<int32_t> bits;
bool symbol_alignment = d_symbol_aligner_and_decoder.get_bits(symbols, bits);
// search for preambles
@ -465,7 +465,7 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
for (std::vector<msg_candiate_char_t>::const_iterator it = valid_msgs.cbegin();
it != valid_msgs.cend(); ++it)
{
int message_sample_offset =
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 * it->first;
double message_sample_stamp = sample_stamp + static_cast<double>(message_sample_offset) / 1000.0;
VLOG(EVENT) << "message_sample_stamp=" << message_sample_stamp

View File

@ -36,6 +36,7 @@
#include <boost/crc.hpp>
#include <gnuradio/block.h>
#include <algorithm> // for copy
#include <cstdint>
#include <deque>
#include <fstream>
#include <string>
@ -59,7 +60,7 @@ class sbas_l1_telemetry_decoder_cc : public gr::block
public:
~sbas_l1_telemetry_decoder_cc();
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
void set_channel(int channel); //!< Set receiver's channel
void set_channel(int32_t channel); //!< Set receiver's channel
/*!
* \brief This is where all signal processing takes place
@ -72,16 +73,16 @@ private:
sbas_l1_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
sbas_l1_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump);
void viterbi_decoder(double *page_part_symbols, int *page_part_bits);
void viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits);
void align_samples();
static const int d_samples_per_symbol = 2;
static const int d_symbols_per_bit = 2;
static const int 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;
int d_channel;
int32_t d_channel;
std::string d_dump_filename;
std::ofstream d_dump_file;
@ -89,8 +90,8 @@ private:
size_t d_block_size; //!< number of samples which are processed during one invocation of the algorithms
std::vector<double> d_sample_buf; //!< input buffer holding the samples to be processed in one block
typedef std::pair<int, std::vector<int>> msg_candiate_int_t;
typedef std::pair<int, std::vector<unsigned char>> msg_candiate_char_t;
typedef std::pair<int32_t, std::vector<int32_t>> msg_candiate_int_t;
typedef std::pair<int32_t, std::vector<uint8_t>> msg_candiate_char_t;
// helper class for sample alignment
class sample_aligner
@ -106,7 +107,7 @@ private:
bool get_symbols(const std::vector<double> samples, std::vector<double> &symbols);
private:
int d_n_smpls_in_history;
int32_t d_n_smpls_in_history;
double d_iir_par;
double d_corr_paired;
double d_corr_shifted;
@ -121,10 +122,10 @@ private:
symbol_aligner_and_decoder();
~symbol_aligner_and_decoder();
void reset();
bool get_bits(const std::vector<double> symbols, std::vector<int> &bits);
bool get_bits(const std::vector<double> symbols, std::vector<int32_t> &bits);
private:
int d_KK;
int32_t d_KK;
Viterbi_Decoder *d_vd1;
Viterbi_Decoder *d_vd2;
double d_past_symbol;
@ -136,10 +137,10 @@ private:
{
public:
void reset();
void get_frame_candidates(const std::vector<int> bits, std::vector<std::pair<int, std::vector<int>>> &msg_candidates);
void get_frame_candidates(const std::vector<int32_t> bits, std::vector<std::pair<int32_t, std::vector<int32_t>>> &msg_candidates);
private:
std::deque<int> d_buffer;
std::deque<int32_t> d_buffer;
} d_frame_detector;
@ -153,8 +154,8 @@ private:
private:
typedef boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> crc_24_q_type;
crc_24_q_type d_checksum_agent;
void zerropad_front_and_convert_to_bytes(const std::vector<int> msg_candidate, std::vector<unsigned char> &bytes);
void zerropad_back_and_convert_to_bytes(const std::vector<int> msg_candidate, std::vector<unsigned char> &bytes);
void zerropad_front_and_convert_to_bytes(const std::vector<int32_t> msg_candidate, std::vector<uint8_t> &bytes);
void zerropad_back_and_convert_to_bytes(const std::vector<int32_t> msg_candidate, std::vector<uint8_t> &bytes);
} d_crc_verifier;
};