1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-08-03 20:33:49 +00:00

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

This commit is contained in:
Carles Fernandez 2018-04-23 08:07:11 +02:00
commit 8298160630
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
15 changed files with 328 additions and 129 deletions

View File

@ -37,10 +37,15 @@ include_directories(
${GFlags_INCLUDE_DIRS} ${GFlags_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS} ${GNURADIO_RUNTIME_INCLUDE_DIRS}
${VOLK_GNSSSDR_INCLUDE_DIRS}
) )
file(GLOB TELEMETRY_DECODER_GR_BLOCKS_HEADERS "*.h") file(GLOB TELEMETRY_DECODER_GR_BLOCKS_HEADERS "*.h")
list(SORT TELEMETRY_DECODER_GR_BLOCKS_HEADERS) list(SORT TELEMETRY_DECODER_GR_BLOCKS_HEADERS)
add_library(telemetry_decoder_gr_blocks ${TELEMETRY_DECODER_GR_BLOCKS_SOURCES} ${TELEMETRY_DECODER_GR_BLOCKS_HEADERS}) add_library(telemetry_decoder_gr_blocks ${TELEMETRY_DECODER_GR_BLOCKS_SOURCES} ${TELEMETRY_DECODER_GR_BLOCKS_HEADERS})
source_group(Headers FILES ${TELEMETRY_DECODER_GR_BLOCKS_HEADERS}) source_group(Headers FILES ${TELEMETRY_DECODER_GR_BLOCKS_HEADERS})
target_link_libraries(telemetry_decoder_gr_blocks telemetry_decoder_libswiftcnav telemetry_decoder_lib gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES}) target_link_libraries(telemetry_decoder_gr_blocks telemetry_decoder_libswiftcnav telemetry_decoder_lib gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES})
if(NOT VOLK_GNSSSDR_FOUND)
add_dependencies(telemetry_decoder_gr_blocks volk_gnsssdr_module)
endif(NOT VOLK_GNSSSDR_FOUND)

View File

