mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-11-14 22:27:12 +00:00
Code cleaning.
Test infrastructure reactivated. Now a run_tests executable is created and runs some tests. git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@138 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
@@ -126,6 +126,10 @@ void gps_l1_ca_pcps_acquisition_cc::set_satellite(Gnss_Satellite satellite)
|
||||
|
||||
// Now the GPS codes are generated on the fly using a custom version of the GPS code generator
|
||||
code_gen_complex_sampled(d_fft_if->get_inbuf(), satellite.get_PRN(), d_fs_in, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
d_fft_if->execute(); // We need the FFT of GPS C/A code
|
||||
//Conjugate the local code
|
||||
//TODO Optimize it ! try conj()
|
||||
|
||||
@@ -146,50 +146,50 @@ signed int code_gen(CPX *_dest, signed int _prn)
|
||||
*/
|
||||
void code_gen_complex_sampled(std::complex<float>* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift)
|
||||
{
|
||||
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
|
||||
std::complex<float> _code[1023];
|
||||
signed int _samplesPerCode,_codeValueIndex;
|
||||
float _ts;
|
||||
float _tc;
|
||||
const signed int _codeFreqBasis=1023000; //Hz
|
||||
const signed int _codeLength=1023;
|
||||
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
|
||||
std::complex<float> _code[1023];
|
||||
signed int _samplesPerCode, _codeValueIndex;
|
||||
float _ts;
|
||||
float _tc;
|
||||
const signed int _codeFreqBasis = 1023000; //Hz
|
||||
const signed int _codeLength = 1023;
|
||||
|
||||
//--- Find number of samples per spreading code ----------------------------
|
||||
_samplesPerCode = round(_fs / (_codeFreqBasis / _codeLength));
|
||||
//--- Find number of samples per spreading code ----------------------------
|
||||
_samplesPerCode = round(_fs / (_codeFreqBasis / _codeLength));
|
||||
|
||||
//--- Find time constants --------------------------------------------------
|
||||
_ts = 1/(float)_fs; // Sampling period in sec
|
||||
_tc = 1/(float)_codeFreqBasis; // C/A chip period in sec
|
||||
code_gen_conplex(_code,_prn,_chip_shift); //generate C/A code 1 sample per chip
|
||||
//std::cout<<"ts="<<_ts<<std::endl;
|
||||
//std::cout<<"tc="<<_tc<<std::endl;
|
||||
//std::cout<<"sv="<<_prn<<std::endl;
|
||||
for (signed int i=0;i<_samplesPerCode;i++)
|
||||
{
|
||||
//=== Digitizing =======================================================
|
||||
//--- Find time constants --------------------------------------------------
|
||||
_ts = 1/(float)_fs; // Sampling period in sec
|
||||
_tc = 1/(float)_codeFreqBasis; // C/A chip period in sec
|
||||
code_gen_conplex(_code,_prn, _chip_shift); //generate C/A code 1 sample per chip
|
||||
//std::cout<<"ts="<<_ts<<std::endl;
|
||||
//std::cout<<"tc="<<_tc<<std::endl;
|
||||
//std::cout<<"sv="<<_prn<<std::endl;
|
||||
for (signed int i=0; i<_samplesPerCode; i++)
|
||||
{
|
||||
//=== Digitizing =======================================================
|
||||
|
||||
//--- Make index array to read C/A code values -------------------------
|
||||
// The length of the index array depends on the sampling frequency -
|
||||
// number of samples per millisecond (because one C/A code period is one
|
||||
// millisecond).
|
||||
//--- Make index array to read C/A code values -------------------------
|
||||
// The length of the index array depends on the sampling frequency -
|
||||
// number of samples per millisecond (because one C/A code period is one
|
||||
// millisecond).
|
||||
|
||||
|
||||
_codeValueIndex = ceil((_ts * ((float)i+1)) / _tc)-1;
|
||||
_codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1;
|
||||
|
||||
//--- Make the digitized version of the C/A code -----------------------
|
||||
// The "upsampled" code is made by selecting values form the CA code
|
||||
// chip array (caCode) for the time instances of each sample.
|
||||
if (i==_samplesPerCode-1){
|
||||
//--- Correct the last index (due to number rounding issues) -----------
|
||||
_dest[i] = _code[_codeLength-1];
|
||||
|
||||
}else{
|
||||
_dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample
|
||||
}
|
||||
//std::cout<<_codeValueIndex;
|
||||
|
||||
}
|
||||
//--- Make the digitized version of the C/A code -----------------------
|
||||
// The "upsampled" code is made by selecting values form the CA code
|
||||
// chip array (caCode) for the time instances of each sample.
|
||||
if (i == _samplesPerCode - 1)
|
||||
{
|
||||
//--- Correct the last index (due to number rounding issues) -----------
|
||||
_dest[i] = _code[_codeLength - 1];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
PassThrough::PassThrough(ConfigurationInterface* configuration, std::string role,
|
||||
Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams,
|
||||
unsigned int out_streams) :
|
||||
role_(role),
|
||||
@@ -77,25 +77,25 @@ PassThrough::PassThrough(ConfigurationInterface* configuration, std::string role
|
||||
DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")";
|
||||
}
|
||||
|
||||
PassThrough::~PassThrough()
|
||||
Pass_Through::~Pass_Through()
|
||||
{}
|
||||
|
||||
void PassThrough::connect(gr_top_block_sptr top_block)
|
||||
void Pass_Through::connect(gr_top_block_sptr top_block)
|
||||
{
|
||||
DLOG(INFO) << "nothing to connect internally";
|
||||
}
|
||||
|
||||
void PassThrough::disconnect(gr_top_block_sptr top_block)
|
||||
void Pass_Through::disconnect(gr_top_block_sptr top_block)
|
||||
{
|
||||
// Nothing to disconnect
|
||||
}
|
||||
|
||||
gr_basic_block_sptr PassThrough::get_left_block()
|
||||
gr_basic_block_sptr Pass_Through::get_left_block()
|
||||
{
|
||||
return kludge_copy_;
|
||||
}
|
||||
|
||||
gr_basic_block_sptr PassThrough::get_right_block()
|
||||
gr_basic_block_sptr Pass_Through::get_right_block()
|
||||
{
|
||||
return kludge_copy_;
|
||||
}
|
||||
|
||||
@@ -43,16 +43,16 @@
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
class PassThrough : public GNSSBlockInterface
|
||||
class Pass_Through : public GNSSBlockInterface
|
||||
{
|
||||
|
||||
public:
|
||||
PassThrough(ConfigurationInterface* configuration,
|
||||
Pass_Through(ConfigurationInterface* configuration,
|
||||
std::string role,
|
||||
unsigned int in_stream,
|
||||
unsigned int out_stream);
|
||||
|
||||
virtual ~PassThrough();
|
||||
virtual ~Pass_Through();
|
||||
|
||||
std::string role()
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ FileOutputFilter::FileOutputFilter(ConfigurationInterface* configuration,
|
||||
out_streams_(out_streams)
|
||||
{
|
||||
|
||||
std::string default_filename = "./data/signal.dat";
|
||||
std::string default_filename = "./output.dat";
|
||||
std::string default_item_type = "short";
|
||||
|
||||
filename_ = configuration->property(role + ".filename", default_filename);
|
||||
|
||||
@@ -51,98 +51,95 @@ DEFINE_string(signal_source, "-",
|
||||
FileSignalSource::FileSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
gr_msg_queue_sptr queue) :
|
||||
role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(
|
||||
queue)
|
||||
role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
{
|
||||
|
||||
std::string default_filename = "./signal_samples/signal.dat";
|
||||
std::string default_filename = "../data/sc2_d16.dat";
|
||||
std::string default_item_type = "short";
|
||||
std::string default_dump_filename = "./data/signal_source.dat";
|
||||
std::string default_dump_filename = "../data/sc2_d16.dat";
|
||||
|
||||
samples_ = configuration->property(role + ".samples", 0);
|
||||
sampling_frequency_ = configuration->property(role
|
||||
+ ".sampling_frequency", 0);
|
||||
sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0);
|
||||
filename_ = configuration->property(role + ".filename", default_filename);
|
||||
|
||||
// override value with commandline flag, if present
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_= FLAGS_signal_source;
|
||||
|
||||
item_type_ = configuration->property(role + ".item_type",
|
||||
default_item_type);
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
repeat_ = configuration->property(role + ".repeat", false);
|
||||
dump_ = configuration->property(role + ".dump", false);
|
||||
dump_filename_ = configuration->property(role + ".dump_filename",
|
||||
default_dump_filename);
|
||||
enable_throttle_control_ = configuration->property(role
|
||||
+ ".enable_throttle_control", false);
|
||||
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
|
||||
enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false);
|
||||
|
||||
if (item_type_.compare("gr_complex") == 0)
|
||||
{
|
||||
item_size_ = sizeof(gr_complex);
|
||||
}
|
||||
{
|
||||
item_size_ = sizeof(gr_complex);
|
||||
}
|
||||
else if (item_type_.compare("float") == 0)
|
||||
{
|
||||
item_size_ = sizeof(float);
|
||||
}
|
||||
{
|
||||
item_size_ = sizeof(float);
|
||||
}
|
||||
else if (item_type_.compare("short") == 0)
|
||||
{
|
||||
item_size_ = sizeof(short);
|
||||
}
|
||||
{
|
||||
item_size_ = sizeof(short);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_AT_LEVEL(WARNING) << item_type_
|
||||
<< " unrecognized item type. Using short.";
|
||||
item_size_ = sizeof(short);
|
||||
}
|
||||
{
|
||||
LOG_AT_LEVEL(WARNING) << item_type_
|
||||
<< " unrecognized item type. Using short.";
|
||||
item_size_ = sizeof(short);
|
||||
}
|
||||
|
||||
file_source_
|
||||
= gr_make_file_source(item_size_, filename_.c_str(), repeat_);
|
||||
file_source_ = gr_make_file_source(item_size_, filename_.c_str(), repeat_);
|
||||
DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")";
|
||||
|
||||
if (samples_==0)
|
||||
{
|
||||
/*!
|
||||
* BUG workaround: The GNURadio file source does not stop the receiver after reaching the End of File.
|
||||
* A possible solution is to compute the file length in samples using file size, excluding the last 100 milliseconds, and enable always the
|
||||
* valve block
|
||||
*/
|
||||
std::ifstream file (filename_.c_str(), std::ios::in|std::ios::binary|std::ios::ate);
|
||||
std::ifstream::pos_type size;
|
||||
if (file.is_open())
|
||||
{
|
||||
size =file.tellg();
|
||||
}else{
|
||||
std::cout<<"file_signal_source: Unable to open the samples file "<<filename_.c_str()<<"\r\n";
|
||||
LOG_AT_LEVEL(WARNING)<<"file_signal_source: Unable to open the samples file "<<filename_.c_str();
|
||||
}
|
||||
std::cout<<std::setprecision(16);
|
||||
std::cout<<"Processing file "<<filename_<<" containing "<<(double)size<<" [bytes] \r\n";
|
||||
if (size>0)
|
||||
{
|
||||
samples_=floor((double)size/(double)item_size())-ceil(0.1*(double)sampling_frequency_); //process all the samples available in the file excluding the last 100 ms
|
||||
if (samples_ == 0)
|
||||
{
|
||||
/*!
|
||||
* BUG workaround: The GNURadio file source does not stop the receiver after reaching the End of File.
|
||||
* A possible solution is to compute the file length in samples using file size, excluding the last 100 milliseconds, and enable always the
|
||||
* valve block
|
||||
*/
|
||||
std::ifstream file (filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
||||
std::ifstream::pos_type size;
|
||||
if (file.is_open())
|
||||
{
|
||||
size = file.tellg();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "file_signal_source: Unable to open the samples file " << filename_.c_str() << std::endl;
|
||||
LOG_AT_LEVEL(ERROR) << "file_signal_source: Unable to open the samples file " << filename_.c_str();
|
||||
}
|
||||
std::cout << std::setprecision(16);
|
||||
std::cout <<"Processing file " << filename_ << ", which contains " << (double)size << " [bytes]" << std::endl;
|
||||
if (size > 0)
|
||||
{
|
||||
samples_ = floor((double)size / (double)item_size()) - ceil(0.1 * (double)sampling_frequency_); //process all the samples available in the file excluding the last 100 ms
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double signal_duration_s;
|
||||
signal_duration_s=(double)samples_*(1/(double)sampling_frequency_);
|
||||
DLOG(INFO)<<"Total samples to be processed="<<samples_<<" GNSS signal duration= "<<signal_duration_s<<" [s]";
|
||||
std::cout<<"GNSS signal recorded time to be processed: "<<signal_duration_s<<" [s]\r\n";
|
||||
signal_duration_s = (double)samples_ * ( 1 /(double)sampling_frequency_);
|
||||
DLOG(INFO) << "Total samples to be processed= "<< samples_ << " GNSS signal duration= " << signal_duration_s << " [s]";
|
||||
std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl;
|
||||
// if samples != 0 then enable a flow valve to stop the process after n samples
|
||||
if (samples_ != 0)
|
||||
{
|
||||
valve_ = gnss_sdr_make_valve(item_size_, samples_, queue_);
|
||||
DLOG(INFO) << "valve(" << valve_->unique_id() << ")";
|
||||
}
|
||||
{
|
||||
valve_ = gnss_sdr_make_valve(item_size_, samples_, queue_);
|
||||
DLOG(INFO) << "valve(" << valve_->unique_id() << ")";
|
||||
}
|
||||
|
||||
if (dump_)
|
||||
{
|
||||
sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str());
|
||||
DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")";
|
||||
}
|
||||
{
|
||||
sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str());
|
||||
DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")";
|
||||
}
|
||||
|
||||
if (enable_throttle_control_)
|
||||
{
|
||||
throttle_ = gr_make_throttle(item_size_, sampling_frequency_);
|
||||
}
|
||||
{
|
||||
throttle_ = gr_make_throttle(item_size_, sampling_frequency_);
|
||||
}
|
||||
DLOG(INFO) << "File source filename " << filename_;
|
||||
DLOG(INFO) << "Samples " << samples_;
|
||||
DLOG(INFO) << "Sampling frequency " << sampling_frequency_;
|
||||
@@ -151,132 +148,152 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration,
|
||||
DLOG(INFO) << "Repeat " << repeat_;
|
||||
DLOG(INFO) << "Dump " << dump_;
|
||||
DLOG(INFO) << "Dump filename " << dump_filename_;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FileSignalSource::~FileSignalSource()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
|
||||
|
||||
void FileSignalSource::connect(gr_top_block_sptr top_block)
|
||||
{
|
||||
if (samples_ != 0)
|
||||
{
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->connect(file_source_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "connected file source to throttle";
|
||||
top_block->connect(throttle_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected throttle to valve";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(valve_, 0, sink_, 0);
|
||||
DLOG(INFO) << "connected valve to file sink";
|
||||
}
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->connect(file_source_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "connected file source to throttle";
|
||||
top_block->connect(throttle_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected throttle to valve";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(valve_, 0, sink_, 0);
|
||||
DLOG(INFO) << "connected valve to file sink";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->connect(file_source_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected file source to valve";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(valve_, 0, sink_, 0);
|
||||
DLOG(INFO) << "connected valve to file sink";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->connect(file_source_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected file source to valve";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(valve_, 0, sink_, 0);
|
||||
DLOG(INFO) << "connected valve to file sink";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->connect(file_source_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "connected file source to throttle";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(file_source_, 0, sink_, 0);
|
||||
DLOG(INFO) << "connected file source to sink";
|
||||
}
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->connect(file_source_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "connected file source to throttle";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(file_source_, 0, sink_, 0);
|
||||
DLOG(INFO) << "connected file source to sink";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(file_source_, 0, sink_, 0);
|
||||
DLOG(INFO) << "connected file source to sink";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(file_source_, 0, sink_, 0);
|
||||
DLOG(INFO) << "connected file source to sink";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void FileSignalSource::disconnect(gr_top_block_sptr top_block)
|
||||
{
|
||||
if (samples_ != 0)
|
||||
{
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "disconnected file source to throttle";
|
||||
top_block->disconnect(throttle_, 0, valve_, 0);
|
||||
DLOG(INFO) << "disconnected throttle to valve";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(valve_, 0, sink_, 0);
|
||||
DLOG(INFO) << "disconnected valve to file sink";
|
||||
}
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "disconnected file source to throttle";
|
||||
top_block->disconnect(throttle_, 0, valve_, 0);
|
||||
DLOG(INFO) << "disconnected throttle to valve";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(valve_, 0, sink_, 0);
|
||||
DLOG(INFO) << "disconnected valve to file sink";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, valve_, 0);
|
||||
DLOG(INFO) << "disconnected file source to valve";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(valve_, 0, sink_, 0);
|
||||
DLOG(INFO) << "disconnected valve to file sink";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, valve_, 0);
|
||||
DLOG(INFO) << "disconnected file source to valve";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(valve_, 0, sink_, 0);
|
||||
DLOG(INFO) << "disconnected valve to file sink";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "disconnected file source to throttle";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, sink_, 0);
|
||||
DLOG(INFO) << "disconnected file source to sink";
|
||||
}
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "disconnected file source to throttle";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, sink_, 0);
|
||||
DLOG(INFO) << "disconnected file source to sink";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, sink_, 0);
|
||||
DLOG(INFO) << "disconnected file source to sink";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, sink_, 0);
|
||||
DLOG(INFO) << "disconnected file source to sink";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gr_basic_block_sptr FileSignalSource::get_left_block()
|
||||
{
|
||||
LOG_AT_LEVEL(WARNING)
|
||||
<< "Left block of a signal source should not be retrieved";
|
||||
<< "Left block of a signal source should not be retrieved";
|
||||
return gr_block_sptr();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gr_basic_block_sptr FileSignalSource::get_right_block()
|
||||
{
|
||||
if (samples_ != 0)
|
||||
{
|
||||
return valve_;
|
||||
}else
|
||||
{
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
return throttle_;
|
||||
}else{
|
||||
return file_source_;
|
||||
}
|
||||
}
|
||||
if (samples_ != 0)
|
||||
{
|
||||
return valve_;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
return throttle_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return file_source_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc(Gnss_Satell
|
||||
d_carrier_loop_filter.set_params(fll_bw_hz,pll_bw_hz,order);
|
||||
|
||||
// Get space for a vector with the C/A code replica sampled 1x/chip
|
||||
d_ca_code = new gr_complex[(int)GPS_L1_CA_CODE_LENGTH_CHIPS+2];
|
||||
d_ca_code = new gr_complex[(int)GPS_L1_CA_CODE_LENGTH_CHIPS + 2];
|
||||
|
||||
// Get space for the resampled early / prompt / late local replicas
|
||||
//d_early_code = new gr_complex[d_vector_length*2];
|
||||
@@ -116,10 +116,16 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc(Gnss_Satell
|
||||
// space for carrier wipeoff LO vector
|
||||
//d_carr_sign = new gr_complex[d_vector_length*2];
|
||||
|
||||
posix_memalign((void**)&d_early_code, 16, d_vector_length*sizeof(gr_complex)*2);
|
||||
posix_memalign((void**)&d_late_code, 16, d_vector_length*sizeof(gr_complex)*2);
|
||||
posix_memalign((void**)&d_prompt_code, 16, d_vector_length*sizeof(gr_complex)*2);
|
||||
posix_memalign((void**)&d_carr_sign,16, d_vector_length*sizeof(gr_complex)*2);
|
||||
/* If an array is partitioned for more than one thread to operate on,
|
||||
* having the sub-array boundaries unaligned to cache lines could lead
|
||||
* to performance degradation. Here we allocate memory
|
||||
* (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes
|
||||
*/
|
||||
// todo: do something if posix_memalign fails
|
||||
if (posix_memalign((void**)&d_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){};
|
||||
if (posix_memalign((void**)&d_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){};
|
||||
if (posix_memalign((void**)&d_prompt_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){};
|
||||
if (posix_memalign((void**)&d_carr_sign, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){};
|
||||
|
||||
// sample synchronization
|
||||
d_sample_counter = 0;
|
||||
@@ -138,7 +144,6 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc(Gnss_Satell
|
||||
d_CN0_SNV_dB_Hz = 0;
|
||||
d_carrier_lock_fail_counter = 0;
|
||||
d_carrier_lock_threshold = 5;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -213,7 +218,9 @@ void Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::start_tracking()
|
||||
d_pull_in = true;
|
||||
d_enable_tracking = true;
|
||||
|
||||
std::cout << "PULL-IN Doppler [Hz]= " << d_carrier_doppler_hz << " Code Phase correction [samples]=" << delay_correction_samples << " PULL-IN Code Phase [samples]= " << d_acq_code_phase_samples << std::endl;
|
||||
std::cout << "PULL-IN Doppler [Hz]= " << d_carrier_doppler_hz
|
||||
<< " Code Phase correction [samples]=" << delay_correction_samples
|
||||
<< " PULL-IN Code Phase [samples]= " << d_acq_code_phase_samples << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -271,10 +278,6 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc()
|
||||
d_dump_file.close();
|
||||
delete[] d_ca_code;
|
||||
|
||||
//delete[] d_early_code;
|
||||
//delete[] d_prompt_code;
|
||||
//delete[] d_late_code;
|
||||
//delete[] d_carr_sign;
|
||||
free(d_prompt_code);
|
||||
free(d_late_code);
|
||||
free(d_early_code);
|
||||
@@ -292,14 +295,6 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc()
|
||||
int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
|
||||
{
|
||||
// if ((unsigned int)ninput_items[0]<(d_vector_length*2))
|
||||
// {
|
||||
// std::cout<<"End of signal detected\r\n";
|
||||
// const int samples_available = ninput_items[0];
|
||||
// consume_each(samples_available);
|
||||
// return 0;
|
||||
// }
|
||||
// process vars
|
||||
float code_error_chips = 0;
|
||||
float correlation_time_s = 0;
|
||||
float PLL_discriminator_hz = 0;
|
||||
@@ -318,26 +313,21 @@ int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vecto
|
||||
if (d_pull_in == true)
|
||||
{
|
||||
int samples_offset;
|
||||
|
||||
// 28/11/2011 ACQ to TRK transition BUG CORRECTION
|
||||
float acq_trk_shif_correction_samples;
|
||||
int acq_to_trk_delay_samples;
|
||||
acq_to_trk_delay_samples = d_sample_counter-d_acq_sample_stamp;
|
||||
acq_trk_shif_correction_samples = d_next_prn_length_samples - fmod((float)acq_to_trk_delay_samples, (float)d_next_prn_length_samples);
|
||||
//std::cout<<"acq_trk_shif_correction="<<acq_trk_shif_correction_samples<<"\r\n";
|
||||
|
||||
samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples);
|
||||
// /todo: Check if the sample counter sent to the next block as a time reference should be incremented AFTER sended or BEFORE
|
||||
d_sample_counter_seconds = d_sample_counter_seconds + (((double)samples_offset)/(double)d_fs_in);
|
||||
d_sample_counter = d_sample_counter + samples_offset; //count for the processed samples
|
||||
d_pull_in = false;
|
||||
//std::cout<<" samples_offset="<<samples_offset<<"\r\n";
|
||||
consume_each(samples_offset); //shift input to perform alignment with local replica
|
||||
return 1;
|
||||
}
|
||||
// get the sample in and out pointers
|
||||
const gr_complex* in = (gr_complex*) input_items[0]; //block input samples pointer
|
||||
double **out = (double **) &output_items[0]; //block output streams pointer
|
||||
double **out = (double **) &output_items[0]; //block output streams pointer
|
||||
|
||||
// check for samples consistency (this should be done before in the receiver / here only if the source is a file)
|
||||
for(int i=0; i<d_current_prn_length_samples; i++)
|
||||
@@ -359,14 +349,14 @@ int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vecto
|
||||
update_local_code();
|
||||
update_local_carrier();
|
||||
|
||||
|
||||
gr_complex* E_out;
|
||||
gr_complex* P_out;
|
||||
gr_complex* L_out;
|
||||
|
||||
posix_memalign((void**)&E_out, 16, 8);
|
||||
posix_memalign((void**)&P_out, 16, 8);
|
||||
posix_memalign((void**)&L_out, 16, 8);
|
||||
// TODO: do something if posix_memalign fails
|
||||
if (posix_memalign((void**)&E_out, 16, 8) == 0){};
|
||||
if (posix_memalign((void**)&P_out, 16, 8) == 0){};
|
||||
if (posix_memalign((void**)&L_out, 16, 8) == 0){};
|
||||
|
||||
// perform Early, Prompt and Late correlation
|
||||
d_correlator.Carrier_wipeoff_and_EPL_volk(d_current_prn_length_samples,
|
||||
@@ -385,18 +375,7 @@ int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vecto
|
||||
free(E_out);
|
||||
free(P_out);
|
||||
free(L_out);
|
||||
/*
|
||||
gr_complex bb_signal_sample(0,0);
|
||||
for(int i=0; i<d_current_prn_length_samples; i++)
|
||||
{
|
||||
//Perform the carrier wipe-off
|
||||
bb_signal_sample = in[i] * d_carr_sign[i];
|
||||
// Now get early, late, and prompt correlation values
|
||||
d_Early += bb_signal_sample * d_early_code[i];
|
||||
d_Prompt += bb_signal_sample * d_prompt_code[i];
|
||||
d_Late += bb_signal_sample * d_late_code[i];
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* DLL, FLL, and PLL discriminators
|
||||
*/
|
||||
@@ -418,16 +397,16 @@ int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vecto
|
||||
}
|
||||
|
||||
// Compute PLL error
|
||||
PLL_discriminator_hz = pll_cloop_two_quadrant_atan(d_Prompt)/(float)TWO_PI;
|
||||
PLL_discriminator_hz = pll_cloop_two_quadrant_atan(d_Prompt) / (float)TWO_PI;
|
||||
|
||||
/*!
|
||||
/*
|
||||
* \todo Update FLL assistance algorithm!
|
||||
*/
|
||||
if (((float)d_sample_counter - (float)d_acq_sample_stamp)/(float)d_fs_in>3)
|
||||
if ((((float)d_sample_counter - (float)d_acq_sample_stamp) / (float)d_fs_in) > 3)
|
||||
{
|
||||
d_FLL_discriminator_hz = 0; //disconnect the FLL after the initial lock
|
||||
}
|
||||
/*!
|
||||
/*
|
||||
* DLL and FLL+PLL filter and get current carrier Doppler and code frequency
|
||||
*/
|
||||
carr_nco_hz = d_carrier_loop_filter.get_carrier_error(d_FLL_discriminator_hz, PLL_discriminator_hz, correlation_time_s);
|
||||
@@ -466,9 +445,7 @@ int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vecto
|
||||
d_channel_internal_queue->push(tracking_message);
|
||||
d_carrier_lock_fail_counter = 0;
|
||||
d_enable_tracking = false; // TODO: check if disabling tracking is consistent with the channel state machine
|
||||
|
||||
}
|
||||
//std::cout<<"d_carrier_lock_fail_counter"<<d_carrier_lock_fail_counter<<"\r\n";
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -65,10 +65,10 @@ float gps_l1_ca_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in)
|
||||
{
|
||||
// estimate CN0 using buffered values
|
||||
// MATLAB CODE
|
||||
//Psig=((1/N)*sum(abs(imag(x((n-N+1):n)))))^2;
|
||||
//Ptot=(1/N)*sum(abs(x((n-N+1):n)).^2);
|
||||
//SNR_SNV(count)=Psig/(Ptot-Psig);
|
||||
//CN0_SNV_dB=10*log10(SNR_SNV)+10*log10(BW)-10*log10(PRN_length);
|
||||
// Psig=((1/N)*sum(abs(imag(x((n-N+1):n)))))^2;
|
||||
// Ptot=(1/N)*sum(abs(x((n-N+1):n)).^2);
|
||||
// SNR_SNV(count)=Psig/(Ptot-Psig);
|
||||
// CN0_SNV_dB=10*log10(SNR_SNV)+10*log10(BW)-10*log10(PRN_length);
|
||||
float SNR, SNR_dB_Hz;
|
||||
float tmp_abs_I, tmp_abs_Q;
|
||||
float Psig, Ptot;
|
||||
@@ -80,12 +80,12 @@ float gps_l1_ca_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in)
|
||||
tmp_abs_I = std::abs(Prompt_buffer[i].imag());
|
||||
tmp_abs_Q = std::abs(Prompt_buffer[i].real());
|
||||
Psig += tmp_abs_I;
|
||||
Ptot += Prompt_buffer[i].imag()*Prompt_buffer[i].imag() + Prompt_buffer[i].real()*Prompt_buffer[i].real();
|
||||
Ptot += Prompt_buffer[i].imag() * Prompt_buffer[i].imag() + Prompt_buffer[i].real() * Prompt_buffer[i].real();
|
||||
}
|
||||
Psig = Psig / (float)length;
|
||||
Psig = Psig*Psig;
|
||||
Psig = Psig * Psig;
|
||||
SNR = Psig / (Ptot / (float)length - Psig);
|
||||
SNR_dB_Hz = 10*log10(SNR) + 10*log10(fs_in/2) - 10*log10(GPS_L1_CA_CODE_LENGTH_CHIPS);
|
||||
SNR_dB_Hz = 10 * log10(SNR) + 10 * log10(fs_in/2) - 10 * log10(GPS_L1_CA_CODE_LENGTH_CHIPS);
|
||||
return SNR_dB_Hz;
|
||||
}
|
||||
|
||||
@@ -100,22 +100,22 @@ float gps_l1_ca_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in)
|
||||
*/
|
||||
float carrier_lock_detector(gr_complex* Prompt_buffer, int length)
|
||||
{
|
||||
/*!
|
||||
* \todo Code lock detector
|
||||
/*
|
||||
* Code lock detector
|
||||
*/
|
||||
// estimate using buffered values
|
||||
// MATLAB CODE
|
||||
// lock detector operation
|
||||
//NBD=sum(abs(imag(x((n-N+1):n))))^2 + sum(abs(real(x((n-N+1):n))))^2;
|
||||
//NBP=sum(imag(x((n-N+1):n)).^2) - sum(real(x((n-N+1):n)).^2);
|
||||
//LOCK(count)=NBD/NBP;
|
||||
// NBD=sum(abs(imag(x((n-N+1):n))))^2 + sum(abs(real(x((n-N+1):n))))^2;
|
||||
// NBP=sum(imag(x((n-N+1):n)).^2) - sum(real(x((n-N+1):n)).^2);
|
||||
// LOCK(count)=NBD/NBP;
|
||||
float tmp_abs_I, tmp_abs_Q;
|
||||
float tmp_sum_abs_I, tmp_sum_abs_Q;
|
||||
float tmp_sum_sqr_I, tmp_sum_sqr_Q;
|
||||
tmp_sum_abs_I=0;
|
||||
tmp_sum_abs_Q=0;
|
||||
tmp_sum_sqr_I=0;
|
||||
tmp_sum_sqr_Q=0;
|
||||
tmp_sum_abs_I = 0;
|
||||
tmp_sum_abs_Q = 0;
|
||||
tmp_sum_sqr_I = 0;
|
||||
tmp_sum_sqr_Q = 0;
|
||||
float NBD,NBP;
|
||||
for (int i=0; i<length; i++)
|
||||
{
|
||||
@@ -123,10 +123,10 @@ float carrier_lock_detector(gr_complex* Prompt_buffer, int length)
|
||||
tmp_abs_Q = std::abs(Prompt_buffer[i].real());
|
||||
tmp_sum_abs_I += tmp_abs_I;
|
||||
tmp_sum_abs_Q += tmp_abs_Q;
|
||||
tmp_sum_sqr_I += (Prompt_buffer[i].imag()*Prompt_buffer[i].imag());
|
||||
tmp_sum_sqr_Q += (Prompt_buffer[i].real()*Prompt_buffer[i].real());
|
||||
tmp_sum_sqr_I += (Prompt_buffer[i].imag() * Prompt_buffer[i].imag());
|
||||
tmp_sum_sqr_Q += (Prompt_buffer[i].real() * Prompt_buffer[i].real());
|
||||
}
|
||||
NBD = tmp_sum_abs_I*tmp_sum_abs_I + tmp_sum_abs_Q*tmp_sum_abs_Q;
|
||||
NBD = tmp_sum_abs_I * tmp_sum_abs_I + tmp_sum_abs_Q * tmp_sum_abs_Q;
|
||||
NBP = tmp_sum_sqr_I - tmp_sum_sqr_Q;
|
||||
return NBD/NBP;
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ void correlator::Carrier_wipeoff_and_EPL_generic(int signal_length_samples,const
|
||||
//Perform the carrier wipe-off
|
||||
bb_signal_sample = input[i] * carrier[i];
|
||||
// Now get early, late, and prompt values for each
|
||||
*E_out += bb_signal_sample*E_code[i];
|
||||
*P_out += bb_signal_sample*P_code[i];
|
||||
*L_out += bb_signal_sample*L_code[i];
|
||||
*E_out += bb_signal_sample * E_code[i];
|
||||
*P_out += bb_signal_sample * P_code[i];
|
||||
*L_out += bb_signal_sample * L_code[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,12 +83,12 @@ void correlator::Carrier_wipeoff_and_EPL_volk(int signal_length_samples,const gr
|
||||
//std::cout<<"length="<<signal_length_samples<<std::endl;
|
||||
|
||||
//long int new_length=next_power_2(signal_length_samples);
|
||||
|
||||
posix_memalign((void**)&bb_signal, 16, signal_length_samples * sizeof(gr_complex));
|
||||
posix_memalign((void**)&input_aligned, 16, signal_length_samples * sizeof(gr_complex));
|
||||
//todo: do something if posix_memalign fails
|
||||
if (posix_memalign((void**)&bb_signal, 16, signal_length_samples * sizeof(gr_complex)) == 0) {};
|
||||
if (posix_memalign((void**)&input_aligned, 16, signal_length_samples * sizeof(gr_complex)) == 0){};
|
||||
//posix_memalign((void**)&carrier_aligned, 16, new_length*sizeof(gr_complex));
|
||||
|
||||
memcpy(input_aligned,input,signal_length_samples*sizeof(gr_complex));
|
||||
memcpy(input_aligned,input,signal_length_samples * sizeof(gr_complex));
|
||||
//memcpy(carrier_aligned,carrier,signal_length_samples*sizeof(gr_complex));
|
||||
|
||||
volk_32fc_x2_multiply_32fc_a_manual(bb_signal, input_aligned, carrier, signal_length_samples, volk_32fc_x2_multiply_32fc_a_best_arch.c_str());
|
||||
|
||||
Reference in New Issue
Block a user