1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-16 05:00:35 +00:00

Implement Spirent GSS6450 file signal source

This commit is contained in:
Antonio Ramos 2018-01-16 17:20:55 +01:00
parent 29b8643def
commit 282c3d8659
4 changed files with 128 additions and 24 deletions

View File

@ -78,8 +78,8 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface*
{ {
file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_); file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_);
file_source_->seek(bytes_seek, SEEK_SET); file_source_->seek(bytes_seek, SEEK_SET);
unpack_ii_ = gr::blocks::packed_to_unpacked_ii::make(2 * adc_bits_, gr::GR_MSB_FIRST); unpack_ii_ = gr::blocks::packed_to_unpacked_ii::make(adc_bits_, gr::GR_MSB_FIRST);
unpack_spir_ = make_unpack_spir_gss6450_samples(n_channels_, sel_ch_, item_size_); unpack_spir_ = make_unpack_spir_gss6450_samples(n_channels_, sel_ch_, samples_per_item, item_size_);
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
@ -139,8 +139,7 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface*
} }
CHECK(samples_ > 0) << "File does not contain enough samples to process."; CHECK(samples_ > 0) << "File does not contain enough samples to process.";
double signal_duration_s; double signal_duration_s = static_cast<double>(samples_) * ( 1 /static_cast<double>(sampling_frequency_));
signal_duration_s = static_cast<double>(samples_) * ( 1 /static_cast<double>(sampling_frequency_));
LOG(INFO) << "Total number samples to be processed= " << samples_ << " GNSS signal duration= " << signal_duration_s << " [s]"; LOG(INFO) << "Total number 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; std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl;

View File