@ -37,6 +37,7 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <glog/logging.h> #include <glog/logging.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <iostream> #include <iostream>
@ -54,38 +55,8 @@ 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, int *page_part_bits)
{ {
int CodeLength = 240;
int DataLength;
int nn, KK, mm, max_states;
int g_encoder[2];
nn = 2; // Coding rate 1/n
KK = 7; // Constraint Length
g_encoder[0] = 121; // Polynomial G1
g_encoder[1] = 91; // Polynomial G2
mm = KK - 1;
max_states = 1 << mm; /* 2^mm */
DataLength = (CodeLength / nn) - mm;
/* create appropriate transition matrices */
int *out0, *out1, *state0, *state1;
out0 = static_cast<int *>(calloc(max_states, sizeof(int)));
out1 = static_cast<int *>(calloc(max_states, sizeof(int)));
state0 = static_cast<int *>(calloc(max_states, sizeof(int)));
state1 = static_cast<int *>(calloc(max_states, sizeof(int)));
nsc_transit(out0, state0, 0, g_encoder, KK, nn);
nsc_transit(out1, state1, 1, g_encoder, KK, nn);
Viterbi(page_part_bits, out0, state0, out1, state1, Viterbi(page_part_bits, out0, state0, out1, state1,
page_part_symbols, KK, nn, DataLength); page_part_symbols, KK, nn, DataLength);
/* Clean up memory */
free(out0);
free(out1);
free(state0);
free(state1);
} }
@ -122,7 +93,7 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc(
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<unsigned short int *>(this->d_preambles_bits), static_cast<unsigned short int *>(preambles_bits), GALILEO_INAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int));
// preamble bits to sampled symbols // preamble bits to sampled symbols
d_preambles_symbols = static_cast<signed int *>(malloc(sizeof(signed int) * d_symbols_per_preamble)); d_preambles_symbols = static_cast<int *>(volk_gnsssdr_malloc(d_symbols_per_preamble * sizeof(int), volk_gnsssdr_get_alignment()));
int n = 0; int n = 0;
for (int i = 0; i < GALILEO_INAV_PREAMBLE_LENGTH_BITS; i++) for (int i = 0; i < GALILEO_INAV_PREAMBLE_LENGTH_BITS; i++)
{ {
@ -153,12 +124,28 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc(
d_flag_preamble = false; d_flag_preamble = false;
d_channel = 0; d_channel = 0;
flag_TOW_set = false; 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 */
nsc_transit(out0, state0, 0, g_encoder, KK, nn);
nsc_transit(out1, state1, 1, g_encoder, KK, nn);
} }
galileo_e1b_telemetry_decoder_cc::~galileo_e1b_telemetry_decoder_cc() galileo_e1b_telemetry_decoder_cc::~galileo_e1b_telemetry_decoder_cc()
{ {
delete d_preambles_symbols; volk_gnsssdr_free(d_preambles_symbols);
volk_gnsssdr_free(out0);
volk_gnsssdr_free(out1);
volk_gnsssdr_free(state0);
volk_gnsssdr_free(state1);
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
try try
@ -213,13 +200,13 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in
d_nav.split_page(page_String, flag_even_word_arrived); d_nav.split_page(page_String, flag_even_word_arrived);
if (d_nav.flag_CRC_test == true) if (d_nav.flag_CRC_test == true)
{ {
LOG(INFO) << "Galileo E1 CRC correct on channel " << d_channel << " from satellite " << d_satellite; LOG(INFO) << "Galileo E1 CRC correct in channel " << d_channel << " from satellite " << d_satellite;
//std::cout << "Galileo E1 CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl; //std::cout << "Galileo E1 CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl;
} }
else else
{ {
std::cout << "Galileo E1 CRC error on channel " << d_channel << " from satellite " << d_satellite << std::endl; std::cout << "Galileo E1 CRC error in channel " << d_channel << " from satellite " << d_satellite << std::endl;
LOG(INFO) << "Galileo E1 CRC error on channel " << d_channel << " from satellite " << d_satellite; LOG(INFO) << "Galileo E1 CRC error in channel " << d_channel << " from satellite " << d_satellite;
} }
flag_even_word_arrived = 0; flag_even_word_arrived = 0;
} }
@ -235,21 +222,21 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in
{ {
// get object for this SV (mandatory) // get object for this SV (mandatory)
std::shared_ptr<Galileo_Ephemeris> tmp_obj = std::make_shared<Galileo_Ephemeris>(d_nav.get_ephemeris()); std::shared_ptr<Galileo_Ephemeris> tmp_obj = std::make_shared<Galileo_Ephemeris>(d_nav.get_ephemeris());
std::cout << "New Galileo E1 I/NAV message received: ephemeris from satellite " << d_satellite << std::endl; std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }
if (d_nav.have_new_iono_and_GST() == true) if (d_nav.have_new_iono_and_GST() == true)
{ {
// get object for this SV (mandatory) // get object for this SV (mandatory)
std::shared_ptr<Galileo_Iono> tmp_obj = std::make_shared<Galileo_Iono>(d_nav.get_iono()); std::shared_ptr<Galileo_Iono> tmp_obj = std::make_shared<Galileo_Iono>(d_nav.get_iono());
std::cout << "New Galileo E1 I/NAV message received: iono/GST model parameters from satellite " << d_satellite << std::endl; std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }
if (d_nav.have_new_utc_model() == true) if (d_nav.have_new_utc_model() == true)
{ {
// get object for this SV (mandatory) // get object for this SV (mandatory)
std::shared_ptr<Galileo_Utc_Model> tmp_obj = std::make_shared<Galileo_Utc_Model>(d_nav.get_utc_model()); std::shared_ptr<Galileo_Utc_Model> tmp_obj = std::make_shared<Galileo_Utc_Model>(d_nav.get_utc_model());
std::cout << "New Galileo E1 I/NAV message received: UTC model parameters from satellite " << d_satellite << std::endl; std::cout << "New Galileo E1 I/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }
if (d_nav.have_new_almanac() == true) if (d_nav.have_new_almanac() == true)
@ -257,7 +244,7 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in
std::shared_ptr<Galileo_Almanac> tmp_obj = std::make_shared<Galileo_Almanac>(d_nav.get_almanac()); std::shared_ptr<Galileo_Almanac> tmp_obj = std::make_shared<Galileo_Almanac>(d_nav.get_almanac());
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
//debug //debug
std::cout << "Galileo E1 I/NAV almanac received!" << std::endl; std::cout << "Galileo E1 I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << std::endl;
DLOG(INFO) << "GPS_to_Galileo time conversion:"; DLOG(INFO) << "GPS_to_Galileo time conversion:";
DLOG(INFO) << "A0G=" << tmp_obj->A_0G_10; DLOG(INFO) << "A0G=" << tmp_obj->A_0G_10;
DLOG(INFO) << "A1G=" << tmp_obj->A_1G_10; DLOG(INFO) << "A1G=" << tmp_obj->A_1G_10;

View File

@ -112,6 +112,15 @@ private:
std::string d_dump_filename; std::string d_dump_filename;
std::ofstream d_dump_file; 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;
}; };
#endif #endif

View File

@ -37,9 +37,11 @@
#include "galileo_e5a_telemetry_decoder_cc.h" #include "galileo_e5a_telemetry_decoder_cc.h"
#include "control_message_factory.h" #include "control_message_factory.h"
#include "convolutional.h" #include "convolutional.h"
#include "display.h"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <glog/logging.h> #include <glog/logging.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
@ -58,42 +60,8 @@ 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, int *page_part_bits)
{ {
// int CodeLength = 240;
int CodeLength = 488;
int DataLength;
int nn, KK, mm, max_states;
int g_encoder[2];
nn = 2; // Coding rate 1/n
KK = 7; // Constraint Length
g_encoder[0] = 121; // Polynomial G1
g_encoder[1] = 91; // Polynomial G2
// g_encoder[0] = 171; // Polynomial G1
// g_encoder[1] = 133; // Polynomial G2
mm = KK - 1;
max_states = 1 << mm; // 2^mm
DataLength = (CodeLength / nn) - mm;
//create appropriate transition matrices
int *out0, *out1, *state0, *state1;
out0 = static_cast<int *>(calloc(max_states, sizeof(int)));
out1 = static_cast<int *>(calloc(max_states, sizeof(int)));
state0 = static_cast<int *>(calloc(max_states, sizeof(int)));
state1 = static_cast<int *>(calloc(max_states, sizeof(int)));
nsc_transit(out0, state0, 0, g_encoder, KK, nn);
nsc_transit(out1, state1, 1, g_encoder, KK, nn);
Viterbi(page_part_bits, out0, state0, out1, state1, Viterbi(page_part_bits, out0, state0, out1, state1,
page_part_symbols, KK, nn, DataLength); page_part_symbols, KK, nn, DataLength);
//Clean up memory
free(out0);
free(out1);
free(state0);
free(state1);
} }
@ -147,32 +115,32 @@ void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int fra
d_nav.split_page(page_String); d_nav.split_page(page_String);
if (d_nav.flag_CRC_test == true) if (d_nav.flag_CRC_test == true)
{ {
LOG(INFO) << "Galileo E5a CRC correct on channel " << d_channel << " from satellite " << d_satellite; 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; //std::cout << "Galileo E5a CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl;
} }
else else
{ {
std::cout << "Galileo E5a CRC error on channel " << d_channel << " from satellite " << d_satellite << std::endl; std::cout << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite << std::endl;
LOG(INFO) << "Galileo E5a CRC error on channel " << d_channel << " from satellite " << d_satellite; LOG(INFO) << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite;
} }
// 4. Push the new navigation data to the queues // 4. Push the new navigation data to the queues
if (d_nav.have_new_ephemeris() == true) if (d_nav.have_new_ephemeris() == true)
{ {
std::shared_ptr<Galileo_Ephemeris> tmp_obj = std::make_shared<Galileo_Ephemeris>(d_nav.get_ephemeris()); std::shared_ptr<Galileo_Ephemeris> tmp_obj = std::make_shared<Galileo_Ephemeris>(d_nav.get_ephemeris());
std::cout << "New Galileo E5a F/NAV message received: ephemeris from satellite " << d_satellite << std::endl; std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }
if (d_nav.have_new_iono_and_GST() == true) if (d_nav.have_new_iono_and_GST() == true)
{ {
std::shared_ptr<Galileo_Iono> tmp_obj = std::make_shared<Galileo_Iono>(d_nav.get_iono()); std::shared_ptr<Galileo_Iono> tmp_obj = std::make_shared<Galileo_Iono>(d_nav.get_iono());
std::cout << "New Galileo E5a F/NAV message received: iono/GST model parameters from satellite " << d_satellite << std::endl; std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << TEXT_RESET << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }
if (d_nav.have_new_utc_model() == true) if (d_nav.have_new_utc_model() == true)
{ {
std::shared_ptr<Galileo_Utc_Model> tmp_obj = std::make_shared<Galileo_Utc_Model>(d_nav.get_utc_model()); std::shared_ptr<Galileo_Utc_Model> tmp_obj = std::make_shared<Galileo_Utc_Model>(d_nav.get_utc_model());
std::cout << "New Galileo E5a F/NAV message received: UTC model parameters from satellite " << d_satellite << std::endl; std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }
} }
@ -226,11 +194,27 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc(
flag_bit_start = false; flag_bit_start = false;
new_symbol = false; new_symbol = false;
required_symbols = GALILEO_FNAV_SYMBOLS_PER_PAGE + GALILEO_FNAV_PREAMBLE_LENGTH_BITS; 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()));
/* create appropriate transition matrices */
nsc_transit(out0, state0, 0, g_encoder, KK, nn);
nsc_transit(out1, state1, 1, g_encoder, KK, nn);
} }
galileo_e5a_telemetry_decoder_cc::~galileo_e5a_telemetry_decoder_cc() galileo_e5a_telemetry_decoder_cc::~galileo_e5a_telemetry_decoder_cc()
{ {
volk_gnsssdr_free(out0);
volk_gnsssdr_free(out1);
volk_gnsssdr_free(state0);
volk_gnsssdr_free(state1);
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
try try

View File

@ -112,6 +112,15 @@ private:
Gnss_Satellite d_satellite; Gnss_Satellite d_satellite;
// navigation message vars // navigation message vars
Galileo_Fnav_Message d_nav; 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;
}; };
#endif /* GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_CC_H_ */ #endif /* GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_CC_H_ */

