Fixed rtl_tcp signal source deadlock

This commit is contained in:
zosoworld 2018-05-04 19:04:09 +02:00
parent 8b390d0924
commit 62198abdf4
3 changed files with 31 additions and 33 deletions

View File

@ -154,7 +154,9 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
rtl_tcp_signal_source_c::~rtl_tcp_signal_source_c()
{
boost::mutex::scoped_lock lock(mutex_);
io_service_.stop();
not_empty_.notify_one();
}

View File

@ -81,7 +81,6 @@ void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int fra
{
double page_symbols_deint[frame_length];
// 1. De-interleave
deinterleaver(GALILEO_FNAV_INTERLEAVER_ROWS, GALILEO_FNAV_INTERLEAVER_COLS, page_symbols, page_symbols_deint);
// 2. Viterbi decoder
@ -116,7 +115,6 @@ void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int fra
if (d_nav.flag_CRC_test == true)
{
LOG(INFO) << "Galileo E5a CRC correct in channel " << d_channel << " from satellite " << d_satellite;
//std::cout << "Galileo E5a CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl;
}
else
{
@ -191,19 +189,19 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc(
delta_t = 0.0;
d_symbol_counter = 0;
d_prompt_acum = 0.0;
flag_bit_start = false;
flag_bit_start = true;
new_symbol = false;
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
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 */
// create appropriate transition matrices
nsc_transit(out0, state0, 0, g_encoder, KK, nn);
nsc_transit(out1, state1, 1, g_encoder, KK, nn);
}
@ -241,7 +239,7 @@ void galileo_e5a_telemetry_decoder_cc::set_channel(int channel)
{
d_channel = channel;
LOG(INFO) << "Navigation channel set to " << channel;
// ############# ENABLE DATA FILE LOG #################
// Enable data file logging
if (d_dump == true)
{
if (d_dump_file.is_open() == false)
@ -272,7 +270,7 @@ int galileo_e5a_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
//1. Copy the current tracking output
// 1. Copy the current tracking output
Gnss_Synchro current_sample = in[0];
d_symbol_counter++;
if (flag_bit_start)
@ -281,7 +279,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
if (d_symbol_counter == GALILEO_FNAV_CODES_PER_SYMBOL)
{
current_sample.Prompt_I = d_prompt_acum / static_cast<double>(GALILEO_FNAV_CODES_PER_SYMBOL);
d_symbol_history.push_back(current_sample); //add new symbol to the symbol queue
d_symbol_history.push_back(current_sample); // add new symbol to the symbol queue
d_prompt_acum = 0.0;
d_symbol_counter = 0;
new_symbol = true;
@ -323,14 +321,14 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
}
}
}
d_sample_counter++; //count for the processed samples
d_sample_counter++; // count for the processed samples
consume_each(1);
d_flag_preamble = false;
if ((d_symbol_history.size() > required_symbols) && new_symbol)
{
//******* preamble correlation ********
// ****************** Preamble orrelation ******************
corr_value = 0;
for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
{
@ -344,13 +342,12 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
}
}
}
//******* frame sync ******************
if ((d_stat == 0) && new_symbol) //no preamble information
// ****************** Frame sync ******************
if ((d_stat == 0) && new_symbol) // no preamble information
{
if (abs(corr_value) >= GALILEO_FNAV_PREAMBLE_LENGTH_BITS)
{
d_preamble_index = d_sample_counter; //record the preamble sample stamp
d_preamble_index = d_sample_counter; // record the preamble sample stamp
LOG(INFO) << "Preamble detection for Galileo E5a satellite " << d_satellite;
d_stat = 1; // enter into frame pre-detection status
}
@ -359,13 +356,13 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
{
if (abs(corr_value) >= GALILEO_FNAV_PREAMBLE_LENGTH_BITS)
{
//check preamble separation
// check preamble separation
preamble_diff = d_sample_counter - d_preamble_index;
if (preamble_diff == GALILEO_FNAV_CODES_PER_PAGE)
{
//try to decode frame
// try to decode frame
LOG(INFO) << "Starting page decoder for Galileo E5a satellite " << d_satellite;
d_preamble_index = d_sample_counter; //record the preamble sample stamp
d_preamble_index = d_sample_counter; // record the preamble sample stamp
d_stat = 2;
}
else if (preamble_diff > GALILEO_FNAV_CODES_PER_PAGE)
@ -397,13 +394,13 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
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!
}
//call the decoder
// call the decoder
decode_word(page_symbols, frame_length);
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;
@ -414,7 +411,7 @@ int galileo_e5a_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 > GALILEO_E5A_CRC_ERROR_LIMIT)
{
LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite;
@ -428,10 +425,10 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
new_symbol = false;
// UPDATE GNSS SYNCHRO DATA
//Add the telemetry decoder information
// Add the telemetry decoder information
if (d_flag_preamble and d_nav.flag_TOW_set)
//update TOW at the preamble instant
//We expect a preamble each 10 seconds (FNAV page period)
// update TOW at the preamble instant
// We expect a preamble each 10 seconds (FNAV page period)
{
if (d_nav.flag_TOW_1 == true)
{
@ -458,7 +455,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
d_TOW_at_current_symbol += GALILEO_E5a_CODE_PERIOD;
}
}
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 += GALILEO_E5a_CODE_PERIOD;
}
@ -499,7 +496,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute
{
d_symbol_history.pop_front();
}
//3. Make the output
// 3. Make the output
if (current_sample.Flag_valid_word)
{
out[0] = current_sample;

View File

@ -144,21 +144,20 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
d_correlation_length_ms = 1;
d_code_samples_per_chip = 1;
d_code_length_chips = static_cast<unsigned int>(GPS_L5i_CODE_LENGTH_CHIPS);
// GPS L5 does not have pilot secondary code
d_secondary = true;
interchange_iq = false;
if (trk_parameters.track_pilot)
{
d_secondary_code_length = static_cast<unsigned int>(GPS_L5q_NH_CODE_LENGTH);
d_secondary_code_string = const_cast<std::string *>(&GPS_L5q_NH_CODE_STR);
signal_pretty_name = signal_pretty_name + "Q";
//interchange_iq = true;
interchange_iq = true;
}
else
{
d_secondary_code_length = static_cast<unsigned int>(GPS_L5i_NH_CODE_LENGTH);
d_secondary_code_string = const_cast<std::string *>(&GPS_L5i_NH_CODE_STR);
signal_pretty_name = signal_pretty_name + "I";
interchange_iq = false;
}
}
else
@ -212,18 +211,18 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
d_code_samples_per_chip = 1;
d_code_length_chips = static_cast<unsigned int>(Galileo_E5a_CODE_LENGTH_CHIPS);
d_secondary = true;
interchange_iq = false;
if (trk_parameters.track_pilot)
{
d_secondary_code_length = static_cast<unsigned int>(Galileo_E5a_Q_SECONDARY_CODE_LENGTH);
signal_pretty_name = signal_pretty_name + "Q";
// interchange_iq = true;
interchange_iq = true;
}
else
{
d_secondary_code_length = static_cast<unsigned int>(Galileo_E5a_I_SECONDARY_CODE_LENGTH);
d_secondary_code_string = const_cast<std::string *>(&Galileo_E5a_I_SECONDARY_CODE);
signal_pretty_name = signal_pretty_name + "I";
interchange_iq = false;
}
}
else