1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-07 02:33:03 +00:00

Code cleaning

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@277 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez
2012-11-01 17:40:26 +00:00
parent 3b489d0107
commit aff4aeefb5
6 changed files with 70 additions and 118 deletions

View File

@@ -165,9 +165,11 @@ void FirFilter::init()
std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type);
int grid_density = config_->property(role_ + ".grid_density", default_grid_density);
std::vector<double> taps_d = gr_remez(number_of_taps - 1, bands, ampl,
error_w, filter_type, grid_density);
// gr_remez implements the Parks-McClellan FIR filter design.
// It calculates the optimal (in the Chebyshev/minimax sense) FIR filter
// impulse response given a set of band edges, the desired response on
// those bands, and the weight given to the error in those bands.
std::vector<double> taps_d = gr_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density);
taps_.reserve(taps_d.size());
for (std::vector<double>::iterator it = taps_d.begin(); it != taps_d.end(); it++)
{

View File

@@ -6,7 +6,7 @@
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
@@ -53,30 +53,24 @@ GpsL1CaTelemetryDecoder::GpsL1CaTelemetryDecoder(ConfigurationInterface* configu
out_streams_(out_streams),
queue_(queue)
{
std::string default_item_type = "gr_complex";
std::string default_dump_filename = "./navigation.dat";
DLOG(INFO) << "role " << role;
DLOG(INFO) << "vector length " << vector_length_;
vector_length_ = configuration->property(role + ".vector_length", 2048);
dump_ = configuration->property(role + ".dump", false);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
int fs_in;
fs_in = configuration->property("GNSS-SDR.internal_fs_hz", 2048000);
// make telemetry decoder object
telemetry_decoder_ = gps_l1_ca_make_telemetry_decoder_cc(satellite_, 0, (long)fs_in, vector_length_, queue_, dump_); // TODO fix me
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
// set the navigation msg queue;
telemetry_decoder_->set_navigation_queue(&global_gps_nav_msg_queue);
DLOG(INFO) << "global navigation message queue assigned to telemetry_decoder ("<< telemetry_decoder_->unique_id() << ")";
}
GpsL1CaTelemetryDecoder::~GpsL1CaTelemetryDecoder()
{}
@@ -95,6 +89,7 @@ void GpsL1CaTelemetryDecoder::connect(gr_top_block_sptr top_block)
DLOG(INFO) << "nothing to connect internally";
}
void GpsL1CaTelemetryDecoder::disconnect(gr_top_block_sptr top_block)
{
// Nothing to disconnect
@@ -106,6 +101,7 @@ gr_basic_block_sptr GpsL1CaTelemetryDecoder::get_left_block()
return telemetry_decoder_;
}
gr_basic_block_sptr GpsL1CaTelemetryDecoder::get_right_block()
{
return telemetry_decoder_;

View File

@@ -124,12 +124,11 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(
d_symbol_accumulator=0;
d_symbol_accumulator_counter = 0;
d_frame_bit_index = 0;
d_preamble_time_seconds=0;
d_preamble_time_seconds = 0;
d_flag_frame_sync = false;
d_GPS_frame_4bytes = 0;
d_prev_GPS_frame_4bytes = 0;
d_flag_parity = false;
//set_history(d_samples_per_bit*8); // At least a history of 8 bits are needed to correlate with the preamble
}
@@ -145,12 +144,10 @@ 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)
{
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. */
d1 = gpsword & 0xFBFFBF00;
d2 = _lrotl(gpsword,1) & 0x07FFBF01;
d3 = _lrotl(gpsword,2) & 0xFC0F8100;
@@ -158,9 +155,7 @@ bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword)
d5 = _lrotl(gpsword,4) & 0xFC00000E;
d6 = _lrotl(gpsword,5) & 0x07F00001;
d7 = _lrotl(gpsword,6) & 0x00003000;
t = d1 ^ d2 ^ d3 ^ d4 ^ d5 ^ d6 ^ d7;
// Now XOR the 5 6-bit fields together to produce the 6-bit final result.
parity = t ^ _lrotl(t,6) ^ _lrotl(t,12) ^ _lrotl(t,18) ^ _lrotl(t,24);
parity = parity & 0x3F;
@@ -243,9 +238,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
}
}
}
//******* SYMBOL TO BIT *******
d_symbol_accumulator += in[0][d_samples_per_bit*8 - 1].Prompt_I; // accumulate the input value in d_symbol_accumulator
d_symbol_accumulator_counter++;
if (d_symbol_accumulator_counter == 20)
@@ -256,14 +249,13 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
}
d_symbol_accumulator = 0;
d_symbol_accumulator_counter = 0;
//******* bits to words ******
d_frame_bit_index++;
if (d_frame_bit_index == 30)
{
d_frame_bit_index = 0;
//parity check
//Each word in wordbuff is composed of:
// parity check
// Each word in wordbuff is composed of:
// Bits 0 to 29 = the GPS data word
// Bits 30 to 31 = 2 LSBs of the GPS word ahead.
// prepare the extended frame [-2 -1 0 ... 30]
@@ -301,12 +293,9 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
d_GPS_frame_4bytes<<=1; //shift 1 bit left the telemetry word
}
}
// output the frame
consume_each(1); //one by one
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
current_synchro_data=in[0][0];
//2. Add the telemetry decoder information
@@ -315,26 +304,24 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
current_synchro_data.Preamble_timestamp_ms = d_preamble_time_seconds * 1000.0;
current_synchro_data.Prn_timestamp_ms = in[0][0].Tracking_timestamp_secs * 1000.0;
current_synchro_data.Preamble_symbol_counter = fmod((double)(d_sample_counter - d_preamble_index), 6000); //not corrected the preamble correlation lag! -> to be taken into account in TX Time
if(d_dump == true)
{
// MULTIPLEXED FILE RECORDING - Record results to file
try
{
double tmp_double;
tmp_double = current_synchro_data.Preamble_timestamp_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double = current_synchro_data.Prn_timestamp_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double = current_synchro_data.Preamble_symbol_counter;
d_dump_file.write((char*)&tmp_double, sizeof(double));
double tmp_double;
tmp_double = current_synchro_data.Preamble_timestamp_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double = current_synchro_data.Prn_timestamp_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double = current_synchro_data.Preamble_symbol_counter;
d_dump_file.write((char*)&tmp_double, sizeof(double));
}
catch (std::ifstream::failure e)
{
std::cout << "Exception writing observables dump file " << e.what() << std::endl;
}
}
//3. Make the output (copy the object contents to the GNURadio reserved memory)
*out[0] = current_synchro_data;
return 1;