View File

@ -181,11 +181,11 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
// 3. Check operation executed correctly // 3. Check operation executed correctly
if (d_nav.flag_CRC_test == true) if (d_nav.flag_CRC_test == true)
{ {
LOG(INFO) << "GLONASS GNAV CRC correct on channel " << d_channel << " from satellite " << d_satellite; LOG(INFO) << "GLONASS GNAV CRC correct in channel " << d_channel << " from satellite " << d_satellite;
} }
else else
{ {
LOG(INFO) << "GLONASS GNAV CRC error on channel " << d_channel << " from satellite " << d_satellite; LOG(INFO) << "GLONASS GNAV CRC error in channel " << d_channel << " from satellite " << d_satellite;
} }
// 4. Push the new navigation data to the queues // 4. Push the new navigation data to the queues
if (d_nav.have_new_ephemeris() == true) if (d_nav.have_new_ephemeris() == true)
@ -194,26 +194,29 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
d_nav.gnav_ephemeris.i_satellite_freq_channel = d_satellite.get_rf_link(); d_nav.gnav_ephemeris.i_satellite_freq_channel = d_satellite.get_rf_link();
std::shared_ptr<Glonass_Gnav_Ephemeris> tmp_obj = std::make_shared<Glonass_Gnav_Ephemeris>(d_nav.get_ephemeris()); std::shared_ptr<Glonass_Gnav_Ephemeris> tmp_obj = std::make_shared<Glonass_Gnav_Ephemeris>(d_nav.get_ephemeris());
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
LOG(INFO) << "GLONASS GNAV Ephemeris have been received on channel" << d_channel << " from satellite " << d_satellite; LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite;
std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << std::endl;
} }
if (d_nav.have_new_utc_model() == true) if (d_nav.have_new_utc_model() == true)
{ {
// get object for this SV (mandatory) // get object for this SV (mandatory)
std::shared_ptr<Glonass_Gnav_Utc_Model> tmp_obj = std::make_shared<Glonass_Gnav_Utc_Model>(d_nav.get_utc_model()); std::shared_ptr<Glonass_Gnav_Utc_Model> tmp_obj = std::make_shared<Glonass_Gnav_Utc_Model>(d_nav.get_utc_model());
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
LOG(INFO) << "GLONASS GNAV UTC Model have been received on channel" << d_channel << " from satellite " << d_satellite; LOG(INFO) << "GLONASS GNAV UTC Model have been received in channel" << d_channel << " from satellite " << d_satellite;
std::cout << "New GLONASS L1 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << std::endl;
} }
if (d_nav.have_new_almanac() == true) if (d_nav.have_new_almanac() == true)
{ {
unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number; unsigned int 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)); 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)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
LOG(INFO) << "GLONASS GNAV Almanac have been received on channel" << d_channel << " in slot number " << slot_nbr; LOG(INFO) << "GLONASS GNAV Almanac have been received in channel" << d_channel << " in slot number " << slot_nbr;
std::cout << "New GLONASS L1 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << std::endl;
} }
// 5. Update satellite information on system // 5. Update satellite information on system
if (d_nav.flag_update_slot_number == true) if (d_nav.flag_update_slot_number == true)
{ {
LOG(INFO) << "GLONASS GNAV Slot Number Identified on channel " << d_channel; LOG(INFO) << "GLONASS GNAV Slot Number Identified in channel " << d_channel;
d_satellite.update_PRN(d_nav.gnav_ephemeris.d_n); d_satellite.update_PRN(d_nav.gnav_ephemeris.d_n);
d_satellite.what_block(d_satellite.get_system(), d_nav.gnav_ephemeris.d_n); d_satellite.what_block(d_satellite.get_system(), d_nav.gnav_ephemeris.d_n);
d_nav.flag_update_slot_number = false; d_nav.flag_update_slot_number = false;

View File

@ -31,9 +31,10 @@
#include "glonass_l2_ca_telemetry_decoder_cc.h" #include "glonass_l2_ca_telemetry_decoder_cc.h"
#include "display.h"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <gnuradio/io_signature.h>
#include <glog/logging.h> #include <glog/logging.h>
#include <gnuradio/io_signature.h>
#define CRC_ERROR_LIMIT 6 #define CRC_ERROR_LIMIT 6
@ -180,11 +181,11 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
// 3. Check operation executed correctly // 3. Check operation executed correctly
if (d_nav.flag_CRC_test == true) if (d_nav.flag_CRC_test == true)
{ {
LOG(INFO) << "GLONASS GNAV CRC correct on channel " << d_channel << " from satellite " << d_satellite; LOG(INFO) << "GLONASS GNAV CRC correct in channel " << d_channel << " from satellite " << d_satellite;
} }
else else
{ {
LOG(INFO) << "GLONASS GNAV CRC error on channel " << d_channel << " from satellite " << d_satellite; LOG(INFO) << "GLONASS GNAV CRC error in channel " << d_channel << " from satellite " << d_satellite;
} }
// 4. Push the new navigation data to the queues // 4. Push the new navigation data to the queues
if (d_nav.have_new_ephemeris() == true) if (d_nav.have_new_ephemeris() == true)
@ -193,26 +194,29 @@ void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, in
d_nav.gnav_ephemeris.i_satellite_freq_channel = d_satellite.get_rf_link(); d_nav.gnav_ephemeris.i_satellite_freq_channel = d_satellite.get_rf_link();
std::shared_ptr<Glonass_Gnav_Ephemeris> tmp_obj = std::make_shared<Glonass_Gnav_Ephemeris>(d_nav.get_ephemeris()); std::shared_ptr<Glonass_Gnav_Ephemeris> tmp_obj = std::make_shared<Glonass_Gnav_Ephemeris>(d_nav.get_ephemeris());
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
LOG(INFO) << "GLONASS GNAV Ephemeris have been received on channel" << d_channel << " from satellite " << d_satellite; LOG(INFO) << "GLONASS GNAV Ephemeris have been received in channel" << d_channel << " from satellite " << d_satellite;
std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl;
} }
if (d_nav.have_new_utc_model() == true) if (d_nav.have_new_utc_model() == true)
{ {
// get object for this SV (mandatory) // get object for this SV (mandatory)
std::shared_ptr<Glonass_Gnav_Utc_Model> tmp_obj = std::make_shared<Glonass_Gnav_Utc_Model>(d_nav.get_utc_model()); std::shared_ptr<Glonass_Gnav_Utc_Model> tmp_obj = std::make_shared<Glonass_Gnav_Utc_Model>(d_nav.get_utc_model());
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
LOG(INFO) << "GLONASS GNAV UTC Model have been received on channel" << d_channel << " from satellite " << d_satellite; LOG(INFO) << "GLONASS GNAV UTC Model have been received in channel" << d_channel << " from satellite " << d_satellite;
std::cout << TEXT_CYAN << "New GLONASS L2 GNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl;
} }
if (d_nav.have_new_almanac() == true) if (d_nav.have_new_almanac() == true)
{ {
unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number; unsigned int 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)); 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)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
LOG(INFO) << "GLONASS GNAV Almanac have been received on channel" << d_channel << " in slot number " << slot_nbr; LOG(INFO) << "GLONASS GNAV Almanac have been received in channel" << d_channel << " in slot number " << slot_nbr;
std::cout << TEXT_CYAN << "New GLONASS L2 GNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << TEXT_RESET << std::endl;
} }
// 5. Update satellite information on system // 5. Update satellite information on system
if (d_nav.flag_update_slot_number == true) if (d_nav.flag_update_slot_number == true)
{ {
LOG(INFO) << "GLONASS GNAV Slot Number Identified on channel " << d_channel; LOG(INFO) << "GLONASS GNAV Slot Number Identified in channel " << d_channel;
d_satellite.update_PRN(d_nav.gnav_ephemeris.d_n); d_satellite.update_PRN(d_nav.gnav_ephemeris.d_n);
d_satellite.what_block(d_satellite.get_system(), d_nav.gnav_ephemeris.d_n); d_satellite.what_block(d_satellite.get_system(), d_nav.gnav_ephemeris.d_n);
d_nav.flag_update_slot_number = false; d_nav.flag_update_slot_number = false;

View File

@ -32,8 +32,9 @@
#include "gps_l1_ca_telemetry_decoder_cc.h" #include "gps_l1_ca_telemetry_decoder_cc.h"
#include "control_message_factory.h" #include "control_message_factory.h"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <gnuradio/io_signature.h>
#include <glog/logging.h> #include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#ifndef _rotl #ifndef _rotl
@ -63,10 +64,8 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(
// set the preamble // set the preamble
unsigned short int preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE; unsigned short int preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE;
//memcpy((unsigned short int*)this->d_preambles_bits, (unsigned short int*)preambles_bits, GPS_CA_PREAMBLE_LENGTH_BITS*sizeof(unsigned short int));
// preamble bits to sampled symbols // preamble bits to sampled symbols
d_preambles_symbols = static_cast<signed int *>(malloc(sizeof(signed int) * GPS_CA_PREAMBLE_LENGTH_SYMBOLS)); d_preambles_symbols = static_cast<int *>(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int), volk_gnsssdr_get_alignment()));
int n = 0; int n = 0;
for (int i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++) for (int i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++)
{ {
@ -112,7 +111,7 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(
gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc() gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc()
{ {
delete d_preambles_symbols; volk_gnsssdr_free(d_preambles_symbols);
if (d_dump_file.is_open() == true) if (d_dump_file.is_open() == true)
{ {
try try

View File

@ -166,20 +166,20 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
{ {
// get ephemeris object for this SV // get ephemeris object for this SV
std::shared_ptr<Gps_CNAV_Ephemeris> tmp_obj = std::make_shared<Gps_CNAV_Ephemeris>(d_CNAV_Message.get_ephemeris()); std::shared_ptr<Gps_CNAV_Ephemeris> tmp_obj = std::make_shared<Gps_CNAV_Ephemeris>(d_CNAV_Message.get_ephemeris());
std::cout << TEXT_BLUE << "New GPS CNAV message received: ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl; std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }
if (d_CNAV_Message.have_new_iono() == true) if (d_CNAV_Message.have_new_iono() == true)
{ {
std::shared_ptr<Gps_CNAV_Iono> tmp_obj = std::make_shared<Gps_CNAV_Iono>(d_CNAV_Message.get_iono()); std::shared_ptr<Gps_CNAV_Iono> tmp_obj = std::make_shared<Gps_CNAV_Iono>(d_CNAV_Message.get_iono());
std::cout << TEXT_BLUE << "New GPS CNAV message received: iono model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << TEXT_RESET << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }
if (d_CNAV_Message.have_new_utc_model() == true) if (d_CNAV_Message.have_new_utc_model() == true)
{ {
std::shared_ptr<Gps_CNAV_Utc_Model> tmp_obj = std::make_shared<Gps_CNAV_Utc_Model>(d_CNAV_Message.get_utc_model()); std::shared_ptr<Gps_CNAV_Utc_Model> tmp_obj = std::make_shared<Gps_CNAV_Utc_Model>(d_CNAV_Message.get_utc_model());
std::cout << TEXT_BLUE << "New GPS CNAV message received: UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl; std::cout << TEXT_BLUE << "New GPS CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }

View File

@ -1,7 +1,6 @@
/*! /*!
* \file gps_l5_telemetry_decoder_cc.cc * \file gps_l5_telemetry_decoder_cc.cc
* \brief Implementation of a NAV message demodulator block based on * \brief Implementation of a CNAV message demodulator block
* Kay Borre book MATLAB-based GPS receiver
* \author Antonio Ramos, 2017. antonio.ramos(at)cttc.es * \author Antonio Ramos, 2017. antonio.ramos(at)cttc.es
* *
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
@ -31,12 +30,13 @@
#include "gps_l5_telemetry_decoder_cc.h" #include "gps_l5_telemetry_decoder_cc.h"
#include "display.h"
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "gps_cnav_ephemeris.h" #include "gps_cnav_ephemeris.h"
#include "gps_cnav_iono.h" #include "gps_cnav_iono.h"
#include <gnuradio/io_signature.h>
#include <glog/logging.h>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <bitset> #include <bitset>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
@ -218,20 +218,20 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u
{ {
// get ephemeris object for this SV // get ephemeris object for this SV
std::shared_ptr<Gps_CNAV_Ephemeris> tmp_obj = std::make_shared<Gps_CNAV_Ephemeris>(d_CNAV_Message.get_ephemeris()); std::shared_ptr<Gps_CNAV_Ephemeris> tmp_obj = std::make_shared<Gps_CNAV_Ephemeris>(d_CNAV_Message.get_ephemeris());
std::cout << "New GPS L5 CNAV message received: ephemeris from satellite " << d_satellite << std::endl; std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }
if (d_CNAV_Message.have_new_iono() == true) if (d_CNAV_Message.have_new_iono() == true)
{ {
std::shared_ptr<Gps_CNAV_Iono> tmp_obj = std::make_shared<Gps_CNAV_Iono>(d_CNAV_Message.get_iono()); std::shared_ptr<Gps_CNAV_Iono> tmp_obj = std::make_shared<Gps_CNAV_Iono>(d_CNAV_Message.get_iono());
std::cout << "New GPS L5 CNAV message received: iono model parameters from satellite " << d_satellite << std::endl; std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": iono model parameters from satellite " << d_satellite << TEXT_RESET << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }
if (d_CNAV_Message.have_new_utc_model() == true) if (d_CNAV_Message.have_new_utc_model() == true)
{ {
std::shared_ptr<Gps_CNAV_Utc_Model> tmp_obj = std::make_shared<Gps_CNAV_Utc_Model>(d_CNAV_Message.get_utc_model()); std::shared_ptr<Gps_CNAV_Utc_Model> tmp_obj = std::make_shared<Gps_CNAV_Utc_Model>(d_CNAV_Message.get_utc_model());
std::cout << "New GPS L5 CNAV message received: UTC model parameters from satellite " << d_satellite << std::endl; std::cout << TEXT_MAGENTA << "New GPS L5 CNAV message received in channel " << d_channel << ": UTC model parameters from satellite " << d_satellite << TEXT_RESET << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
} }

View File

@ -1,7 +1,6 @@
/*! /*!
* \file gps_l5_telemetry_decoder_cc.h * \file gps_l5_telemetry_decoder_cc.h
* \brief Interface of a CNAV message demodulator block based on * \brief Interface of a CNAV message demodulator block
* Kay Borre book MATLAB-based GPS receiver
* \author Antonio Ramos, 2017. antonio.ramos(at)cttc.es * \author Antonio Ramos, 2017. antonio.ramos(at)cttc.es
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
* *
@ -42,7 +41,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
extern "C" { extern "C"
{
#include "cnav_msg.h" #include "cnav_msg.h"
#include "edc.h" #include "edc.h"
#include "bits.h" #include "bits.h"

View File

@ -39,13 +39,16 @@
//************ GPS WORD TO SUBFRAME DECODER STATE MACHINE ********** //************ GPS WORD TO SUBFRAME DECODER STATE MACHINE **********
struct Ev_gps_word_valid : sc::event<Ev_gps_word_valid> struct Ev_gps_word_valid : sc::event<Ev_gps_word_valid>
{ {
}; };
struct Ev_gps_word_invalid : sc::event<Ev_gps_word_invalid> struct Ev_gps_word_invalid : sc::event<Ev_gps_word_invalid>
{ {
}; };
struct Ev_gps_word_preamble : sc::event<Ev_gps_word_preamble> struct Ev_gps_word_preamble : sc::event<Ev_gps_word_preamble>
{ {
}; };
@ -245,16 +248,20 @@ void GpsL1CaSubframeFsm::gps_word_to_subframe(int position)
std::memcpy(&d_subframe[position * GPS_WORD_LENGTH], &d_GPS_frame_4bytes, sizeof(char) * GPS_WORD_LENGTH); std::memcpy(&d_subframe[position * GPS_WORD_LENGTH], &d_GPS_frame_4bytes, sizeof(char) * GPS_WORD_LENGTH);
} }
void GpsL1CaSubframeFsm::clear_flag_new_subframe() void GpsL1CaSubframeFsm::clear_flag_new_subframe()
{ {
d_flag_new_subframe = false; d_flag_new_subframe = false;
} }
void GpsL1CaSubframeFsm::gps_subframe_to_nav_msg() void GpsL1CaSubframeFsm::gps_subframe_to_nav_msg()
{ {
//int subframe_ID; //int subframe_ID;
// NEW GPS SUBFRAME HAS ARRIVED! // NEW GPS SUBFRAME HAS ARRIVED!
d_subframe_ID = d_nav.subframe_decoder(this->d_subframe); //decode the subframe d_subframe_ID = d_nav.subframe_decoder(this->d_subframe); //decode the subframe
std::cout << "New GPS NAV message received: subframe " std::cout << "New GPS NAV message received in channel " << i_channel_ID << ": "
<< "subframe "
<< d_subframe_ID << " from satellite " << d_subframe_ID << " from satellite "
<< Gnss_Satellite(std::string("GPS"), i_satellite_PRN) << std::endl; << Gnss_Satellite(std::string("GPS"), i_satellite_PRN) << std::endl;
d_nav.i_satellite_PRN = i_satellite_PRN; d_nav.i_satellite_PRN = i_satellite_PRN;
@ -263,6 +270,7 @@ void GpsL1CaSubframeFsm::gps_subframe_to_nav_msg()
d_flag_new_subframe = true; d_flag_new_subframe = true;
} }
void GpsL1CaSubframeFsm::Event_gps_word_valid() void GpsL1CaSubframeFsm::Event_gps_word_valid()
{ {
this->process_event(Ev_gps_word_valid()); this->process_event(Ev_gps_word_valid());

View File

@ -148,6 +148,7 @@ void ControlThread::run()
std::cout << "Stopping GNSS-SDR, please wait!" << std::endl; std::cout << "Stopping GNSS-SDR, please wait!" << std::endl;
flowgraph_->stop(); flowgraph_->stop();
stop_ = true; stop_ = true;
flowgraph_->disconnect();
//Join keyboard thread //Join keyboard thread
#ifdef OLD_BOOST #ifdef OLD_BOOST

View File

@ -58,7 +58,13 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configurati
} }
GNSSFlowgraph::~GNSSFlowgraph() {} GNSSFlowgraph::~GNSSFlowgraph()
{
if (connected_)
{
GNSSFlowgraph::disconnect();
}
}
void GNSSFlowgraph::start() void GNSSFlowgraph::start()
@ -376,6 +382,183 @@ void GNSSFlowgraph::connect()
} }
void GNSSFlowgraph::disconnect()
{
LOG(INFO) << "Disconnecting flowgraph";
if (!connected_)
{
LOG(INFO) << "flowgraph was not connected";
return;
}
// Signal Source (i) > Signal conditioner (i) >
int RF_Channels = 0;
int signal_conditioner_ID = 0;
for (int i = 0; i < sources_count_; i++)
{
try
{
// TODO: Remove this array implementation and create generic multistream connector
// (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner)
if (sig_source_.at(i)->implementation().compare("Raw_Array_Signal_Source") == 0)
{
//Multichannel Array
for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++)
{
top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j);
}
}
else
{
// TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface.
// Include GetRFChannels in the interface to avoid read config parameters here
// read the number of RF channels for each front-end
RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1);
for (int j = 0; j < RF_Channels; j++)
{
if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1)
{
top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0);
}
else
{
if (j == 0)
{
// RF_channel 0 backward compatibility with single channel sources
top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0);
}
else
{
// Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call)
top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0);
}
}
signal_conditioner_ID++;
}
}
}
catch (const std::exception& e)
{
LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what();
}
}
try
{
top_block_->disconnect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0);
top_block_->disconnect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse
}
catch (const std::exception& e)
{
LOG(INFO) << "Can't disconnect sample counter: " << e.what();
}
// Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID)
int selected_signal_conditioner_ID;
for (unsigned int i = 0; i < channels_count_; i++)
{
selected_signal_conditioner_ID = configuration_->property("Channel" + boost::lexical_cast<std::string>(i) + ".RF_channel_ID", 0);
try
{
top_block_->disconnect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0,
channels_.at(i)->get_left_block(), 0);
}
catch (const std::exception& e)
{
LOG(INFO) << "Can't disconnect signal conditioner " << selected_signal_conditioner_ID << " to channel " << i << ": " << e.what();
}
// Signal Source > Signal conditioner >> Channels >> Observables
try
{
top_block_->disconnect(channels_.at(i)->get_right_block(), 0,
observables_->get_left_block(), i);
}
catch (const std::exception& e)
{
LOG(INFO) << "Can't disconnect channel " << i << " to observables: " << e.what();
}
}
try
{
for (unsigned int i = 0; i < channels_count_; i++)
{
top_block_->disconnect(observables_->get_right_block(), i, pvt_->get_left_block(), i);
top_block_->msg_disconnect(channels_.at(i)->get_right_block(), pmt::mp("telemetry"), pvt_->get_left_block(), pmt::mp("telemetry"));
}
}
catch (const std::exception& e)
{
LOG(INFO) << "Can't disconnect observables to PVT: " << e.what();
}
for (int i = 0; i < sources_count_; i++)
{
try
{
sig_source_.at(i)->disconnect(top_block_);
}
catch (const std::exception& e)
{
LOG(INFO) << "Can't disconnect signal source block " << i << " internally: " << e.what();
}
}
// Signal Source > Signal conditioner >
for (unsigned int i = 0; i < sig_conditioner_.size(); i++)
{
try
{
sig_conditioner_.at(i)->disconnect(top_block_);
}
catch (const std::exception& e)
{
LOG(INFO) << "Can't disconnect signal conditioner block " << i << " internally: " << e.what();
}
}
for (unsigned int i = 0; i < channels_count_; i++)
{
try
{
channels_.at(i)->disconnect(top_block_);
}
catch (const std::exception& e)
{
LOG(INFO) << "Can't disconnect channel " << i << " internally: " << e.what();
}
}
try
{
observables_->disconnect(top_block_);
}
catch (const std::exception& e)
{
LOG(INFO) << "Can't disconnect observables block internally: " << e.what();
}
// Signal Source > Signal conditioner >> Channels >> Observables > PVT
try
{
pvt_->disconnect(top_block_);
}
catch (const std::exception& e)
{
LOG(INFO) << "Can't disconnect PVT block internally: " << e.what();
}
DLOG(INFO) << "blocks disconnected internally";
connected_ = false;
LOG(INFO) << "Flowgraph disconnected";
}
void GNSSFlowgraph::wait() void GNSSFlowgraph::wait()
{ {
if (!running_) if (!running_)
@ -411,18 +594,19 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what)
switch (what) switch (what)
{ {
case 0: case 0:
DLOG(INFO) << "Channel " << who << " ACQ FAILED satellite " << channels_.at(who)->get_signal().get_satellite() << ", Signal " << channels_.at(who)->get_signal().get_signal_str(); DLOG(INFO) << "Channel " << who << " ACQ FAILED satellite " << channels_[who]->get_signal().get_satellite() << ", Signal " << channels_[who]->get_signal().get_signal_str();
if (sat == 0) if (sat == 0)
{ {
available_GNSS_signals_.push_back(channels_.at(who)->get_signal()); std::lock_guard<std::mutex> lock(signal_list_mutex);
channels_.at(who)->set_signal(search_next_signal(channels_.at(who)->get_signal().get_signal_str(), true)); available_GNSS_signals_.push_back(channels_[who]->get_signal());
channels_[who]->set_signal(search_next_signal(channels_[who]->get_signal().get_signal_str(), true));
} }
DLOG(INFO) << "Channel " << who << " Starting acquisition " << channels_.at(who)->get_signal().get_satellite() << ", Signal " << channels_.at(who)->get_signal().get_signal_str(); DLOG(INFO) << "Channel " << who << " Starting acquisition " << channels_[who]->get_signal().get_satellite() << ", Signal " << channels_[who]->get_signal().get_signal_str();
channels_.at(who)->start_acquisition(); channels_[who]->start_acquisition();
break; break;
case 1: case 1:
LOG(INFO) << "Channel " << who << " ACQ SUCCESS satellite " << channels_.at(who)->get_signal().get_satellite(); LOG(INFO) << "Channel " << who << " ACQ SUCCESS satellite " << channels_[who]->get_signal().get_satellite();
channels_state_[who] = 2; channels_state_[who] = 2;
acq_channels_count_--; acq_channels_count_--;
for (unsigned int i = 0; i < channels_count_; i++) for (unsigned int i = 0; i < channels_count_; i++)
@ -433,26 +617,27 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what)
channels_state_[i] = 1; channels_state_[i] = 1;
if (sat_ == 0) if (sat_ == 0)
{ {
channels_.at(i)->set_signal(search_next_signal(channels_.at(i)->get_signal().get_signal_str(), true)); std::lock_guard<std::mutex> lock(signal_list_mutex);
channels_[i]->set_signal(search_next_signal(channels_[i]->get_signal().get_signal_str(), true));
} }
acq_channels_count_++; acq_channels_count_++;
DLOG(INFO) << "Channel " << i << " Starting acquisition " << channels_.at(i)->get_signal().get_satellite() << ", Signal " << channels_.at(i)->get_signal().get_signal_str(); DLOG(INFO) << "Channel " << i << " Starting acquisition " << channels_[i]->get_signal().get_satellite() << ", Signal " << channels_[i]->get_signal().get_signal_str();
channels_.at(i)->start_acquisition(); channels_[i]->start_acquisition();
} }
DLOG(INFO) << "Channel " << i << " in state " << channels_state_[i]; DLOG(INFO) << "Channel " << i << " in state " << channels_state_[i];
} }
break; break;
case 2: case 2:
LOG(INFO) << "Channel " << who << " TRK FAILED satellite " << channels_.at(who)->get_signal().get_satellite(); LOG(INFO) << "Channel " << who << " TRK FAILED satellite " << channels_[who]->get_signal().get_satellite();
DLOG(INFO) << "Number of channels in acquisition = " << acq_channels_count_; DLOG(INFO) << "Number of channels in acquisition = " << acq_channels_count_;
if (acq_channels_count_ < max_acq_channels_) if (acq_channels_count_ < max_acq_channels_)
{ {
channels_state_[who] = 1; channels_state_[who] = 1;
acq_channels_count_++; acq_channels_count_++;
LOG(INFO) << "Channel " << who << " Starting acquisition " << channels_.at(who)->get_signal().get_satellite() << ", Signal " << channels_.at(who)->get_signal().get_signal_str(); LOG(INFO) << "Channel " << who << " Starting acquisition " << channels_[who]->get_signal().get_satellite() << ", Signal " << channels_[who]->get_signal().get_signal_str();
channels_.at(who)->start_acquisition(); channels_[who]->start_acquisition();
} }
else else
{ {
@ -460,7 +645,8 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what)
LOG(INFO) << "Channel " << who << " Idle state"; LOG(INFO) << "Channel " << who << " Idle state";
if (sat == 0) if (sat == 0)
{ {
available_GNSS_signals_.push_back(channels_.at(who)->get_signal()); std::lock_guard<std::mutex> lock(signal_list_mutex);
available_GNSS_signals_.push_back(channels_[who]->get_signal());
} }
} }
break; break;

View File

@ -43,6 +43,7 @@
#include <gnuradio/msg_queue.h> #include <gnuradio/msg_queue.h>
#include <list> #include <list>
#include <memory> #include <memory>
#include <mutex>
#include <queue> #include <queue>
#include <string> #include <string>
#include <vector> #include <vector>
@ -67,9 +68,9 @@ public:
GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configuration, gr::msg_queue::sptr queue); GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configuration, gr::msg_queue::sptr queue);
/*! /*!
* \brief Virtual destructor * \brief Destructor
*/ */
virtual ~GNSSFlowgraph(); ~GNSSFlowgraph();
//! \brief Start the flow graph //! \brief Start the flow graph
void start(); void start();
@ -84,6 +85,8 @@ public:
*/ */
void connect(); void connect();
void disconnect();
void wait(); void wait();
/*! /*!
@ -147,6 +150,7 @@ private:
gr::msg_queue::sptr queue_; gr::msg_queue::sptr queue_;
std::list<Gnss_Signal> available_GNSS_signals_; std::list<Gnss_Signal> available_GNSS_signals_;
std::vector<unsigned int> channels_state_; std::vector<unsigned int> channels_state_;
std::mutex signal_list_mutex;
}; };
#endif /*GNSS_SDR_GNSS_FLOWGRAPH_H_*/ #endif /*GNSS_SDR_GNSS_FLOWGRAPH_H_*/