@ -34,14 +34,14 @@
unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int n_chann, unsigned int sel_ch, size_t item_size) unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int n_chann, unsigned int sel_ch, int samp_item, size_t item_size)
{ {
return unpack_spir_gss6450_samples_sptr(new unpack_spir_gss6450_samples(n_chann, sel_ch, item_size)); return unpack_spir_gss6450_samples_sptr(new unpack_spir_gss6450_samples(n_chann, sel_ch, samp_item, item_size));
} }
unpack_spir_gss6450_samples::unpack_spir_gss6450_samples( unpack_spir_gss6450_samples::unpack_spir_gss6450_samples(
unsigned int n_chann, unsigned int sel_ch, size_t item_size) : gr::block("unpack_spir_gss6450_samples", unsigned int n_chann, unsigned int sel_ch, int samp_item, size_t item_size) : gr::block("unpack_spir_gss6450_samples",
gr::io_signature::make(1, 1, sizeof(int)), gr::io_signature::make(1, 1, sizeof(int)),
gr::io_signature::make(1, 1, sizeof(gr_complex))) gr::io_signature::make(1, 1, sizeof(gr_complex)))
{ {
@ -49,27 +49,108 @@ unpack_spir_gss6450_samples::unpack_spir_gss6450_samples(
d_sel_ch = sel_ch; d_sel_ch = sel_ch;
item_size_ = item_size; item_size_ = item_size;
ch_processing = 1; ch_processing = 1;
} d_samp_item = samp_item;
samp_frame = 0;
void unpack_spir_gss6450_samples::forecast(int noutput_items, gr_vector_int &ninput_items_required) adc_bits = 16 / d_samp_item;
{ i_ = true;
ninput_items_required[0] = d_channels * noutput_items; new_sample = false;
i_data = 0;
q_data = 0;
} }
unpack_spir_gss6450_samples::~unpack_spir_gss6450_samples() unpack_spir_gss6450_samples::~unpack_spir_gss6450_samples()
{} {}
void unpack_spir_gss6450_samples::process_sample(gr_complex* out)
{
gr_complex result = gr_complex(0.5, 0.5);
compute_two_complement(i_data);
compute_two_complement(q_data);
result += gr_complex(static_cast<float>(i_data), static_cast<float>(q_data));
*out = result;
}
int unpack_spir_gss6450_samples::general_work(int noutput_items, int unpack_spir_gss6450_samples::general_work(int noutput_items,
gr_vector_const_void_star &input_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items) gr_vector_void_star &output_items)
{ {
const int *in = reinterpret_cast<const int *>(input_items[0]); const int* in = reinterpret_cast<const int*>(input_items[0]);
gr_complex *out = reinterpret_cast<gr_complex*>(output_items[0]); gr_complex* out = reinterpret_cast<gr_complex*>(output_items[0]);
int samples_produced = 0;
for(int i = 0; i < noutput_items; i++)
{
if(ch_processing == d_sel_ch)
return noutput_items; {
if(i_)
{
i_data = in[i];
swap_data(i_data);
i_ = false;
}
else
{
q_data = in[i];
swap_data(q_data);
i_ = true;
process_sample(out);
out++;
samples_produced++;
new_sample = true;
}
}
else
{
if(i_) { i_ = false;}
else
{
i_ = true;
new_sample = true;
}
}
if(new_sample)
{
new_sample = false;
samp_frame++;
if(samp_frame == d_samp_item)
{
samp_frame = 0;
ch_processing++;
if(ch_processing > d_channels) { ch_processing = 1; }
}
}
}
consume_each(noutput_items);
return samples_produced;
}
void unpack_spir_gss6450_samples::swap_data(int& data)
{
int result = 0;
int aux = data;
int mask = 1;
for (int i = 0; i < adc_bits; i++)
{
result = result << 1;
result += (aux & mask);
aux = aux >> 1;
}
data = result;
}
void unpack_spir_gss6450_samples::compute_two_complement(int& data)
{
int result = 0;
int mask = 1;
for(int i = 0; i < (adc_bits - 1); i++)
{
result = result << 1;
result += (data >> i) & mask;
}
if((data >> (adc_bits - 1)) == 1)
{
if(adc_bits == 2) { result -= 2; }
else { result -= 8; }
}
data = result;
} }

View File

@ -37,7 +37,7 @@ class unpack_spir_gss6450_samples;
typedef boost::shared_ptr<unpack_spir_gss6450_samples> unpack_spir_gss6450_samples_sptr; typedef boost::shared_ptr<unpack_spir_gss6450_samples> unpack_spir_gss6450_samples_sptr;
unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int n_chann, unsigned int sel_ch, size_t item_size); unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int n_chann, unsigned int sel_ch, int samp_item, size_t item_size);
class unpack_spir_gss6450_samples: public gr::block class unpack_spir_gss6450_samples: public gr::block
@ -46,17 +46,25 @@ public:
int general_work (int noutput_items, int general_work (int noutput_items,
gr_vector_const_void_star &input_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items); gr_vector_void_star &output_items);
void forecast(int noutput_items, gr_vector_int &ninput_items_required); friend unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples_sptr(unsigned int n_chann, unsigned int sel_ch, int samp_item, size_t item_size);
unpack_spir_gss6450_samples(unsigned int n_chann, unsigned int sel_ch, int samp_item, size_t item_size);
~unpack_spir_gss6450_samples(); ~unpack_spir_gss6450_samples();
private: private:
unsigned int d_channels; unsigned int d_channels;
unsigned int d_sel_ch; unsigned int d_sel_ch;
unsigned int ch_processing; unsigned int ch_processing;
int d_samp_item;
int samp_frame;
int adc_bits;
size_t item_size_; size_t item_size_;
friend unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples_sptr(unsigned int n_chann, unsigned int sel_ch, size_t item_size); void process_sample(gr_complex* out);
unpack_spir_gss6450_samples(unsigned int n_chann, unsigned int sel_ch, size_t item_size); void swap_data(int& data);
void compute_two_complement(int& data);
bool i_;
bool new_sample;
int i_data;
int q_data;
}; };
#endif #endif

View File

@ -48,6 +48,7 @@
#include "nsr_file_signal_source.h" #include "nsr_file_signal_source.h"
#include "two_bit_cpx_file_signal_source.h" #include "two_bit_cpx_file_signal_source.h"
#include "spir_file_signal_source.h" #include "spir_file_signal_source.h"
#include "spir_gss6450_file_signal_source.h"
#include "rtl_tcp_signal_source.h" #include "rtl_tcp_signal_source.h"
#include "two_bit_packed_file_signal_source.h" #include "two_bit_packed_file_signal_source.h"
#include "channel.h" #include "channel.h"
@ -864,6 +865,21 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock(
out_streams, queue)); out_streams, queue));
block = std::move(block_); block = std::move(block_);
}
catch (const std::exception &e)
{
std::cout << "GNSS-SDR program ended." << std::endl;
exit(1);
}
}
else if (implementation.compare("Spir_GSS6450_File_Signal_Source") == 0)
{
try
{
std::unique_ptr<GNSSBlockInterface> block_(new SpirGSS6450FileSignalSource(configuration.get(), role, in_streams,
out_streams, queue));
block = std::move(block_);
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {