mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-11-13 13:47:15 +00:00
Merging fpga with next
This commit is contained in:
@@ -41,14 +41,12 @@
|
||||
#include <exception>
|
||||
|
||||
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
|
||||
FileSignalSource::FileSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
{
|
||||
std::string default_filename = "./example_capture.dat";
|
||||
std::string default_item_type = "short";
|
||||
@@ -61,8 +59,8 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration,
|
||||
filename_ = configuration->property(role + ".filename", default_filename);
|
||||
|
||||
// override value with commandline flag, if present
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_= FLAGS_signal_source;
|
||||
if (FLAGS_s.compare("-") != 0) filename_= FLAGS_s;
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_ = FLAGS_signal_source;
|
||||
if (FLAGS_s.compare("-") != 0) filename_ = FLAGS_s;
|
||||
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
repeat_ = configuration->property(role + ".repeat", false);
|
||||
@@ -70,8 +68,8 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration,
|
||||
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
|
||||
enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false);
|
||||
|
||||
double seconds_to_skip = configuration->property(role + ".seconds_to_skip", default_seconds_to_skip );
|
||||
header_size = configuration->property( role + ".header_size", 0 );
|
||||
double seconds_to_skip = configuration->property(role + ".seconds_to_skip", default_seconds_to_skip);
|
||||
header_size = configuration->property(role + ".header_size", 0);
|
||||
long samples_to_skip = 0;
|
||||
|
||||
bool is_complex = false;
|
||||
@@ -105,84 +103,84 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration,
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << item_type_
|
||||
<< " unrecognized item type. Using gr_complex.";
|
||||
<< " unrecognized item type. Using gr_complex.";
|
||||
item_size_ = sizeof(gr_complex);
|
||||
}
|
||||
try
|
||||
{
|
||||
{
|
||||
file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_);
|
||||
|
||||
if( seconds_to_skip > 0 )
|
||||
if (seconds_to_skip > 0)
|
||||
{
|
||||
samples_to_skip = static_cast< long >( seconds_to_skip * sampling_frequency_ );
|
||||
samples_to_skip = static_cast<long>(seconds_to_skip * sampling_frequency_);
|
||||
|
||||
if( is_complex )
|
||||
if (is_complex)
|
||||
{
|
||||
samples_to_skip *= 2;
|
||||
}
|
||||
}
|
||||
if( header_size > 0 )
|
||||
if (header_size > 0)
|
||||
{
|
||||
samples_to_skip += header_size;
|
||||
}
|
||||
|
||||
if( samples_to_skip > 0 )
|
||||
if (samples_to_skip > 0)
|
||||
{
|
||||
LOG(INFO) << "Skipping " << samples_to_skip << " samples of the input file";
|
||||
if( not file_source_->seek( samples_to_skip, SEEK_SET ) )
|
||||
if (not file_source_->seek(samples_to_skip, SEEK_SET))
|
||||
{
|
||||
LOG(INFO) << "Error skipping bytes!";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
if (filename_.compare(default_filename) == 0)
|
||||
{
|
||||
std::cerr
|
||||
<< "The configuration file has not been found."
|
||||
<< std::endl
|
||||
<< "Please create a configuration file based on the examples at the 'conf/' folder "
|
||||
<< std::endl
|
||||
<< "and then generate your own GNSS Software Defined Receiver by doing:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl;
|
||||
<< "The configuration file has not been found."
|
||||
<< std::endl
|
||||
<< "Please create a configuration file based on the examples at the 'conf/' folder "
|
||||
<< std::endl
|
||||
<< "and then generate your own GNSS Software Defined Receiver by doing:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
LOG(INFO) << "file_signal_source: Unable to open the samples file "
|
||||
<< filename_.c_str() << ", exiting the program.";
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
|
||||
DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")";
|
||||
|
||||
if (samples_ == 0) // read all file
|
||||
if (samples_ == 0) // read all file
|
||||
{
|
||||
/*!
|
||||
* BUG workaround: The GNU Radio 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 file(filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
||||
std::ifstream::pos_type size;
|
||||
|
||||
if (file.is_open())
|
||||
@@ -198,21 +196,21 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration,
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(16);
|
||||
std::cout << "Processing file " << filename_ << ", which contains " << static_cast<double>(size) << " [bytes]" << std::endl;
|
||||
std::cout.precision (ss);
|
||||
std::cout.precision(ss);
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
long bytes_to_skip = samples_to_skip*item_size_;
|
||||
long bytes_to_skip = samples_to_skip * item_size_;
|
||||
long bytes_to_process = static_cast<long>(size) - bytes_to_skip;
|
||||
samples_ = floor(static_cast<double>(bytes_to_process) / static_cast<double>(item_size()) - ceil(0.002 * static_cast<double>(sampling_frequency_))); //process all the samples available in the file excluding at least the last 1 ms
|
||||
samples_ = floor(static_cast<double>(bytes_to_process) / static_cast<double>(item_size()) - ceil(0.002 * static_cast<double>(sampling_frequency_))); //process all the samples available in the file excluding at least the last 1 ms
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(samples_ > 0) << "File does not contain enough samples to process.";
|
||||
double signal_duration_s;
|
||||
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_));
|
||||
|
||||
if( is_complex )
|
||||
if (is_complex)
|
||||
{
|
||||
signal_duration_s /= 2.0;
|
||||
}
|
||||
@@ -246,7 +244,8 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration,
|
||||
|
||||
|
||||
FileSignalSource::~FileSignalSource()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void FileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
|
||||
@@ -49,12 +49,12 @@ class ConfigurationInterface;
|
||||
* \brief Class that reads signals samples from a file
|
||||
* and adapts it to a SignalSourceInterface
|
||||
*/
|
||||
class FileSignalSource: public GNSSBlockInterface
|
||||
class FileSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
FileSignalSource(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~FileSignalSource();
|
||||
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
gr::blocks::file_source::sptr file_source_;
|
||||
boost::shared_ptr<gr::block> valve_;
|
||||
gr::blocks::file_sink::sptr sink_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
size_t item_size_;
|
||||
// Throttle control
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
using google::LogMessage;
|
||||
|
||||
FlexibandSignalSource::FlexibandSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
{
|
||||
std::string default_item_type = "byte";
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
@@ -48,12 +47,12 @@ FlexibandSignalSource::FlexibandSignalSource(ConfigurationInterface* configurati
|
||||
std::string default_firmware_file = "flexiband_I-1b.bit";
|
||||
firmware_filename_ = configuration->property(role + ".firmware_file", default_firmware_file);
|
||||
|
||||
gain1_ = configuration->property(role + ".gain1", 0); // check gain DAC values for Flexiband frontend!
|
||||
gain2_ = configuration->property(role + ".gain2", 0); // check gain DAC values for Flexiband frontend!
|
||||
gain3_ = configuration->property(role + ".gain3", 0); // check gain DAC values for Flexiband frontend!
|
||||
gain1_ = configuration->property(role + ".gain1", 0); // check gain DAC values for Flexiband frontend!
|
||||
gain2_ = configuration->property(role + ".gain2", 0); // check gain DAC values for Flexiband frontend!
|
||||
gain3_ = configuration->property(role + ".gain3", 0); // check gain DAC values for Flexiband frontend!
|
||||
|
||||
AGC_ = configuration->property(role + ".AGC", true); // enabled AGC by default
|
||||
flag_read_file = configuration->property(role + ".flag_read_file", false); //disable read samples from file by default
|
||||
AGC_ = configuration->property(role + ".AGC", true); // enabled AGC by default
|
||||
flag_read_file = configuration->property(role + ".flag_read_file", false); //disable read samples from file by default
|
||||
std::string default_signal_file = "flexiband_frame_samples.bin";
|
||||
signal_file = configuration->property(role + ".signal_file", default_signal_file);
|
||||
|
||||
@@ -89,10 +88,9 @@ FlexibandSignalSource::FlexibandSignalSource(ConfigurationInterface* configurati
|
||||
}
|
||||
|
||||
|
||||
|
||||
FlexibandSignalSource::~FlexibandSignalSource()
|
||||
{}
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void FlexibandSignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -111,7 +109,6 @@ void FlexibandSignalSource::connect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FlexibandSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
for (int n = 0; n < (RF_channels_ * 2); n++)
|
||||
@@ -144,4 +141,3 @@ gr::basic_block_sptr FlexibandSignalSource::get_right_block(int RF_channel)
|
||||
{
|
||||
return float_to_complex_.at(RF_channel);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,12 +49,12 @@ class ConfigurationInterface;
|
||||
* \brief This class configures and reads samples from Teleorbit Flexiband front-end.
|
||||
* This software requires a Flexiband GNU Radio driver installed (not included with GNSS-SDR).
|
||||
*/
|
||||
class FlexibandSignalSource: public GNSSBlockInterface
|
||||
class FlexibandSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
FlexibandSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, gr::msg_queue::sptr queue);
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, gr::msg_queue::sptr queue);
|
||||
|
||||
virtual ~FlexibandSignalSource();
|
||||
|
||||
|
||||
@@ -40,10 +40,8 @@
|
||||
using google::LogMessage;
|
||||
|
||||
Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream),
|
||||
queue_(queue)
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
{
|
||||
std::string default_item_type = "gr_complex";
|
||||
std::string default_dump_file = "./data/signal_source.dat";
|
||||
@@ -75,17 +73,17 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
|
||||
std::cout << "LO frequency : " << freq_ << " Hz" << std::endl;
|
||||
std::cout << "sample rate: " << sample_rate_ << " Hz" << std::endl;
|
||||
|
||||
if(item_type_.compare("gr_complex") == 0)
|
||||
if (item_type_.compare("gr_complex") == 0)
|
||||
{
|
||||
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
|
||||
uri_.c_str(), freq_, sample_rate_,
|
||||
bandwidth_,
|
||||
rx1_en_, rx2_en_,
|
||||
buffer_size_, quadrature_, rf_dc_,
|
||||
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
|
||||
gain_mode_rx2_.c_str(), rf_gain_rx2_,
|
||||
rf_port_select_.c_str(), filter_file_.c_str(),
|
||||
filter_auto_);
|
||||
uri_.c_str(), freq_, sample_rate_,
|
||||
bandwidth_,
|
||||
rx1_en_, rx2_en_,
|
||||
buffer_size_, quadrature_, rf_dc_,
|
||||
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
|
||||
gain_mode_rx2_.c_str(), rf_gain_rx2_,
|
||||
rf_port_select_.c_str(), filter_file_.c_str(),
|
||||
filter_auto_);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -109,7 +107,8 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
|
||||
|
||||
|
||||
Fmcomms2SignalSource::~Fmcomms2SignalSource()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Fmcomms2SignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -128,8 +127,7 @@ void Fmcomms2SignalSource::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
|
||||
top_block->connect(fmcomms2_source_f32c_ , 0, file_sink_, 0);
|
||||
top_block->connect(fmcomms2_source_f32c_, 0, file_sink_, 0);
|
||||
DLOG(INFO) << "connected fmcomms2 source to file sink";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
class Fmcomms2SignalSource: public GNSSBlockInterface
|
||||
class Fmcomms2SignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
Fmcomms2SignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~Fmcomms2SignalSource();
|
||||
|
||||
@@ -78,11 +78,11 @@ private:
|
||||
std::string role_;
|
||||
|
||||
// Front-end settings
|
||||
std::string uri_;//device direction
|
||||
unsigned long freq_; //frequency of local oscilator
|
||||
std::string uri_; //device direction
|
||||
unsigned long freq_; //frequency of local oscilator
|
||||
unsigned long sample_rate_;
|
||||
unsigned long bandwidth_;
|
||||
unsigned long buffer_size_; //reception buffer
|
||||
unsigned long buffer_size_; //reception buffer
|
||||
bool rx1_en_;
|
||||
bool rx2_en_;
|
||||
bool quadrature_;
|
||||
|
||||
@@ -42,11 +42,10 @@ using google::LogMessage;
|
||||
|
||||
// Constructor
|
||||
GenSignalSource::GenSignalSource(GNSSBlockInterface *signal_generator, GNSSBlockInterface *filter,
|
||||
std::string role, boost::shared_ptr<gr::msg_queue> queue) :
|
||||
signal_generator_(signal_generator),
|
||||
filter_(filter),
|
||||
role_(role),
|
||||
queue_(queue)
|
||||
std::string role, boost::shared_ptr<gr::msg_queue> queue) : signal_generator_(signal_generator),
|
||||
filter_(filter),
|
||||
role_(role),
|
||||
queue_(queue)
|
||||
{
|
||||
connected_ = false;
|
||||
}
|
||||
@@ -72,7 +71,7 @@ void GenSignalSource::connect(gr::top_block_sptr top_block)
|
||||
filter_->connect(top_block);
|
||||
|
||||
top_block->connect(signal_generator_->get_right_block(), 0,
|
||||
filter_->get_left_block(), 0);
|
||||
filter_->get_left_block(), 0);
|
||||
|
||||
DLOG(INFO) << "signal_generator -> filter";
|
||||
|
||||
@@ -89,7 +88,7 @@ void GenSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
top_block->disconnect(signal_generator_->get_right_block(), 0,
|
||||
filter_->get_left_block(), 0);
|
||||
filter_->get_left_block(), 0);
|
||||
|
||||
signal_generator_->disconnect(top_block);
|
||||
filter_->disconnect(top_block);
|
||||
@@ -108,4 +107,3 @@ gr::basic_block_sptr GenSignalSource::get_right_block()
|
||||
{
|
||||
return filter_->get_right_block();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,12 +42,12 @@
|
||||
* \brief This class wraps blocks that generates synthesized GNSS signal and
|
||||
* filters the signal.
|
||||
*/
|
||||
class GenSignalSource: public GNSSBlockInterface
|
||||
class GenSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
GenSignalSource(GNSSBlockInterface *signal_generator, GNSSBlockInterface *filter,
|
||||
std::string role, boost::shared_ptr<gr::msg_queue> queue);
|
||||
std::string role, boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
//! Virtual destructor
|
||||
virtual ~GenSignalSource();
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
using google::LogMessage;
|
||||
|
||||
Gn3sSignalSource::Gn3sSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
{
|
||||
std::string default_item_type = "short";
|
||||
std::string default_dump_file = "./data/gn3s_source.dat";
|
||||
@@ -54,7 +53,6 @@ Gn3sSignalSource::Gn3sSignalSource(ConfigurationInterface* configuration,
|
||||
gn3s_source_ = gn3s_make_source_cc();
|
||||
DLOG(INFO) << "Item size " << item_size_;
|
||||
DLOG(INFO) << "gn3s_source(" << gn3s_source_->unique_id() << ")";
|
||||
|
||||
}
|
||||
// else if (item_type_.compare("short") == 0)
|
||||
// {
|
||||
@@ -65,7 +63,7 @@ Gn3sSignalSource::Gn3sSignalSource(ConfigurationInterface* configuration,
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << item_type_
|
||||
<< " unrecognized item type for resampler";
|
||||
<< " unrecognized item type for resampler";
|
||||
item_size_ = sizeof(short);
|
||||
}
|
||||
if (dump_)
|
||||
@@ -80,10 +78,9 @@ Gn3sSignalSource::Gn3sSignalSource(ConfigurationInterface* configuration,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Gn3sSignalSource::~Gn3sSignalSource()
|
||||
{}
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Gn3sSignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -100,7 +97,6 @@ void Gn3sSignalSource::connect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Gn3sSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
|
||||
@@ -44,12 +44,12 @@ class ConfigurationInterface;
|
||||
/*!
|
||||
* \brief This class reads samples from a GN3S USB dongle, a RF front-end signal sampler
|
||||
*/
|
||||
class Gn3sSignalSource: public GNSSBlockInterface
|
||||
class Gn3sSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
Gn3sSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, gr::msg_queue::sptr queue);
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, gr::msg_queue::sptr queue);
|
||||
|
||||
virtual ~Gn3sSignalSource();
|
||||
|
||||
|
||||
@@ -34,12 +34,10 @@
|
||||
#include <glog/logging.h>
|
||||
|
||||
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
LabsatSignalSource::LabsatSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
{
|
||||
std::string default_item_type = "gr_complex";
|
||||
std::string default_dump_file = "./data/source.bin";
|
||||
@@ -56,7 +54,7 @@ LabsatSignalSource::LabsatSignalSource(ConfigurationInterface* configuration,
|
||||
if (item_type_.compare("gr_complex") == 0)
|
||||
{
|
||||
item_size_ = sizeof(gr_complex);
|
||||
labsat23_source_ = labsat23_make_source(filename_.c_str(),channel_selector);
|
||||
labsat23_source_ = labsat23_make_source(filename_.c_str(), channel_selector);
|
||||
DLOG(INFO) << "Item size " << item_size_;
|
||||
DLOG(INFO) << "labsat23_source_(" << labsat23_source_->unique_id() << ")";
|
||||
}
|
||||
@@ -77,10 +75,9 @@ LabsatSignalSource::LabsatSignalSource(ConfigurationInterface* configuration,
|
||||
}
|
||||
|
||||
|
||||
|
||||
LabsatSignalSource::~LabsatSignalSource()
|
||||
{}
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LabsatSignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -97,7 +94,6 @@ void LabsatSignalSource::connect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LabsatSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
|
||||
@@ -43,12 +43,12 @@ class ConfigurationInterface;
|
||||
/*!
|
||||
* \brief This class reads samples stored by a LabSat 2 or LabSat 3 device
|
||||
*/
|
||||
class LabsatSignalSource: public GNSSBlockInterface
|
||||
class LabsatSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
LabsatSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, gr::msg_queue::sptr queue);
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, gr::msg_queue::sptr queue);
|
||||
|
||||
virtual ~LabsatSignalSource();
|
||||
|
||||
|
||||
@@ -45,9 +45,8 @@ using google::LogMessage;
|
||||
|
||||
|
||||
NsrFileSignalSource::NsrFileSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
{
|
||||
std::string default_filename = "../data/my_capture.dat";
|
||||
std::string default_item_type = "byte";
|
||||
@@ -58,8 +57,8 @@ NsrFileSignalSource::NsrFileSignalSource(ConfigurationInterface* configuration,
|
||||
filename_ = configuration->property(role + ".filename", default_filename);
|
||||
|
||||
// override value with commandline flag, if present
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_= FLAGS_signal_source;
|
||||
if (FLAGS_s.compare("-") != 0) filename_= FLAGS_s;
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_ = FLAGS_signal_source;
|
||||
if (FLAGS_s.compare("-") != 0) filename_ = FLAGS_s;
|
||||
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
repeat_ = configuration->property(role + ".repeat", false);
|
||||
@@ -73,48 +72,47 @@ NsrFileSignalSource::NsrFileSignalSource(ConfigurationInterface* configuration,
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << item_type_ << " unrecognized item type. Using byte.";
|
||||
LOG(WARNING) << item_type_ << " unrecognized item type. Using byte.";
|
||||
item_size_ = sizeof(char);
|
||||
}
|
||||
try
|
||||
{
|
||||
{
|
||||
file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_);
|
||||
unpack_byte_ = make_unpack_byte_2bit_samples();
|
||||
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
|
||||
LOG(WARNING) << "file_signal_source: Unable to open the samples file "
|
||||
<< filename_.c_str() << ", exiting the program.";
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
|
||||
DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")";
|
||||
|
||||
if (samples_ == 0) // read all file
|
||||
if (samples_ == 0) // read all file
|
||||
{
|
||||
/*!
|
||||
* BUG workaround: The GNU Radio 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 2 milliseconds, and enable always the
|
||||
* valve block
|
||||
*/
|
||||
std::ifstream file (filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
||||
std::ifstream file(filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
||||
std::ifstream::pos_type size;
|
||||
|
||||
if (file.is_open())
|
||||
@@ -130,19 +128,19 @@ NsrFileSignalSource::NsrFileSignalSource(ConfigurationInterface* configuration,
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(16);
|
||||
std::cout << "Processing file " << filename_ << ", which contains " << size << " [bytes]" << std::endl;
|
||||
std::cout.precision (ss);
|
||||
std::cout.precision(ss);
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
int sample_packet_factor = 4; // 1 byte -> 4 samples
|
||||
int sample_packet_factor = 4; // 1 byte -> 4 samples
|
||||
samples_ = floor(static_cast<double>(size) / static_cast<double>(item_size())) * sample_packet_factor;
|
||||
samples_ = samples_- ceil(0.002 * static_cast<double>(sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms
|
||||
samples_ = samples_ - ceil(0.002 * static_cast<double>(sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(samples_ > 0) << "File does not contain enough samples to process.";
|
||||
double signal_duration_s;
|
||||
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]";
|
||||
std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl;
|
||||
|
||||
@@ -171,12 +169,9 @@ NsrFileSignalSource::NsrFileSignalSource(ConfigurationInterface* configuration,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
NsrFileSignalSource::~NsrFileSignalSource()
|
||||
{}
|
||||
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NsrFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -186,7 +181,7 @@ void NsrFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->connect(file_source_, 0, unpack_byte_, 0);
|
||||
top_block->connect(unpack_byte_, 0,throttle_,0);
|
||||
top_block->connect(unpack_byte_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "connected file source to throttle";
|
||||
top_block->connect(throttle_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected throttle to valve";
|
||||
@@ -199,7 +194,7 @@ void NsrFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
else
|
||||
{
|
||||
top_block->connect(file_source_, 0, unpack_byte_, 0);
|
||||
top_block->connect(unpack_byte_, 0,valve_,0);
|
||||
top_block->connect(unpack_byte_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected file source to valve";
|
||||
if (dump_)
|
||||
{
|
||||
@@ -213,7 +208,7 @@ void NsrFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->connect(file_source_, 0, unpack_byte_, 0);
|
||||
top_block->connect(unpack_byte_, 0,throttle_,0);
|
||||
top_block->connect(unpack_byte_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "connected file source to throttle";
|
||||
if (dump_)
|
||||
{
|
||||
@@ -234,10 +229,6 @@ void NsrFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void NsrFileSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (samples_ > 0)
|
||||
@@ -246,7 +237,7 @@ void NsrFileSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, unpack_byte_, 0);
|
||||
DLOG(INFO) << "disconnected file source to unpack_byte_";
|
||||
top_block->connect(unpack_byte_, 0,throttle_,0);
|
||||
top_block->connect(unpack_byte_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "disconnected unpack_byte_ to throttle_";
|
||||
top_block->disconnect(throttle_, 0, valve_, 0);
|
||||
DLOG(INFO) << "disconnected throttle to valve";
|
||||
@@ -297,9 +288,6 @@ void NsrFileSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr NsrFileSignalSource::get_left_block()
|
||||
{
|
||||
LOG(WARNING) << "Left block of a signal source should not be retrieved";
|
||||
@@ -308,9 +296,6 @@ gr::basic_block_sptr NsrFileSignalSource::get_left_block()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr NsrFileSignalSource::get_right_block()
|
||||
{
|
||||
if (samples_ > 0)
|
||||
|
||||
@@ -50,12 +50,12 @@ class ConfigurationInterface;
|
||||
* \brief Class that reads signals samples from a file
|
||||
* and adapts it to a SignalSourceInterface
|
||||
*/
|
||||
class NsrFileSignalSource: public GNSSBlockInterface
|
||||
class NsrFileSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
NsrFileSignalSource(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~NsrFileSignalSource();
|
||||
inline std::string role() override
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
unpack_byte_2bit_samples_sptr unpack_byte_;
|
||||
boost::shared_ptr<gr::block> valve_;
|
||||
gr::blocks::file_sink::sptr sink_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
size_t item_size_;
|
||||
// Throttle control
|
||||
|
||||
@@ -39,15 +39,12 @@
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
|
||||
OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream),
|
||||
queue_(queue)
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
{
|
||||
// DUMP PARAMETERS
|
||||
std::string empty = "";
|
||||
@@ -56,7 +53,7 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration,
|
||||
samples_ = configuration->property(role + ".samples", 0);
|
||||
dump_ = configuration->property(role + ".dump", false);
|
||||
dump_filename_ = configuration->property(role + ".dump_filename",
|
||||
default_dump_file);
|
||||
default_dump_file);
|
||||
|
||||
// OSMOSDR Driver parameters
|
||||
AGC_enabled_ = configuration->property(role + ".AGC_enabled", true);
|
||||
@@ -66,7 +63,7 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration,
|
||||
if_gain_ = configuration->property(role + ".if_gain", 40.0);
|
||||
sample_rate_ = configuration->property(role + ".sampling_frequency", 2.0e6);
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
osmosdr_args_ = configuration->property(role + ".osmosdr_args", std::string( ));
|
||||
osmosdr_args_ = configuration->property(role + ".osmosdr_args", std::string());
|
||||
antenna_ = configuration->property(role + ".antenna", empty);
|
||||
|
||||
if (item_type_.compare("short") == 0)
|
||||
@@ -83,23 +80,23 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration,
|
||||
if (!antenna_.empty())
|
||||
{
|
||||
osmosdr_source_->set_antenna(antenna_, 0);
|
||||
std::cout << boost::format("Set RX Antenna : %s") % (osmosdr_source_->get_antenna(0)) << std::endl ;
|
||||
std::cout << boost::format("Set RX Antenna : %s") % (osmosdr_source_->get_antenna(0)) << std::endl;
|
||||
LOG(INFO) << boost::format("Set RX Antenna : %s") % (osmosdr_source_->get_antenna(0));
|
||||
}
|
||||
|
||||
// 2 set sampling rate
|
||||
osmosdr_source_->set_sample_rate(sample_rate_);
|
||||
std::cout << boost::format("Actual RX Rate: %f [SPS]...") % (osmosdr_source_->get_sample_rate()) << std::endl ;
|
||||
std::cout << boost::format("Actual RX Rate: %f [SPS]...") % (osmosdr_source_->get_sample_rate()) << std::endl;
|
||||
LOG(INFO) << boost::format("Actual RX Rate: %f [SPS]...") % (osmosdr_source_->get_sample_rate());
|
||||
|
||||
// 3. set rx frequency
|
||||
osmosdr_source_->set_center_freq(freq_);
|
||||
std::cout << boost::format("Actual RX Freq: %f [Hz]...") % (osmosdr_source_->get_center_freq()) << std::endl ;
|
||||
std::cout << boost::format("Actual RX Freq: %f [Hz]...") % (osmosdr_source_->get_center_freq()) << std::endl;
|
||||
LOG(INFO) << boost::format("Actual RX Freq: %f [Hz]...") % (osmosdr_source_->get_center_freq());
|
||||
|
||||
// TODO: Assign the remnant IF from the PLL tune error
|
||||
std::cout << boost::format("PLL Frequency tune error %f [Hz]...") % (osmosdr_source_->get_center_freq() - freq_) << std::endl;
|
||||
LOG(INFO) << boost::format("PLL Frequency tune error %f [Hz]...") % (osmosdr_source_->get_center_freq() - freq_) ;
|
||||
LOG(INFO) << boost::format("PLL Frequency tune error %f [Hz]...") % (osmosdr_source_->get_center_freq() - freq_);
|
||||
|
||||
// 4. set rx gain
|
||||
if (this->AGC_enabled_ == true)
|
||||
@@ -116,10 +113,9 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration,
|
||||
osmosdr_source_->set_bb_gain(if_gain_, 0);
|
||||
if (!osmosdr_args_.empty() && (osmosdr_args_.find("bladerf") != std::string::npos))
|
||||
{
|
||||
std::cout << boost::format("Actual LNA Gain: %f dB...") % osmosdr_source_->get_gain("LNA",0) << std::endl;
|
||||
std::cout << boost::format("Actual VGA1 Gain: %f dB...") % osmosdr_source_->get_gain("VGA1",0) << std::endl;
|
||||
std::cout << boost::format("Actual VGA2 Gain: %f dB...") % osmosdr_source_->get_gain("VGA2",0) << std::endl;
|
||||
|
||||
std::cout << boost::format("Actual LNA Gain: %f dB...") % osmosdr_source_->get_gain("LNA", 0) << std::endl;
|
||||
std::cout << boost::format("Actual VGA1 Gain: %f dB...") % osmosdr_source_->get_gain("VGA1", 0) << std::endl;
|
||||
std::cout << boost::format("Actual VGA2 Gain: %f dB...") % osmosdr_source_->get_gain("VGA2", 0) << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -127,7 +123,7 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration,
|
||||
LOG(INFO) << boost::format("Actual RX Gain: %f dB...") % osmosdr_source_->get_gain();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get actual bandwidth
|
||||
std::cout << boost::format("Actual Bandwidth: %f [Hz]...") % osmosdr_source_->get_bandwidth(0) << std::endl;
|
||||
}
|
||||
@@ -153,27 +149,27 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration,
|
||||
}
|
||||
|
||||
|
||||
|
||||
OsmosdrSignalSource::~OsmosdrSignalSource()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void OsmosdrSignalSource::driver_instance()
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
if (!osmosdr_args_.empty())
|
||||
{
|
||||
std::cout << "OsmoSdr arguments: " << osmosdr_args_ << std::endl;
|
||||
LOG(INFO) << "OsmoSdr arguments: " << osmosdr_args_;
|
||||
}
|
||||
osmosdr_source_ = osmosdr::source::make(osmosdr_args_);
|
||||
}
|
||||
catch( const boost::exception & e )
|
||||
{
|
||||
}
|
||||
catch (const boost::exception& e)
|
||||
{
|
||||
LOG(WARNING) << "Boost exception: " << boost::diagnostic_information(e);
|
||||
throw std::invalid_argument( "Wrong OsmoSdr arguments" );
|
||||
}
|
||||
throw std::invalid_argument("Wrong OsmoSdr arguments");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +196,6 @@ void OsmosdrSignalSource::connect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OsmosdrSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (samples_ != 0)
|
||||
@@ -221,7 +216,6 @@ void OsmosdrSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr OsmosdrSignalSource::get_left_block()
|
||||
{
|
||||
LOG(WARNING) << "Trying to get signal source left block.";
|
||||
@@ -229,7 +223,6 @@ gr::basic_block_sptr OsmosdrSignalSource::get_left_block()
|
||||
}
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr OsmosdrSignalSource::get_right_block()
|
||||
{
|
||||
if (samples_ != 0)
|
||||
|
||||
@@ -48,12 +48,12 @@ class ConfigurationInterface;
|
||||
* HackRF or Realtek's RTL2832U-based USB dongle DVB-T receivers
|
||||
* (see http://sdr.osmocom.org/trac/wiki/rtl-sdr)
|
||||
*/
|
||||
class OsmosdrSignalSource: public GNSSBlockInterface
|
||||
class OsmosdrSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
OsmosdrSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~OsmosdrSignalSource();
|
||||
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
|
||||
osmosdr::source::sptr osmosdr_source_;
|
||||
std::string osmosdr_args_;
|
||||
|
||||
|
||||
std::string antenna_;
|
||||
|
||||
boost::shared_ptr<gr::block> valve_;
|
||||
|
||||
@@ -40,10 +40,8 @@ using google::LogMessage;
|
||||
|
||||
|
||||
PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream),
|
||||
queue_(queue)
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
{
|
||||
std::string default_item_type = "gr_complex";
|
||||
std::string default_dump_file = "./data/signal_source.dat";
|
||||
@@ -65,7 +63,7 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
|
||||
dump_ = configuration->property(role + ".dump", false);
|
||||
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
|
||||
|
||||
if(item_type_.compare("gr_complex") != 0)
|
||||
if (item_type_.compare("gr_complex") != 0)
|
||||
{
|
||||
std::cout << "Configuration error: item_type must be gr_complex" << std::endl;
|
||||
LOG(FATAL) << "Configuration error: item_type must be gr_complex!";
|
||||
@@ -80,8 +78,8 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
|
||||
std::cout << "item type: " << item_type_ << std::endl;
|
||||
|
||||
plutosdr_source_ = gr::iio::pluto_source::make(uri_, freq_, sample_rate_,
|
||||
bandwidth_, buffer_size_, quadrature_, rf_dc_, bb_dc_,
|
||||
gain_mode_.c_str(), rf_gain_,filter_file_.c_str(), filter_auto_);
|
||||
bandwidth_, buffer_size_, quadrature_, rf_dc_, bb_dc_,
|
||||
gain_mode_.c_str(), rf_gain_, filter_file_.c_str(), filter_auto_);
|
||||
|
||||
if (samples_ != 0)
|
||||
{
|
||||
@@ -100,7 +98,8 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
|
||||
|
||||
|
||||
PlutosdrSignalSource::~PlutosdrSignalSource()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PlutosdrSignalSource::connect(gr::top_block_sptr top_block)
|
||||
|
||||
@@ -44,12 +44,12 @@ class ConfigurationInterface;
|
||||
|
||||
/*!
|
||||
*/
|
||||
class PlutosdrSignalSource: public GNSSBlockInterface
|
||||
class PlutosdrSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
PlutosdrSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~PlutosdrSignalSource();
|
||||
|
||||
@@ -79,11 +79,11 @@ private:
|
||||
std::string role_;
|
||||
|
||||
// Front-end settings
|
||||
std::string uri_; // device direction
|
||||
unsigned long freq_; // frequency of local oscilator
|
||||
std::string uri_; // device direction
|
||||
unsigned long freq_; // frequency of local oscilator
|
||||
unsigned long sample_rate_;
|
||||
unsigned long bandwidth_;
|
||||
unsigned long buffer_size_; // reception buffer
|
||||
unsigned long buffer_size_; // reception buffer
|
||||
bool quadrature_;
|
||||
bool rf_dc_;
|
||||
bool bb_dc_;
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
using google::LogMessage;
|
||||
|
||||
RawArraySignalSource::RawArraySignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream, gr::msg_queue::sptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
{
|
||||
std::string default_item_type = "gr_complex";
|
||||
std::string default_dump_file = "./data/raw_array_source.dat";
|
||||
@@ -70,10 +69,9 @@ RawArraySignalSource::RawArraySignalSource(ConfigurationInterface* configuration
|
||||
if (item_type_.compare("gr_complex") == 0)
|
||||
{
|
||||
item_size_ = sizeof(gr_complex);
|
||||
raw_array_source_ = gr::dbfcttc::raw_array::make(eth_device_.c_str(),channels_,snapshots_per_frame_,inter_frame_delay_,sampling_freq_);
|
||||
raw_array_source_ = gr::dbfcttc::raw_array::make(eth_device_.c_str(), channels_, snapshots_per_frame_, inter_frame_delay_, sampling_freq_);
|
||||
DLOG(INFO) << "Item size " << item_size_;
|
||||
DLOG(INFO) << "raw_array_source(" << raw_array_source_->unique_id() << ")";
|
||||
|
||||
}
|
||||
// else if (item_type_.compare("short") == 0)
|
||||
// {
|
||||
@@ -99,10 +97,9 @@ RawArraySignalSource::RawArraySignalSource(ConfigurationInterface* configuration
|
||||
}
|
||||
|
||||
|
||||
|
||||
RawArraySignalSource::~RawArraySignalSource()
|
||||
{}
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RawArraySignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -120,7 +117,6 @@ void RawArraySignalSource::connect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RawArraySignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
|
||||
@@ -43,12 +43,12 @@ class ConfigurationInterface;
|
||||
/*!
|
||||
* \brief This class reads samples from a GN3S USB dongle, a RF front-end signal sampler
|
||||
*/
|
||||
class RawArraySignalSource: public GNSSBlockInterface
|
||||
class RawArraySignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
RawArraySignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, gr::msg_queue::sptr queue);
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, gr::msg_queue::sptr queue);
|
||||
|
||||
virtual ~RawArraySignalSource();
|
||||
|
||||
|
||||
@@ -43,10 +43,8 @@ using google::LogMessage;
|
||||
|
||||
|
||||
RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream),
|
||||
queue_(queue)
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
{
|
||||
// DUMP PARAMETERS
|
||||
std::string empty = "";
|
||||
@@ -55,7 +53,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration,
|
||||
samples_ = configuration->property(role + ".samples", 0);
|
||||
dump_ = configuration->property(role + ".dump", false);
|
||||
dump_filename_ = configuration->property(role + ".dump_filename",
|
||||
default_dump_file);
|
||||
default_dump_file);
|
||||
|
||||
// rtl_tcp PARAMTERS
|
||||
std::string default_address = "127.0.0.1";
|
||||
@@ -134,38 +132,39 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration,
|
||||
|
||||
|
||||
RtlTcpSignalSource::~RtlTcpSignalSource()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RtlTcpSignalSource::MakeBlock()
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
std::cout << "Connecting to " << address_ << ":" << port_ << std::endl;
|
||||
LOG (INFO) << "Connecting to " << address_ << ":" << port_;
|
||||
signal_source_ = rtl_tcp_make_signal_source_c (address_, port_, flip_iq_);
|
||||
}
|
||||
catch( const boost::exception & e )
|
||||
{
|
||||
LOG(INFO) << "Connecting to " << address_ << ":" << port_;
|
||||
signal_source_ = rtl_tcp_make_signal_source_c(address_, port_, flip_iq_);
|
||||
}
|
||||
catch (const boost::exception& e)
|
||||
{
|
||||
LOG(WARNING) << "Boost exception: " << boost::diagnostic_information(e);
|
||||
throw std::runtime_error( "Failure connecting to the device" );
|
||||
}
|
||||
throw std::runtime_error("Failure connecting to the device");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RtlTcpSignalSource::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if ( samples_ )
|
||||
if (samples_)
|
||||
{
|
||||
top_block->connect (signal_source_, 0, valve_, 0);
|
||||
top_block->connect(signal_source_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected rtl tcp source to valve";
|
||||
if ( dump_ )
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(valve_, 0, file_sink_, 0);
|
||||
DLOG(INFO) << "connected valve to file sink";
|
||||
}
|
||||
}
|
||||
else if ( dump_ )
|
||||
else if (dump_)
|
||||
{
|
||||
top_block->connect(signal_source_, 0, file_sink_, 0);
|
||||
DLOG(INFO) << "connected rtl tcp source to file sink";
|
||||
@@ -175,15 +174,15 @@ void RtlTcpSignalSource::connect(gr::top_block_sptr top_block)
|
||||
|
||||
void RtlTcpSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if ( samples_ )
|
||||
if (samples_)
|
||||
{
|
||||
top_block->disconnect (signal_source_, 0, valve_, 0);
|
||||
if ( dump_ )
|
||||
top_block->disconnect(signal_source_, 0, valve_, 0);
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(valve_, 0, file_sink_, 0);
|
||||
}
|
||||
}
|
||||
else if ( dump_ )
|
||||
else if (dump_)
|
||||
{
|
||||
top_block->disconnect(signal_source_, 0, file_sink_, 0);
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@ class ConfigurationInterface;
|
||||
* I/Q samples over TCP.
|
||||
* (see http://sdr.osmocom.org/trac/wiki/rtl-sdr)
|
||||
*/
|
||||
class RtlTcpSignalSource: public GNSSBlockInterface
|
||||
class RtlTcpSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
RtlTcpSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~RtlTcpSignalSource();
|
||||
|
||||
|
||||
@@ -44,9 +44,8 @@ using google::LogMessage;
|
||||
|
||||
|
||||
SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
{
|
||||
std::string default_filename = "../data/my_capture.dat";
|
||||
std::string default_item_type = "int";
|
||||
@@ -57,8 +56,8 @@ SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration
|
||||
filename_ = configuration->property(role + ".filename", default_filename);
|
||||
|
||||
// override value with commandline flag, if present
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_= FLAGS_signal_source;
|
||||
if (FLAGS_s.compare("-") != 0) filename_= FLAGS_s;
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_ = FLAGS_signal_source;
|
||||
if (FLAGS_s.compare("-") != 0) filename_ = FLAGS_s;
|
||||
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
repeat_ = configuration->property(role + ".repeat", false);
|
||||
@@ -72,48 +71,47 @@ SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << item_type_ << " unrecognized item type. Using int.";
|
||||
LOG(WARNING) << item_type_ << " unrecognized item type. Using int.";
|
||||
item_size_ = sizeof(int);
|
||||
}
|
||||
try
|
||||
{
|
||||
{
|
||||
file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_);
|
||||
unpack_intspir_ = make_unpack_intspir_1bit_samples();
|
||||
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
|
||||
LOG(WARNING) << "file_signal_source: Unable to open the samples file "
|
||||
<< filename_.c_str() << ", exiting the program.";
|
||||
<< filename_.c_str() << ", exiting the program.";
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
|
||||
DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")";
|
||||
|
||||
if (samples_ == 0) // read all file
|
||||
if (samples_ == 0) // read all file
|
||||
{
|
||||
/*!
|
||||
* BUG workaround: The GNU Radio 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 file(filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
||||
std::ifstream::pos_type size;
|
||||
|
||||
if (file.is_open())
|
||||
@@ -129,19 +127,19 @@ SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(16);
|
||||
std::cout << "Processing file " << filename_ << ", which contains " << size << " [bytes]" << std::endl;
|
||||
std::cout.precision (ss);
|
||||
std::cout.precision(ss);
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
int sample_packet_factor = 1; // 1 int -> 1 complex sample (I&Q from 1 channel)
|
||||
int sample_packet_factor = 1; // 1 int -> 1 complex sample (I&Q from 1 channel)
|
||||
samples_ = floor(static_cast<double>(size) / static_cast<double>(item_size())) * sample_packet_factor;
|
||||
samples_ = samples_- ceil(0.002 * static_cast<double>(sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms
|
||||
samples_ = samples_ - ceil(0.002 * static_cast<double>(sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(samples_ > 0) << "File does not contain enough samples to process.";
|
||||
double signal_duration_s;
|
||||
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]";
|
||||
std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl;
|
||||
|
||||
@@ -170,12 +168,9 @@ SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SpirFileSignalSource::~SpirFileSignalSource()
|
||||
{}
|
||||
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SpirFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -185,7 +180,7 @@ void SpirFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->connect(file_source_, 0, unpack_intspir_, 0);
|
||||
top_block->connect(unpack_intspir_, 0,throttle_,0);
|
||||
top_block->connect(unpack_intspir_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "connected file source to throttle";
|
||||
top_block->connect(throttle_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected throttle to valve";
|
||||
@@ -198,7 +193,7 @@ void SpirFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
else
|
||||
{
|
||||
top_block->connect(file_source_, 0, unpack_intspir_, 0);
|
||||
top_block->connect(unpack_intspir_, 0,valve_,0);
|
||||
top_block->connect(unpack_intspir_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected file source to valve";
|
||||
if (dump_)
|
||||
{
|
||||
@@ -212,7 +207,7 @@ void SpirFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->connect(file_source_, 0, unpack_intspir_, 0);
|
||||
top_block->connect(unpack_intspir_, 0,throttle_,0);
|
||||
top_block->connect(unpack_intspir_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "connected file source to throttle";
|
||||
if (dump_)
|
||||
{
|
||||
@@ -233,10 +228,6 @@ void SpirFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void SpirFileSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (samples_ > 0)
|
||||
@@ -245,7 +236,7 @@ void SpirFileSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, unpack_intspir_, 0);
|
||||
DLOG(INFO) << "disconnected file source to unpack_intspir_";
|
||||
top_block->connect(unpack_intspir_, 0,throttle_,0);
|
||||
top_block->connect(unpack_intspir_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "disconnected unpack_intspir_ to throttle_";
|
||||
top_block->disconnect(throttle_, 0, valve_, 0);
|
||||
DLOG(INFO) << "disconnected throttle to valve";
|
||||
@@ -296,9 +287,6 @@ void SpirFileSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr SpirFileSignalSource::get_left_block()
|
||||
{
|
||||
LOG(WARNING) << "Left block of a signal source should not be retrieved";
|
||||
@@ -307,9 +295,6 @@ gr::basic_block_sptr SpirFileSignalSource::get_left_block()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr SpirFileSignalSource::get_right_block()
|
||||
{
|
||||
if (samples_ > 0)
|
||||
|
||||
@@ -47,12 +47,12 @@ class ConfigurationInterface;
|
||||
* \brief Class that reads signals samples from a file
|
||||
* and adapts it to a SignalSourceInterface
|
||||
*/
|
||||
class SpirFileSignalSource: public GNSSBlockInterface
|
||||
class SpirFileSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
SpirFileSignalSource(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~SpirFileSignalSource();
|
||||
inline std::string role() override
|
||||
@@ -118,7 +118,7 @@ private:
|
||||
unpack_intspir_1bit_samples_sptr unpack_intspir_;
|
||||
boost::shared_ptr<gr::block> valve_;
|
||||
gr::blocks::file_sink::sptr sink_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
size_t item_size_;
|
||||
// Throttle control
|
||||
|
||||
@@ -42,8 +42,7 @@ using google::LogMessage;
|
||||
|
||||
|
||||
SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(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)
|
||||
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)
|
||||
{
|
||||
std::string default_filename = "../data/my_capture.dat";
|
||||
std::string default_dump_filename = "../data/my_capture_dump.dat";
|
||||
@@ -64,54 +63,57 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface*
|
||||
long bytes_seek = configuration->property(role + ".bytes_to_skip", 65536);
|
||||
double sample_size_byte = static_cast<double>(adc_bits_) / 4.0;
|
||||
|
||||
if(sel_ch_ > n_channels_) { LOG(WARNING) << "Invalid RF channel selection"; }
|
||||
if(n_channels_ > 1)
|
||||
{
|
||||
for(unsigned int i = 0; i < (n_channels_ - 1); i++)
|
||||
if (sel_ch_ > n_channels_)
|
||||
{
|
||||
null_sinks_.push_back(gr::blocks::null_sink::make(item_size_));
|
||||
LOG(WARNING) << "Invalid RF channel selection";
|
||||
}
|
||||
if (n_channels_ > 1)
|
||||
{
|
||||
for (unsigned int i = 0; i < (n_channels_ - 1); i++)
|
||||
{
|
||||
null_sinks_.push_back(gr::blocks::null_sink::make(item_size_));
|
||||
}
|
||||
DLOG(INFO) << "NUMBER OF NULL SINKS = " << null_sinks_.size();
|
||||
}
|
||||
DLOG(INFO)<< "NUMBER OF NULL SINKS = " << null_sinks_.size();
|
||||
}
|
||||
try
|
||||
{
|
||||
file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_);
|
||||
file_source_->seek(bytes_seek / item_size_, SEEK_SET);
|
||||
unpack_spir_ = make_unpack_spir_gss6450_samples(adc_bits_);
|
||||
deint_ = gr::blocks::deinterleave::make(item_size_);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
{
|
||||
file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_);
|
||||
file_source_->seek(bytes_seek / item_size_, SEEK_SET);
|
||||
unpack_spir_ = make_unpack_spir_gss6450_samples(adc_bits_);
|
||||
deint_ = gr::blocks::deinterleave::make(item_size_);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
|
||||
LOG(WARNING) << "file_signal_source: Unable to open the samples file "
|
||||
<< filename_.c_str() << ", exiting the program.";
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")";
|
||||
|
||||
if(samples_ == 0) // read all file
|
||||
if (samples_ == 0) // read all file
|
||||
{
|
||||
/*!
|
||||
* BUG workaround: The GNU Radio 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 2 milliseconds, and enable always the
|
||||
* valve block
|
||||
*/
|
||||
std::ifstream file (filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
||||
std::ifstream file(filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
||||
std::ifstream::pos_type size;
|
||||
|
||||
if (file.is_open())
|
||||
@@ -127,12 +129,12 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface*
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(16);
|
||||
std::cout << "Processing file " << filename_ << ", which contains " << size << " [bytes]" << std::endl;
|
||||
std::cout.precision (ss);
|
||||
std::cout.precision(ss);
|
||||
|
||||
if(size > 0)
|
||||
if (size > 0)
|
||||
{
|
||||
samples_ = static_cast<unsigned long long>(floor(static_cast<double>(static_cast<long>(size) - static_cast<long>(bytes_seek)) / (sample_size_byte * static_cast<double>(n_channels_))));
|
||||
samples_ = samples_- static_cast<unsigned long long>(ceil(0.002 * sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms
|
||||
samples_ = samples_ - static_cast<unsigned long long>(ceil(0.002 * sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +171,8 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface*
|
||||
|
||||
|
||||
SpirGSS6450FileSignalSource::~SpirGSS6450FileSignalSource()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SpirGSS6450FileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -177,27 +180,27 @@ void SpirGSS6450FileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
if (samples_ > 0)
|
||||
{
|
||||
top_block->connect(file_source_, 0, deint_, 0);
|
||||
if(endian_swap_)
|
||||
{
|
||||
top_block->connect(deint_, sel_ch_ - 1, endian_ ,0);
|
||||
top_block->connect(endian_, 0, unpack_spir_, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->connect(deint_, sel_ch_ - 1, unpack_spir_, 0);
|
||||
}
|
||||
if(n_channels_ > 1)
|
||||
{
|
||||
unsigned int aux = 0;
|
||||
for(unsigned int i = 0; i < n_channels_; i++)
|
||||
if (endian_swap_)
|
||||
{
|
||||
if(i != (sel_ch_ - 1))
|
||||
{
|
||||
top_block->connect(deint_, i, null_sinks_.at(aux), 0);
|
||||
aux++;
|
||||
}
|
||||
top_block->connect(deint_, sel_ch_ - 1, endian_, 0);
|
||||
top_block->connect(endian_, 0, unpack_spir_, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->connect(deint_, sel_ch_ - 1, unpack_spir_, 0);
|
||||
}
|
||||
if (n_channels_ > 1)
|
||||
{
|
||||
unsigned int aux = 0;
|
||||
for (unsigned int i = 0; i < n_channels_; i++)
|
||||
{
|
||||
if (i != (sel_ch_ - 1))
|
||||
{
|
||||
top_block->connect(deint_, i, null_sinks_.at(aux), 0);
|
||||
aux++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enable_throttle_control_)
|
||||
{
|
||||
top_block->connect(unpack_spir_, 0, throttle_, 0);
|
||||
@@ -207,7 +210,7 @@ void SpirGSS6450FileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
top_block->connect(unpack_spir_, 0, valve_, 0);
|
||||
}
|
||||
if(dump_)
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(valve_, 0, sink_, 0);
|
||||
}
|
||||
@@ -222,47 +225,47 @@ void SpirGSS6450FileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
void SpirGSS6450FileSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (samples_ > 0)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, deint_, 0);
|
||||
if(endian_swap_)
|
||||
{
|
||||
top_block->disconnect(deint_, sel_ch_ - 1, endian_ ,0);
|
||||
top_block->disconnect(endian_, 0, unpack_spir_, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->disconnect(deint_, sel_ch_ - 1, unpack_spir_, 0);
|
||||
}
|
||||
if(n_channels_ > 1)
|
||||
{
|
||||
unsigned int aux = 0;
|
||||
for(unsigned int i = 0; i < n_channels_; i++)
|
||||
{
|
||||
if(i != (sel_ch_ - 1))
|
||||
top_block->disconnect(file_source_, 0, deint_, 0);
|
||||
if (endian_swap_)
|
||||
{
|
||||
top_block->disconnect(deint_, i, null_sinks_.at(aux), 0);
|
||||
aux++;
|
||||
top_block->disconnect(deint_, sel_ch_ - 1, endian_, 0);
|
||||
top_block->disconnect(endian_, 0, unpack_spir_, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->disconnect(deint_, sel_ch_ - 1, unpack_spir_, 0);
|
||||
}
|
||||
if (n_channels_ > 1)
|
||||
{
|
||||
unsigned int aux = 0;
|
||||
for (unsigned int i = 0; i < n_channels_; i++)
|
||||
{
|
||||
if (i != (sel_ch_ - 1))
|
||||
{
|
||||
top_block->disconnect(deint_, i, null_sinks_.at(aux), 0);
|
||||
aux++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enable_throttle_control_)
|
||||
{
|
||||
top_block->disconnect(unpack_spir_, 0, throttle_, 0);
|
||||
top_block->disconnect(throttle_, 0, valve_, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->disconnect(unpack_spir_, 0, valve_, 0);
|
||||
}
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(valve_, 0, sink_, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enable_throttle_control_)
|
||||
{
|
||||
top_block->disconnect(unpack_spir_, 0, throttle_, 0);
|
||||
top_block->disconnect(throttle_, 0, valve_, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->disconnect(unpack_spir_, 0, valve_, 0);
|
||||
}
|
||||
if(dump_)
|
||||
{
|
||||
top_block->disconnect(valve_, 0, sink_, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << "Nothing to disconnect";
|
||||
}
|
||||
{
|
||||
LOG(WARNING) << "Nothing to disconnect";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -275,10 +278,19 @@ gr::basic_block_sptr SpirGSS6450FileSignalSource::get_left_block()
|
||||
|
||||
gr::basic_block_sptr SpirGSS6450FileSignalSource::get_right_block()
|
||||
{
|
||||
if(samples_ > 0) { return valve_; }
|
||||
if (samples_ > 0)
|
||||
{
|
||||
return valve_;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(enable_throttle_control_) { return throttle_; }
|
||||
else { return unpack_spir_; }
|
||||
if (enable_throttle_control_)
|
||||
{
|
||||
return throttle_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return unpack_spir_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ class ConfigurationInterface;
|
||||
* \brief Class that reads signals samples from a file
|
||||
* and adapts it to a SignalSourceInterface
|
||||
*/
|
||||
class SpirGSS6450FileSignalSource: public GNSSBlockInterface
|
||||
class SpirGSS6450FileSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
SpirGSS6450FileSignalSource(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams, gr::msg_queue::sptr queue);
|
||||
unsigned int in_streams, unsigned int out_streams, gr::msg_queue::sptr queue);
|
||||
|
||||
virtual ~SpirGSS6450FileSignalSource();
|
||||
inline std::string role() override
|
||||
@@ -110,7 +110,7 @@ private:
|
||||
double sampling_frequency_;
|
||||
std::string filename_;
|
||||
bool repeat_;
|
||||
bool dump_; //Enables dumping the gr_complex sample output
|
||||
bool dump_; //Enables dumping the gr_complex sample output
|
||||
bool enable_throttle_control_;
|
||||
bool endian_swap_;
|
||||
std::string dump_filename_;
|
||||
@@ -128,7 +128,7 @@ private:
|
||||
unpack_spir_gss6450_samples_sptr unpack_spir_;
|
||||
boost::shared_ptr<gr::block> valve_;
|
||||
gr::blocks::file_sink::sptr sink_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
gr::msg_queue::sptr queue_;
|
||||
size_t item_size_;
|
||||
};
|
||||
|
||||
@@ -44,9 +44,8 @@ using google::LogMessage;
|
||||
|
||||
|
||||
TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
{
|
||||
std::string default_filename = "../data/my_capture.dat";
|
||||
std::string default_item_type = "byte";
|
||||
@@ -57,8 +56,8 @@ TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* con
|
||||
filename_ = configuration->property(role + ".filename", default_filename);
|
||||
|
||||
// override value with commandline flag, if present
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_= FLAGS_signal_source;
|
||||
if (FLAGS_s.compare("-") != 0) filename_= FLAGS_s;
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_ = FLAGS_signal_source;
|
||||
if (FLAGS_s.compare("-") != 0) filename_ = FLAGS_s;
|
||||
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
repeat_ = configuration->property(role + ".repeat", false);
|
||||
@@ -72,49 +71,48 @@ TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* con
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << item_type_ << " unrecognized item type. Using byte.";
|
||||
LOG(WARNING) << item_type_ << " unrecognized item type. Using byte.";
|
||||
item_size_ = sizeof(char);
|
||||
}
|
||||
try
|
||||
{
|
||||
{
|
||||
file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_);
|
||||
unpack_byte_ = make_unpack_byte_2bit_cpx_samples();
|
||||
inter_shorts_to_cpx_ = gr::blocks::interleaved_short_to_complex::make(false,true); //I/Q swap enabled
|
||||
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
inter_shorts_to_cpx_ = gr::blocks::interleaved_short_to_complex::make(false, true); //I/Q swap enabled
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
|
||||
LOG(WARNING) << "file_signal_source: Unable to open the samples file "
|
||||
<< filename_.c_str() << ", exiting the program.";
|
||||
<< filename_.c_str() << ", exiting the program.";
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
|
||||
DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")";
|
||||
|
||||
if (samples_ == 0) // read all file
|
||||
if (samples_ == 0) // read all file
|
||||
{
|
||||
/*!
|
||||
* BUG workaround: The GNU Radio 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 2 milliseconds, and enable always the
|
||||
* valve block
|
||||
*/
|
||||
std::ifstream file (filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
||||
std::ifstream file(filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
||||
std::ifstream::pos_type size;
|
||||
|
||||
if (file.is_open())
|
||||
@@ -130,19 +128,19 @@ TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* con
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(16);
|
||||
std::cout << "Processing file " << filename_ << ", which contains " << size << " [bytes]" << std::endl;
|
||||
std::cout.precision (ss);
|
||||
std::cout.precision(ss);
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
int sample_packet_factor = 2; // 1 byte -> 2 samples
|
||||
int sample_packet_factor = 2; // 1 byte -> 2 samples
|
||||
samples_ = floor(static_cast<double>(size) / static_cast<double>(item_size())) * sample_packet_factor;
|
||||
samples_ = samples_- ceil(0.002 * static_cast<double>(sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms
|
||||
samples_ = samples_ - ceil(0.002 * static_cast<double>(sampling_frequency_)); //process all the samples available in the file excluding the last 2 ms
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(samples_ > 0) << "File does not contain enough samples to process.";
|
||||
double signal_duration_s;
|
||||
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]";
|
||||
std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl;
|
||||
|
||||
@@ -172,7 +170,8 @@ TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* con
|
||||
|
||||
|
||||
TwoBitCpxFileSignalSource::~TwoBitCpxFileSignalSource()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TwoBitCpxFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -182,8 +181,8 @@ void TwoBitCpxFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->connect(file_source_, 0, unpack_byte_, 0);
|
||||
top_block->connect(unpack_byte_, 0,inter_shorts_to_cpx_,0);
|
||||
top_block->connect(inter_shorts_to_cpx_, 0,throttle_,0);
|
||||
top_block->connect(unpack_byte_, 0, inter_shorts_to_cpx_, 0);
|
||||
top_block->connect(inter_shorts_to_cpx_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "connected file source to throttle";
|
||||
top_block->connect(throttle_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected throttle to valve";
|
||||
@@ -196,8 +195,8 @@ void TwoBitCpxFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
else
|
||||
{
|
||||
top_block->connect(file_source_, 0, unpack_byte_, 0);
|
||||
top_block->connect(unpack_byte_, 0,inter_shorts_to_cpx_,0);
|
||||
top_block->connect(inter_shorts_to_cpx_, 0,valve_,0);
|
||||
top_block->connect(unpack_byte_, 0, inter_shorts_to_cpx_, 0);
|
||||
top_block->connect(inter_shorts_to_cpx_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected file source to valve";
|
||||
if (dump_)
|
||||
{
|
||||
@@ -211,8 +210,8 @@ void TwoBitCpxFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
if (enable_throttle_control_ == true)
|
||||
{
|
||||
top_block->connect(file_source_, 0, unpack_byte_, 0);
|
||||
top_block->connect(unpack_byte_, 0,inter_shorts_to_cpx_,0);
|
||||
top_block->connect(inter_shorts_to_cpx_, 0,throttle_,0);
|
||||
top_block->connect(unpack_byte_, 0, inter_shorts_to_cpx_, 0);
|
||||
top_block->connect(inter_shorts_to_cpx_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "connected file source to throttle";
|
||||
if (dump_)
|
||||
{
|
||||
@@ -225,7 +224,7 @@ void TwoBitCpxFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(file_source_, 0, unpack_byte_, 0);
|
||||
top_block->connect(unpack_byte_, 0,inter_shorts_to_cpx_,0);
|
||||
top_block->connect(unpack_byte_, 0, inter_shorts_to_cpx_, 0);
|
||||
top_block->connect(inter_shorts_to_cpx_, 0, sink_, 0);
|
||||
DLOG(INFO) << "connected file source to sink";
|
||||
}
|
||||
@@ -242,7 +241,7 @@ void TwoBitCpxFileSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
top_block->disconnect(file_source_, 0, unpack_byte_, 0);
|
||||
DLOG(INFO) << "disconnected file source to unpack_byte_";
|
||||
top_block->connect(unpack_byte_, 0,throttle_,0);
|
||||
top_block->connect(unpack_byte_, 0, throttle_, 0);
|
||||
DLOG(INFO) << "disconnected unpack_byte_ to throttle_";
|
||||
top_block->disconnect(throttle_, 0, valve_, 0);
|
||||
DLOG(INFO) << "disconnected throttle to valve";
|
||||
|
||||
@@ -51,12 +51,12 @@ class ConfigurationInterface;
|
||||
* \brief Class that reads signals samples from a file
|
||||
* and adapts it to a SignalSourceInterface
|
||||
*/
|
||||
class TwoBitCpxFileSignalSource: public GNSSBlockInterface
|
||||
class TwoBitCpxFileSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
TwoBitCpxFileSignalSource(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~TwoBitCpxFileSignalSource();
|
||||
inline std::string role() override
|
||||
@@ -123,7 +123,7 @@ private:
|
||||
gr::blocks::interleaved_short_to_complex::sptr inter_shorts_to_cpx_;
|
||||
boost::shared_ptr<gr::block> valve_;
|
||||
gr::blocks::file_sink::sptr sink_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
size_t item_size_;
|
||||
// Throttle control
|
||||
|
||||
@@ -46,9 +46,8 @@ using google::LogMessage;
|
||||
|
||||
|
||||
TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
std::string role, unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
|
||||
{
|
||||
std::string default_filename = "../data/my_capture.dat";
|
||||
std::string default_item_type = "byte";
|
||||
@@ -61,29 +60,29 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac
|
||||
filename_ = configuration->property(role + ".filename", default_filename);
|
||||
|
||||
// override value with commandline flag, if present
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_= FLAGS_signal_source;
|
||||
if (FLAGS_s.compare("-") != 0) filename_= FLAGS_s;
|
||||
if (FLAGS_signal_source.compare("-") != 0) filename_ = FLAGS_signal_source;
|
||||
if (FLAGS_s.compare("-") != 0) filename_ = FLAGS_s;
|
||||
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
big_endian_items_ = configuration->property(role + ".big_endian_items", true);
|
||||
big_endian_bytes_ = configuration->property(role + ".big_endian_bytes", false);
|
||||
sample_type_ = configuration->property(role + ".sample_type", default_sample_type ); // options: "real", "iq", "qi"
|
||||
sample_type_ = configuration->property(role + ".sample_type", default_sample_type); // options: "real", "iq", "qi"
|
||||
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);
|
||||
double seconds_to_skip = configuration->property(role + ".seconds_to_skip", default_seconds_to_skip );
|
||||
double seconds_to_skip = configuration->property(role + ".seconds_to_skip", default_seconds_to_skip);
|
||||
long bytes_to_skip = 0;
|
||||
|
||||
if (item_type_.compare("byte") == 0)
|
||||
{
|
||||
item_size_ = sizeof(char);
|
||||
}
|
||||
else if( item_type_.compare("short") == 0)
|
||||
else if (item_type_.compare("short") == 0)
|
||||
{
|
||||
// If we have shorts stored in little endian format, might as
|
||||
// well read them in as bytes.
|
||||
if( big_endian_items_ )
|
||||
if (big_endian_items_)
|
||||
{
|
||||
item_size_ = sizeof(short);
|
||||
}
|
||||
@@ -94,20 +93,20 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << item_type_ << " unrecognized item type. Using byte.";
|
||||
LOG(WARNING) << item_type_ << " unrecognized item type. Using byte.";
|
||||
item_size_ = sizeof(char);
|
||||
}
|
||||
|
||||
if( sample_type_.compare("real") == 0 )
|
||||
if (sample_type_.compare("real") == 0)
|
||||
{
|
||||
is_complex_ = false;
|
||||
}
|
||||
else if( sample_type_.compare("iq" ) == 0 )
|
||||
else if (sample_type_.compare("iq") == 0)
|
||||
{
|
||||
is_complex_ = true;
|
||||
reverse_interleaving_ = false;
|
||||
}
|
||||
else if( sample_type_.compare("qi") == 0 )
|
||||
else if (sample_type_.compare("qi") == 0)
|
||||
{
|
||||
is_complex_ = true;
|
||||
reverse_interleaving_ = true;
|
||||
@@ -115,83 +114,82 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << sample_type_ << " unrecognized sample type. Assuming: "
|
||||
<< ( is_complex_ ? ( reverse_interleaving_ ? "qi" : "iq" ) : "real" );
|
||||
<< (is_complex_ ? (reverse_interleaving_ ? "qi" : "iq") : "real");
|
||||
}
|
||||
try
|
||||
{
|
||||
{
|
||||
file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_);
|
||||
|
||||
if( seconds_to_skip > 0 )
|
||||
if (seconds_to_skip > 0)
|
||||
{
|
||||
bytes_to_skip = static_cast< long >(
|
||||
seconds_to_skip * sampling_frequency_ / 4 );
|
||||
if( is_complex_ )
|
||||
bytes_to_skip = static_cast<long>(
|
||||
seconds_to_skip * sampling_frequency_ / 4);
|
||||
if (is_complex_)
|
||||
{
|
||||
bytes_to_skip <<= 1;
|
||||
}
|
||||
file_source_->seek( bytes_to_skip, SEEK_SET );
|
||||
file_source_->seek(bytes_to_skip, SEEK_SET);
|
||||
}
|
||||
|
||||
unpack_samples_ = make_unpack_2bit_samples( big_endian_bytes_,
|
||||
item_size_, big_endian_items_, reverse_interleaving_);
|
||||
if( is_complex_ )
|
||||
unpack_samples_ = make_unpack_2bit_samples(big_endian_bytes_,
|
||||
item_size_, big_endian_items_, reverse_interleaving_);
|
||||
if (is_complex_)
|
||||
{
|
||||
char_to_float_ =
|
||||
gr::blocks::interleaved_char_to_complex::make(false);
|
||||
gr::blocks::interleaved_char_to_complex::make(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
char_to_float_ =
|
||||
gr::blocks::char_to_float::make();
|
||||
gr::blocks::char_to_float::make();
|
||||
}
|
||||
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
<< "The receiver was configured to work with a file signal source "
|
||||
<< std::endl
|
||||
<< "but the specified file is unreachable by GNSS-SDR."
|
||||
<< std::endl
|
||||
<< "Please modify your configuration file"
|
||||
<< std::endl
|
||||
<< "and point SignalSource.filename to a valid raw data file. Then:"
|
||||
<< std::endl
|
||||
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
|
||||
<< std::endl
|
||||
<< "Examples of configuration files available at:"
|
||||
<< std::endl
|
||||
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
|
||||
<< std::endl;
|
||||
|
||||
LOG(WARNING) << "file_signal_source: Unable to open the samples file "
|
||||
<< filename_.c_str() << ", exiting the program.";
|
||||
<< filename_.c_str() << ", exiting the program.";
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
|
||||
DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")";
|
||||
|
||||
size_t output_item_size = ( is_complex_ ? sizeof( gr_complex ) : sizeof( float ) );
|
||||
size_t output_item_size = (is_complex_ ? sizeof(gr_complex) : sizeof(float));
|
||||
|
||||
if (samples_ == 0) // read all file
|
||||
if (samples_ == 0) // read all file
|
||||
{
|
||||
/*!
|
||||
* BUG workaround: The GNU Radio 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 2 milliseconds, and enable always the
|
||||
* valve block
|
||||
*/
|
||||
std::ifstream file (filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
|
||||
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();
|
||||
samples_ = floor(static_cast<double>(size) * ( is_complex_ ? 2.0 : 4.0 ) );
|
||||
LOG(INFO) << "Total samples in the file= " << samples_; // 4 samples per byte
|
||||
samples_ = floor(static_cast<double>(size) * (is_complex_ ? 2.0 : 4.0));
|
||||
LOG(INFO) << "Total samples in the file= " << samples_; // 4 samples per byte
|
||||
samples_ -= bytes_to_skip;
|
||||
|
||||
//Also skip the last two milliseconds:
|
||||
samples_ -= ceil( 0.002 * sampling_frequency_ / (is_complex_ ? 2.0 : 4.0 ) );
|
||||
samples_ -= ceil(0.002 * sampling_frequency_ / (is_complex_ ? 2.0 : 4.0));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -201,12 +199,12 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac
|
||||
std::streamsize ss = std::cout.precision();
|
||||
std::cout << std::setprecision(16);
|
||||
std::cout << "Processing file " << filename_ << ", which contains " << size << " [bytes]" << std::endl;
|
||||
std::cout.precision (ss);
|
||||
std::cout.precision(ss);
|
||||
}
|
||||
|
||||
CHECK(samples_ > 0) << "File does not contain enough samples to process.";
|
||||
double signal_duration_s;
|
||||
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]";
|
||||
std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl;
|
||||
|
||||
@@ -236,7 +234,8 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac
|
||||
|
||||
|
||||
TwoBitPackedFileSignalSource::~TwoBitPackedFileSignalSource()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TwoBitPackedFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -249,14 +248,14 @@ void TwoBitPackedFileSignalSource::connect(gr::top_block_sptr top_block)
|
||||
|
||||
DLOG(INFO) << "connected file source to unpack samples";
|
||||
right_block = char_to_float_;
|
||||
top_block->connect( left_block, 0, right_block, 0 );
|
||||
top_block->connect(left_block, 0, right_block, 0);
|
||||
left_block = right_block;
|
||||
DLOG(INFO) << "connected unpack samples to char to float";
|
||||
|
||||
if( enable_throttle_control_ )
|
||||
if (enable_throttle_control_)
|
||||
{
|
||||
right_block = throttle_;
|
||||
top_block->connect( left_block, 0, right_block, 0 );
|
||||
top_block->connect(left_block, 0, right_block, 0);
|
||||
left_block = right_block;
|
||||
DLOG(INFO) << " connected to throttle";
|
||||
}
|
||||
@@ -282,14 +281,14 @@ void TwoBitPackedFileSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
|
||||
DLOG(INFO) << "disconnected file source to unpack samples";
|
||||
right_block = char_to_float_;
|
||||
top_block->disconnect( left_block, 0, right_block, 0 );
|
||||
top_block->disconnect(left_block, 0, right_block, 0);
|
||||
left_block = right_block;
|
||||
DLOG(INFO) << "disconnected unpack samples to char to float";
|
||||
|
||||
if( enable_throttle_control_ )
|
||||
if (enable_throttle_control_)
|
||||
{
|
||||
right_block = throttle_;
|
||||
top_block->disconnect( left_block, 0, right_block, 0 );
|
||||
top_block->disconnect(left_block, 0, right_block, 0);
|
||||
left_block = right_block;
|
||||
DLOG(INFO) << " disconnected to throttle";
|
||||
}
|
||||
@@ -316,4 +315,3 @@ gr::basic_block_sptr TwoBitPackedFileSignalSource::get_right_block()
|
||||
{
|
||||
return valve_;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ class ConfigurationInterface;
|
||||
* \brief Class that reads signals samples from a file
|
||||
* and adapts it to a SignalSourceInterface
|
||||
*/
|
||||
class TwoBitPackedFileSignalSource: public GNSSBlockInterface
|
||||
class TwoBitPackedFileSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
TwoBitPackedFileSignalSource(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~TwoBitPackedFileSignalSource();
|
||||
inline std::string role() override
|
||||
@@ -144,7 +144,7 @@ private:
|
||||
gr::basic_block_sptr char_to_float_;
|
||||
boost::shared_ptr<gr::block> valve_;
|
||||
gr::blocks::file_sink::sptr sink_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
gr::blocks::throttle::sptr throttle_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
size_t item_size_;
|
||||
bool big_endian_items_;
|
||||
|
||||
@@ -42,10 +42,8 @@
|
||||
using google::LogMessage;
|
||||
|
||||
UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream),
|
||||
queue_(queue)
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue)
|
||||
{
|
||||
// DUMP PARAMETERS
|
||||
std::string empty = "";
|
||||
@@ -59,13 +57,13 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration,
|
||||
// available transports on the system (ethernet, usb...).
|
||||
// To narrow down the discovery process to a particular device,
|
||||
// specify a transport key/value pair specific to your device.
|
||||
if (empty.compare(device_address_) != 0) // if not empty
|
||||
if (empty.compare(device_address_) != 0) // if not empty
|
||||
{
|
||||
dev_addr["addr"] = device_address_;
|
||||
}
|
||||
//filter the device by serial number if required (useful for USB devices)
|
||||
std::string device_serial = configuration->property(role + ".device_serial", empty);
|
||||
if (empty.compare(device_serial) != 0) // if not empty
|
||||
if (empty.compare(device_serial) != 0) // if not empty
|
||||
{
|
||||
dev_addr["serial"] = device_serial;
|
||||
}
|
||||
@@ -85,8 +83,7 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration,
|
||||
freq_.push_back(configuration->property(role + ".freq", GPS_L1_FREQ_HZ));
|
||||
gain_.push_back(configuration->property(role + ".gain", 50.0));
|
||||
|
||||
IF_bandwidth_hz_.push_back(configuration->property(role + ".IF_bandwidth_hz", sample_rate_/2));
|
||||
|
||||
IF_bandwidth_hz_.push_back(configuration->property(role + ".IF_bandwidth_hz", sample_rate_ / 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -101,7 +98,7 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration,
|
||||
freq_.push_back(configuration->property(role + ".freq" + boost::lexical_cast<std::string>(i), GPS_L1_FREQ_HZ));
|
||||
gain_.push_back(configuration->property(role + ".gain" + boost::lexical_cast<std::string>(i), 50.0));
|
||||
|
||||
IF_bandwidth_hz_.push_back(configuration->property(role + ".IF_bandwidth_hz" + boost::lexical_cast<std::string>(i), sample_rate_/2));
|
||||
IF_bandwidth_hz_.push_back(configuration->property(role + ".IF_bandwidth_hz" + boost::lexical_cast<std::string>(i), sample_rate_ / 2));
|
||||
}
|
||||
}
|
||||
// 1. Make the uhd driver instance
|
||||
@@ -219,14 +216,14 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration,
|
||||
{
|
||||
if (samples_.at(i) != 0)
|
||||
{
|
||||
LOG(INFO) << "RF_channel "<< i << " Send STOP signal after " << samples_.at(i) << " samples";
|
||||
LOG(INFO) << "RF_channel " << i << " Send STOP signal after " << samples_.at(i) << " samples";
|
||||
valve_.push_back(gnss_sdr_make_valve(item_size_, samples_.at(i), queue_));
|
||||
DLOG(INFO) << "valve(" << valve_.at(i)->unique_id() << ")";
|
||||
}
|
||||
|
||||
if (dump_.at(i))
|
||||
{
|
||||
LOG(INFO) << "RF_channel "<< i << "Dumping output into file " << dump_filename_.at(i);
|
||||
LOG(INFO) << "RF_channel " << i << "Dumping output into file " << dump_filename_.at(i);
|
||||
file_sink_.push_back(gr::blocks::file_sink::make(item_size_, dump_filename_.at(i).c_str()));
|
||||
DLOG(INFO) << "file_sink(" << file_sink_.at(i)->unique_id() << ")";
|
||||
}
|
||||
@@ -234,9 +231,9 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration,
|
||||
}
|
||||
|
||||
|
||||
|
||||
UhdSignalSource::~UhdSignalSource()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void UhdSignalSource::connect(gr::top_block_sptr top_block)
|
||||
@@ -265,7 +262,6 @@ void UhdSignalSource::connect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void UhdSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
for (int i = 0; i < RF_channels_; i++)
|
||||
@@ -290,7 +286,6 @@ void UhdSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
}
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr UhdSignalSource::get_left_block()
|
||||
{
|
||||
LOG(WARNING) << "Trying to get signal source left block.";
|
||||
|
||||
@@ -46,13 +46,12 @@ class ConfigurationInterface;
|
||||
/*!
|
||||
* \brief This class reads samples from a UHD device (see http://code.ettus.com/redmine/ettus/projects/uhd/wiki)
|
||||
*/
|
||||
class UhdSignalSource: public GNSSBlockInterface
|
||||
class UhdSignalSource : public GNSSBlockInterface
|
||||
{
|
||||
|
||||
public:
|
||||
UhdSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~UhdSignalSource();
|
||||
|
||||
|
||||
@@ -48,13 +48,13 @@ std::string labsat23_source::generate_filename()
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << std::setw(4) << std::setfill('0') << d_current_file_number;
|
||||
return d_signal_file_basename + "_" + ss.str()+".LS3";
|
||||
return d_signal_file_basename + "_" + ss.str() + ".LS3";
|
||||
}
|
||||
|
||||
|
||||
labsat23_source::labsat23_source(const char *signal_file_basename, int channel_selector) : gr::block("labsat23_source",
|
||||
gr::io_signature::make(0, 0, 0),
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)))
|
||||
gr::io_signature::make(0, 0, 0),
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)))
|
||||
{
|
||||
if (channel_selector < 1 or channel_selector > 2)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ labsat23_source::labsat23_source(const char *signal_file_basename, int channel_s
|
||||
std::string signal_file;
|
||||
this->set_output_multiple(8);
|
||||
signal_file = generate_filename();
|
||||
binary_input_file = new std::ifstream (signal_file.c_str(), std::ios::in|std::ios::binary);
|
||||
binary_input_file = new std::ifstream(signal_file.c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
if (binary_input_file->is_open())
|
||||
{
|
||||
@@ -104,75 +104,75 @@ int labsat23_source::getBit(uint8_t byte, int position)
|
||||
}
|
||||
|
||||
|
||||
void labsat23_source::decode_samples_one_channel(int16_t input_short, gr_complex* out, int type)
|
||||
void labsat23_source::decode_samples_one_channel(int16_t input_short, gr_complex *out, int type)
|
||||
{
|
||||
std::bitset<16> bs(input_short);
|
||||
switch(type)
|
||||
{
|
||||
case 2:
|
||||
//two bits per sample, 8 samples per int16
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
out[i] = gr_complex(static_cast<float>(bs[15-(2*i)]),
|
||||
static_cast<float>(bs[14-(2*i)]));
|
||||
out[i] = out[i]*gr_complex(2,0)-gr_complex(1,1);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
//four bits per sample, 4 samples per int16
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
out[i] = gr_complex(0.0,0.0);
|
||||
//In-Phase
|
||||
if (bs[15-4*i])
|
||||
{
|
||||
if (bs[13-4*i]) //11
|
||||
{
|
||||
out[i] += gr_complex(-1,0);
|
||||
}
|
||||
else //10
|
||||
{
|
||||
out[i] += gr_complex(-2,0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bs[13-4*i]) //01
|
||||
{
|
||||
out[i] += gr_complex(1,0);
|
||||
}
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case 2:
|
||||
//two bits per sample, 8 samples per int16
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
out[i] = gr_complex(static_cast<float>(bs[15 - (2 * i)]),
|
||||
static_cast<float>(bs[14 - (2 * i)]));
|
||||
out[i] = out[i] * gr_complex(2, 0) - gr_complex(1, 1);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
//four bits per sample, 4 samples per int16
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
out[i] = gr_complex(0.0, 0.0);
|
||||
//In-Phase
|
||||
if (bs[15 - 4 * i])
|
||||
{
|
||||
if (bs[13 - 4 * i]) //11
|
||||
{
|
||||
out[i] += gr_complex(-1, 0);
|
||||
}
|
||||
else //10
|
||||
{
|
||||
out[i] += gr_complex(-2, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bs[13 - 4 * i]) //01
|
||||
{
|
||||
out[i] += gr_complex(1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//Quadrature
|
||||
if (bs[14-4*i])
|
||||
{
|
||||
if (bs[12-4*i]) //11
|
||||
{
|
||||
out[i] += gr_complex(0,-1);
|
||||
}
|
||||
else //10
|
||||
{
|
||||
out[i] += gr_complex(0,-2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bs[12-4*i]) //01
|
||||
{
|
||||
out[i] += gr_complex(0,1);
|
||||
}
|
||||
}
|
||||
out[i] += gr_complex(0.5,0.5);
|
||||
}
|
||||
break;
|
||||
}
|
||||
//Quadrature
|
||||
if (bs[14 - 4 * i])
|
||||
{
|
||||
if (bs[12 - 4 * i]) //11
|
||||
{
|
||||
out[i] += gr_complex(0, -1);
|
||||
}
|
||||
else //10
|
||||
{
|
||||
out[i] += gr_complex(0, -2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bs[12 - 4 * i]) //01
|
||||
{
|
||||
out[i] += gr_complex(0, 1);
|
||||
}
|
||||
}
|
||||
out[i] += gr_complex(0.5, 0.5);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int labsat23_source::general_work(int noutput_items,
|
||||
__attribute__((unused)) gr_vector_int &ninput_items,
|
||||
__attribute__((unused)) gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
__attribute__((unused)) gr_vector_int &ninput_items,
|
||||
__attribute__((unused)) gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
|
||||
|
||||
@@ -200,13 +200,13 @@ int labsat23_source::general_work(int noutput_items,
|
||||
}
|
||||
|
||||
// check Labsat version
|
||||
if (memblock[byte_counter] == 0x4C and memblock[byte_counter+1] == 0x53 and memblock[byte_counter+2] == 0x32)
|
||||
if (memblock[byte_counter] == 0x4C and memblock[byte_counter + 1] == 0x53 and memblock[byte_counter + 2] == 0x32)
|
||||
{
|
||||
d_labsat_version = 2;
|
||||
std::cout << "Labsat file version 2 detected" << std::endl;
|
||||
}
|
||||
|
||||
if (memblock[byte_counter] == 0x4C and memblock[byte_counter+1] == 0x53 and memblock[byte_counter+2] == 0x33)
|
||||
if (memblock[byte_counter] == 0x4C and memblock[byte_counter + 1] == 0x53 and memblock[byte_counter + 2] == 0x33)
|
||||
{
|
||||
d_labsat_version = 3;
|
||||
std::cout << "Labsat file version 3 detected" << std::endl;
|
||||
@@ -227,80 +227,80 @@ int labsat23_source::general_work(int noutput_items,
|
||||
byte_counter++;
|
||||
|
||||
int header_bytes = 0;
|
||||
header_bytes += memblock[byte_counter] | (memblock[byte_counter+1] << 8) | (memblock[byte_counter+2] << 16) | (memblock[byte_counter+3] << 24);
|
||||
header_bytes += memblock[byte_counter] | (memblock[byte_counter + 1] << 8) | (memblock[byte_counter + 2] << 16) | (memblock[byte_counter + 3] << 24);
|
||||
|
||||
byte_counter += 4;
|
||||
//std::cout << "header_bytes=" << header_bytes << std::endl;
|
||||
|
||||
// read first section
|
||||
// section ID (little-endian)
|
||||
uint8_t section_id = static_cast<int>(memblock[byte_counter]) + static_cast<int>(memblock[byte_counter+1]) * 256;
|
||||
uint8_t section_id = static_cast<int>(memblock[byte_counter]) + static_cast<int>(memblock[byte_counter + 1]) * 256;
|
||||
//std::cout << "Section ID: " << (int)section_id << std::endl;
|
||||
byte_counter += 2;
|
||||
|
||||
uint8_t section_lenght_bytes = 0;
|
||||
section_lenght_bytes += memblock[byte_counter] | (memblock[byte_counter+1] << 8) | (memblock[byte_counter+2] << 16) | (memblock[byte_counter+3] << 24);
|
||||
section_lenght_bytes += memblock[byte_counter] | (memblock[byte_counter + 1] << 8) | (memblock[byte_counter + 2] << 16) | (memblock[byte_counter + 3] << 24);
|
||||
//std::cout << "section_lenght_bytes=" << (int)section_lenght_bytes << std::endl;
|
||||
|
||||
byte_counter += 4;
|
||||
if (section_id == 2)
|
||||
{
|
||||
d_ref_clock = static_cast<uint8_t>(memblock[byte_counter]);
|
||||
switch(d_ref_clock)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Labsat reference clock: internal OXCO" << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Labsat reference clock: internal TXCO" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Labsat reference clock: external 10 MHz" << std::endl;
|
||||
break;
|
||||
case 3:
|
||||
std::cout << "Labsat reference clock: external 16.386 MHz" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Labsat Unknown reference clock ID " << static_cast<int>(d_ref_clock) << std::endl;
|
||||
}
|
||||
switch (d_ref_clock)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Labsat reference clock: internal OXCO" << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Labsat reference clock: internal TXCO" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Labsat reference clock: external 10 MHz" << std::endl;
|
||||
break;
|
||||
case 3:
|
||||
std::cout << "Labsat reference clock: external 16.386 MHz" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Labsat Unknown reference clock ID " << static_cast<int>(d_ref_clock) << std::endl;
|
||||
}
|
||||
byte_counter++;
|
||||
d_bits_per_sample = static_cast<uint8_t>(memblock[byte_counter]);
|
||||
switch(d_bits_per_sample)
|
||||
{
|
||||
case 2:
|
||||
std::cout << "Labsat is using 2 bits per sample" << std::endl;
|
||||
break;
|
||||
case 4:
|
||||
std::cout << "Labsat is using 4 bits per sample" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Labsat Unknown bits per sample ID " << static_cast<int>(d_bits_per_sample) << std::endl;
|
||||
return -1;
|
||||
}
|
||||
switch (d_bits_per_sample)
|
||||
{
|
||||
case 2:
|
||||
std::cout << "Labsat is using 2 bits per sample" << std::endl;
|
||||
break;
|
||||
case 4:
|
||||
std::cout << "Labsat is using 4 bits per sample" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Labsat Unknown bits per sample ID " << static_cast<int>(d_bits_per_sample) << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte_counter++;
|
||||
d_channel_selector = static_cast<uint8_t>(memblock[byte_counter]);
|
||||
switch(d_channel_selector)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Available channels: Channel A + B, 1 bit quantisation" << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Available channels: Channel A, 1 bit quantisation" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Available channels: Channel B, 1 bit quantisation" << std::endl;
|
||||
break;
|
||||
case 3:
|
||||
std::cout << "Available channels: Channel A, 2 bit quantisation" << std::endl;
|
||||
break;
|
||||
case 4:
|
||||
std::cout << "Available channels: Channel B, 2 bit quantisation" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown channel selection ID " << static_cast<int>(d_channel_selector) << std::endl;
|
||||
return -1;
|
||||
}
|
||||
switch (d_channel_selector)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Available channels: Channel A + B, 1 bit quantisation" << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Available channels: Channel A, 1 bit quantisation" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Available channels: Channel B, 1 bit quantisation" << std::endl;
|
||||
break;
|
||||
case 3:
|
||||
std::cout << "Available channels: Channel A, 2 bit quantisation" << std::endl;
|
||||
break;
|
||||
case 4:
|
||||
std::cout << "Available channels: Channel B, 2 bit quantisation" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown channel selection ID " << static_cast<int>(d_channel_selector) << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//check if the selected channel in config file match the file encoding
|
||||
if (d_channel_selector_config == 2 and d_channel_selector != 0)
|
||||
@@ -317,49 +317,49 @@ int labsat23_source::general_work(int noutput_items,
|
||||
}
|
||||
byte_counter++;
|
||||
uint8_t quantization = static_cast<uint8_t>(memblock[byte_counter]);
|
||||
switch(quantization)
|
||||
{
|
||||
case 1:
|
||||
std::cout << "1 bit per sample" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "2 bit per sample" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown quantization ID " << static_cast<int>(quantization) << std::endl;
|
||||
}
|
||||
switch (quantization)
|
||||
{
|
||||
case 1:
|
||||
std::cout << "1 bit per sample" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "2 bit per sample" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown quantization ID " << static_cast<int>(quantization) << std::endl;
|
||||
}
|
||||
byte_counter++;
|
||||
uint8_t channel_a_constellation = static_cast<uint8_t>(memblock[byte_counter]);
|
||||
switch(channel_a_constellation)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Labsat Channel A is GPS" << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Labsat Channel A is GLONASS" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Labsat Channel A is BDS" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown channel A constellation ID " << static_cast<int>(channel_a_constellation) << std::endl;
|
||||
}
|
||||
switch (channel_a_constellation)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Labsat Channel A is GPS" << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Labsat Channel A is GLONASS" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Labsat Channel A is BDS" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown channel A constellation ID " << static_cast<int>(channel_a_constellation) << std::endl;
|
||||
}
|
||||
byte_counter++;
|
||||
uint8_t channel_b_constellation = static_cast<uint8_t>(memblock[byte_counter]);
|
||||
switch(channel_b_constellation)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Labsat Channel B is GPS" << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Labsat Channel B is GLONASS" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Labsat Channel B is BDS" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown channel B constellation ID " << static_cast<int>(channel_b_constellation) << std::endl;
|
||||
}
|
||||
switch (channel_b_constellation)
|
||||
{
|
||||
case 0:
|
||||
std::cout << "Labsat Channel B is GPS" << std::endl;
|
||||
break;
|
||||
case 1:
|
||||
std::cout << "Labsat Channel B is GLONASS" << std::endl;
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Labsat Channel B is BDS" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown channel B constellation ID " << static_cast<int>(channel_b_constellation) << std::endl;
|
||||
}
|
||||
|
||||
//end of header
|
||||
d_header_parsed = true;
|
||||
@@ -383,115 +383,115 @@ int labsat23_source::general_work(int noutput_items,
|
||||
else
|
||||
{
|
||||
//ready to start reading samples
|
||||
switch(d_bits_per_sample)
|
||||
{
|
||||
case 2:
|
||||
switch (d_bits_per_sample)
|
||||
{
|
||||
switch(d_channel_selector)
|
||||
case 2:
|
||||
{
|
||||
case 0:
|
||||
// dual channel 2 bits per complex sample
|
||||
break;
|
||||
default:
|
||||
//single channel 2 bits per complex sample (1 bit I + 1 bit Q, 8 samples per int16)
|
||||
int n_int16_to_read = noutput_items / 8;
|
||||
if (n_int16_to_read > 0)
|
||||
switch (d_channel_selector)
|
||||
{
|
||||
int16_t memblock[n_int16_to_read];
|
||||
binary_input_file->read(reinterpret_cast<char*>(memblock), n_int16_to_read * 2);
|
||||
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
|
||||
case 0:
|
||||
// dual channel 2 bits per complex sample
|
||||
break;
|
||||
default:
|
||||
//single channel 2 bits per complex sample (1 bit I + 1 bit Q, 8 samples per int16)
|
||||
int n_int16_to_read = noutput_items / 8;
|
||||
if (n_int16_to_read > 0)
|
||||
{
|
||||
int output_pointer = 0;
|
||||
for (int i = 0; i < n_int16_to_read; i++)
|
||||
int16_t memblock[n_int16_to_read];
|
||||
binary_input_file->read(reinterpret_cast<char *>(memblock), n_int16_to_read * 2);
|
||||
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
|
||||
if (n_int16_to_read > 0)
|
||||
{
|
||||
decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample);
|
||||
output_pointer += 8;
|
||||
}
|
||||
return output_pointer;
|
||||
}
|
||||
else
|
||||
{
|
||||
//trigger the read of the next file in the sequence
|
||||
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
|
||||
|
||||
d_current_file_number++;
|
||||
binary_input_file->close();
|
||||
binary_input_file->open(generate_filename().c_str(), std::ios::in|std::ios::binary);
|
||||
if (binary_input_file->is_open())
|
||||
{
|
||||
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
|
||||
int output_pointer = 0;
|
||||
for (int i = 0; i < n_int16_to_read; i++)
|
||||
{
|
||||
decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample);
|
||||
output_pointer += 8;
|
||||
}
|
||||
return output_pointer;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Last file reached, LabSat source stop" << std::endl;
|
||||
return -1;
|
||||
//trigger the read of the next file in the sequence
|
||||
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
|
||||
|
||||
d_current_file_number++;
|
||||
binary_input_file->close();
|
||||
binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary);
|
||||
if (binary_input_file->is_open())
|
||||
{
|
||||
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Last file reached, LabSat source stop" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
switch(d_channel_selector)
|
||||
{
|
||||
case 0:
|
||||
// dual channel
|
||||
break;
|
||||
default:
|
||||
//single channel 4 bits per complex sample (2 bit I + 2 bit Q, 4 samples per int16)
|
||||
int n_int16_to_read = noutput_items / 4;
|
||||
if (n_int16_to_read > 0)
|
||||
{
|
||||
int16_t memblock[n_int16_to_read];
|
||||
binary_input_file->read(reinterpret_cast<char*>(memblock), n_int16_to_read * 2);
|
||||
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
|
||||
if (n_int16_to_read > 0)
|
||||
{
|
||||
int output_pointer = 0;
|
||||
for (int i = 0; i < n_int16_to_read; i++)
|
||||
{
|
||||
decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample);
|
||||
output_pointer += 4;
|
||||
}
|
||||
return output_pointer;
|
||||
}
|
||||
else
|
||||
{
|
||||
//trigger the read of the next file in the sequence
|
||||
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
|
||||
|
||||
d_current_file_number++;
|
||||
binary_input_file->close();
|
||||
binary_input_file->open(generate_filename().c_str(), std::ios::in|std::ios::binary);
|
||||
if (binary_input_file->is_open())
|
||||
{
|
||||
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Last file reached, LabSat source stop" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
switch (d_channel_selector)
|
||||
{
|
||||
case 0:
|
||||
// dual channel
|
||||
break;
|
||||
default:
|
||||
//single channel 4 bits per complex sample (2 bit I + 2 bit Q, 4 samples per int16)
|
||||
int n_int16_to_read = noutput_items / 4;
|
||||
if (n_int16_to_read > 0)
|
||||
{
|
||||
int16_t memblock[n_int16_to_read];
|
||||
binary_input_file->read(reinterpret_cast<char *>(memblock), n_int16_to_read * 2);
|
||||
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
|
||||
if (n_int16_to_read > 0)
|
||||
{
|
||||
int output_pointer = 0;
|
||||
for (int i = 0; i < n_int16_to_read; i++)
|
||||
{
|
||||
decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample);
|
||||
output_pointer += 4;
|
||||
}
|
||||
return output_pointer;
|
||||
}
|
||||
else
|
||||
{
|
||||
//trigger the read of the next file in the sequence
|
||||
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
|
||||
|
||||
d_current_file_number++;
|
||||
binary_input_file->close();
|
||||
binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary);
|
||||
if (binary_input_file->is_open())
|
||||
{
|
||||
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Last file reached, LabSat source stop" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << "Warning!!" << std::endl;
|
||||
return 0;
|
||||
|
||||
@@ -46,12 +46,12 @@ labsat23_source_sptr labsat23_make_source(const char *signal_file_basename, int
|
||||
/*!
|
||||
* \brief This class implements conversion between Labsat2 and 3 format byte packet samples to gr_complex
|
||||
*/
|
||||
class labsat23_source: public gr::block
|
||||
class labsat23_source : public gr::block
|
||||
{
|
||||
private:
|
||||
friend labsat23_source_sptr labsat23_make_source_sptr(const char *signal_file_basename, int channel_selector);
|
||||
std::string generate_filename();
|
||||
void decode_samples_one_channel(int16_t input_short, gr_complex* out, int type);
|
||||
void decode_samples_one_channel(int16_t input_short, gr_complex *out, int type);
|
||||
int getBit(uint8_t byte, int position);
|
||||
bool d_header_parsed;
|
||||
uint8_t d_channel_selector;
|
||||
@@ -67,9 +67,9 @@ public:
|
||||
labsat23_source(const char *signal_file_basename, int channel_selector);
|
||||
~labsat23_source();
|
||||
int general_work(int noutput_items,
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,33 +43,34 @@ using boost::asio::ip::tcp;
|
||||
|
||||
// Buffer constants
|
||||
// TODO: Make these configurable
|
||||
enum {
|
||||
RTL_TCP_BUFFER_SIZE = 1024 * 16, // 16 KB
|
||||
RTL_TCP_PAYLOAD_SIZE = 1024 * 4 // 4 KB
|
||||
enum
|
||||
{
|
||||
RTL_TCP_BUFFER_SIZE = 1024 * 16, // 16 KB
|
||||
RTL_TCP_PAYLOAD_SIZE = 1024 * 4 // 4 KB
|
||||
};
|
||||
|
||||
rtl_tcp_signal_source_c_sptr
|
||||
rtl_tcp_make_signal_source_c(const std::string &address,
|
||||
short port,
|
||||
bool flip_iq)
|
||||
short port,
|
||||
bool flip_iq)
|
||||
{
|
||||
return gnuradio::get_initial_sptr (new rtl_tcp_signal_source_c (address,
|
||||
port,
|
||||
flip_iq));
|
||||
return gnuradio::get_initial_sptr(new rtl_tcp_signal_source_c(address,
|
||||
port,
|
||||
flip_iq));
|
||||
}
|
||||
|
||||
|
||||
rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
|
||||
short port,
|
||||
bool flip_iq)
|
||||
: gr::sync_block ("rtl_tcp_signal_source_c",
|
||||
gr::io_signature::make(0, 0, 0),
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex))),
|
||||
socket_ (io_service_),
|
||||
data_ (RTL_TCP_PAYLOAD_SIZE),
|
||||
flip_iq_(flip_iq),
|
||||
buffer_ (RTL_TCP_BUFFER_SIZE),
|
||||
unread_ (0)
|
||||
short port,
|
||||
bool flip_iq)
|
||||
: gr::sync_block("rtl_tcp_signal_source_c",
|
||||
gr::io_signature::make(0, 0, 0),
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex))),
|
||||
socket_(io_service_),
|
||||
data_(RTL_TCP_PAYLOAD_SIZE),
|
||||
flip_iq_(flip_iq),
|
||||
buffer_(RTL_TCP_BUFFER_SIZE),
|
||||
unread_(0)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
|
||||
@@ -80,32 +81,32 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
|
||||
}
|
||||
|
||||
// 2. Set socket options
|
||||
ip::address addr = ip::address::from_string (address, ec);
|
||||
ip::address addr = ip::address::from_string(address, ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << address << " is not an IP address" << std::endl;
|
||||
LOG (ERROR) << address << " is not an IP address";
|
||||
LOG(ERROR) << address << " is not an IP address";
|
||||
return;
|
||||
}
|
||||
ip::tcp::endpoint ep (addr, port);
|
||||
socket_.open (ep.protocol( ), ec);
|
||||
ip::tcp::endpoint ep(addr, port);
|
||||
socket_.open(ep.protocol(), ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to open socket." << std::endl;
|
||||
LOG (ERROR) << "Failed to open socket.";
|
||||
LOG(ERROR) << "Failed to open socket.";
|
||||
}
|
||||
|
||||
socket_.set_option (boost::asio::socket_base::reuse_address (true), ec);
|
||||
socket_.set_option(boost::asio::socket_base::reuse_address(true), ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set reuse address option: " << ec << std::endl;
|
||||
LOG (WARNING) << "Failed to set reuse address option";
|
||||
LOG(WARNING) << "Failed to set reuse address option";
|
||||
}
|
||||
socket_.set_option (boost::asio::socket_base::linger (true, 0), ec);
|
||||
socket_.set_option(boost::asio::socket_base::linger(true, 0), ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set linger option: " << ec << std::endl;
|
||||
LOG (WARNING) << "Failed to set linger option";
|
||||
LOG(WARNING) << "Failed to set linger option";
|
||||
}
|
||||
|
||||
// 3. Connect socket
|
||||
@@ -114,162 +115,162 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to connect to " << addr << ":" << port
|
||||
<< "(" << ec << ")" << std::endl;
|
||||
LOG (ERROR) << "Failed to connect to " << addr << ":" << port
|
||||
<< "(" << ec << ")";
|
||||
<< "(" << ec << ")" << std::endl;
|
||||
LOG(ERROR) << "Failed to connect to " << addr << ":" << port
|
||||
<< "(" << ec << ")";
|
||||
return;
|
||||
}
|
||||
std::cout << "Connected to " << addr << ":" << port << std::endl;
|
||||
LOG (INFO) << "Connected to " << addr << ":" << port;
|
||||
LOG(INFO) << "Connected to " << addr << ":" << port;
|
||||
|
||||
// 4. Set nodelay
|
||||
socket_.set_option (tcp::no_delay (true), ec);
|
||||
socket_.set_option(tcp::no_delay(true), ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set no delay option." << std::endl;
|
||||
LOG (WARNING) << "Failed to set no delay option";
|
||||
LOG(WARNING) << "Failed to set no delay option";
|
||||
}
|
||||
|
||||
// 5. Receive dongle info
|
||||
ec = info_.read (socket_);
|
||||
ec = info_.read(socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to read dongle info." << std::endl;
|
||||
LOG (WARNING) << "Failed to read dongle info";
|
||||
LOG(WARNING) << "Failed to read dongle info";
|
||||
}
|
||||
else if (info_.is_valid ())
|
||||
else if (info_.is_valid())
|
||||
{
|
||||
std::cout << "Found " << info_.get_type_name() << " tuner." << std::endl;
|
||||
LOG (INFO) << "Found " << info_.get_type_name() << " tuner.";
|
||||
std::cout << "Found " << info_.get_type_name() << " tuner." << std::endl;
|
||||
LOG(INFO) << "Found " << info_.get_type_name() << " tuner.";
|
||||
}
|
||||
|
||||
// 6. Start reading
|
||||
boost::asio::async_read (socket_, boost::asio::buffer (data_),
|
||||
boost::bind (&rtl_tcp_signal_source_c::handle_read,
|
||||
this, _1, _2));
|
||||
boost::thread (boost::bind (&boost::asio::io_service::run, &io_service_));
|
||||
boost::asio::async_read(socket_, boost::asio::buffer(data_),
|
||||
boost::bind(&rtl_tcp_signal_source_c::handle_read,
|
||||
this, _1, _2));
|
||||
boost::thread(boost::bind(&boost::asio::io_service::run, &io_service_));
|
||||
}
|
||||
|
||||
|
||||
rtl_tcp_signal_source_c::~rtl_tcp_signal_source_c()
|
||||
{
|
||||
io_service_.stop ();
|
||||
io_service_.stop();
|
||||
}
|
||||
|
||||
|
||||
int rtl_tcp_signal_source_c::work (int noutput_items,
|
||||
gr_vector_const_void_star &/*input_items*/,
|
||||
gr_vector_void_star &output_items)
|
||||
int rtl_tcp_signal_source_c::work(int noutput_items,
|
||||
gr_vector_const_void_star & /*input_items*/,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
gr_complex *out = reinterpret_cast <gr_complex *>( output_items[0] );
|
||||
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
|
||||
int i = 0;
|
||||
if (io_service_.stopped ())
|
||||
if (io_service_.stopped())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock (mutex_);
|
||||
not_empty_.wait (lock, boost::bind (&rtl_tcp_signal_source_c::not_empty,
|
||||
this));
|
||||
boost::mutex::scoped_lock lock(mutex_);
|
||||
not_empty_.wait(lock, boost::bind(&rtl_tcp_signal_source_c::not_empty,
|
||||
this));
|
||||
|
||||
for ( ; i < noutput_items && unread_ > 1; i++ )
|
||||
for (; i < noutput_items && unread_ > 1; i++)
|
||||
{
|
||||
float re = buffer_[--unread_];
|
||||
float im = buffer_[--unread_];
|
||||
if (flip_iq_)
|
||||
{
|
||||
out[i] = gr_complex (im, re);
|
||||
out[i] = gr_complex(im, re);
|
||||
}
|
||||
else
|
||||
{
|
||||
out[i] = gr_complex (re, im);
|
||||
out[i] = gr_complex(re, im);
|
||||
}
|
||||
}
|
||||
}
|
||||
not_full_.notify_one ();
|
||||
not_full_.notify_one();
|
||||
return i == 0 ? -1 : i;
|
||||
}
|
||||
|
||||
|
||||
void rtl_tcp_signal_source_c::set_frequency (int frequency)
|
||||
void rtl_tcp_signal_source_c::set_frequency(int frequency)
|
||||
{
|
||||
boost::system::error_code ec =
|
||||
rtl_tcp_command (RTL_TCP_SET_FREQUENCY, frequency, socket_);
|
||||
rtl_tcp_command(RTL_TCP_SET_FREQUENCY, frequency, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set frequency" << std::endl;
|
||||
LOG (WARNING) << "Failed to set frequency";
|
||||
LOG(WARNING) << "Failed to set frequency";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void rtl_tcp_signal_source_c::set_sample_rate (int sample_rate)
|
||||
void rtl_tcp_signal_source_c::set_sample_rate(int sample_rate)
|
||||
{
|
||||
boost::system::error_code ec =
|
||||
rtl_tcp_command (RTL_TCP_SET_SAMPLE_RATE, sample_rate, socket_);
|
||||
rtl_tcp_command(RTL_TCP_SET_SAMPLE_RATE, sample_rate, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set sample rate" << std::endl;
|
||||
LOG (WARNING) << "Failed to set sample rate";
|
||||
LOG(WARNING) << "Failed to set sample rate";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void rtl_tcp_signal_source_c::set_agc_mode (bool agc)
|
||||
void rtl_tcp_signal_source_c::set_agc_mode(bool agc)
|
||||
{
|
||||
boost::system::error_code ec =
|
||||
rtl_tcp_command (RTL_TCP_SET_GAIN_MODE, !agc, socket_);
|
||||
rtl_tcp_command(RTL_TCP_SET_GAIN_MODE, !agc, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set gain mode" << std::endl;
|
||||
LOG (WARNING) << "Failed to set gain mode";
|
||||
LOG(WARNING) << "Failed to set gain mode";
|
||||
}
|
||||
ec = rtl_tcp_command (RTL_TCP_SET_AGC_MODE, agc, socket_);
|
||||
ec = rtl_tcp_command(RTL_TCP_SET_AGC_MODE, agc, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set gain mode" << std::endl;
|
||||
LOG (WARNING) << "Failed to set gain mode";
|
||||
LOG(WARNING) << "Failed to set gain mode";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void rtl_tcp_signal_source_c::set_gain (int gain)
|
||||
void rtl_tcp_signal_source_c::set_gain(int gain)
|
||||
{
|
||||
unsigned clipped = static_cast<unsigned> (info_.clip_gain (gain) * 10.0);
|
||||
boost::system::error_code ec = rtl_tcp_command (RTL_TCP_SET_GAIN, clipped, socket_);
|
||||
unsigned clipped = static_cast<unsigned>(info_.clip_gain(gain) * 10.0);
|
||||
boost::system::error_code ec = rtl_tcp_command(RTL_TCP_SET_GAIN, clipped, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set gain" << std::endl;
|
||||
LOG (WARNING) << "Failed to set gain";
|
||||
LOG(WARNING) << "Failed to set gain";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void rtl_tcp_signal_source_c::set_if_gain (int gain)
|
||||
void rtl_tcp_signal_source_c::set_if_gain(int gain)
|
||||
{
|
||||
// from gr-osmosdr
|
||||
struct range {
|
||||
struct range
|
||||
{
|
||||
double start, stop, step;
|
||||
};
|
||||
if (info_.get_tuner_type () != rtl_tcp_dongle_info::TUNER_E4000)
|
||||
if (info_.get_tuner_type() != rtl_tcp_dongle_info::TUNER_E4000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<range> ranges = {
|
||||
{ -3, 6, 9 },
|
||||
{ 0, 9, 3 },
|
||||
{ 0, 9, 3 },
|
||||
{ 0, 2, 1 },
|
||||
{ 3, 15, 3},
|
||||
{ 3, 15, 3}
|
||||
};
|
||||
{-3, 6, 9},
|
||||
{0, 9, 3},
|
||||
{0, 9, 3},
|
||||
{0, 2, 1},
|
||||
{3, 15, 3},
|
||||
{3, 15, 3}};
|
||||
|
||||
std::map <int, double> gains;
|
||||
for (int i = 0; i < static_cast<int>(ranges.size ()); i++)
|
||||
std::map<int, double> gains;
|
||||
for (int i = 0; i < static_cast<int>(ranges.size()); i++)
|
||||
{
|
||||
gains[i+1] = ranges[i].start;
|
||||
gains[i + 1] = ranges[i].start;
|
||||
}
|
||||
|
||||
for (int i = ranges.size() - 1; i >= 0; i--)
|
||||
@@ -280,7 +281,7 @@ void rtl_tcp_signal_source_c::set_if_gain (int gain)
|
||||
for (double g = r.start; g < r.stop; g += r.step)
|
||||
{
|
||||
double sum = 0;
|
||||
for (int j = 0; j < static_cast<int> ( gains.size() ); j++)
|
||||
for (int j = 0; j < static_cast<int>(gains.size()); j++)
|
||||
{
|
||||
if (i == j)
|
||||
{
|
||||
@@ -291,71 +292,70 @@ void rtl_tcp_signal_source_c::set_if_gain (int gain)
|
||||
sum += gains[j + 1];
|
||||
}
|
||||
}
|
||||
double err = std::abs (gain - sum);
|
||||
double err = std::abs(gain - sum);
|
||||
if (err < error)
|
||||
{
|
||||
error = err;
|
||||
gains[i+1] = g;
|
||||
gains[i + 1] = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (unsigned stage = 1; stage <= gains.size(); stage++)
|
||||
{
|
||||
int stage_gain = static_cast<int>( gains[stage] * 10 );
|
||||
int stage_gain = static_cast<int>(gains[stage] * 10);
|
||||
unsigned param = (stage << 16) | (stage_gain & 0xffff);
|
||||
boost::system::error_code ec = rtl_tcp_command (RTL_TCP_SET_IF_GAIN, param, socket_);
|
||||
boost::system::error_code ec = rtl_tcp_command(RTL_TCP_SET_IF_GAIN, param, socket_);
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Failed to set if gain" << std::endl;
|
||||
LOG (WARNING) << "Failed to set if gain";
|
||||
LOG(WARNING) << "Failed to set if gain";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void rtl_tcp_signal_source_c::handle_read (const boost::system::error_code &ec,
|
||||
size_t bytes_transferred)
|
||||
void rtl_tcp_signal_source_c::handle_read(const boost::system::error_code &ec,
|
||||
size_t bytes_transferred)
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
std::cout << "Error during read: " << ec << std::endl;
|
||||
LOG (WARNING) << "Error during read: " << ec;
|
||||
boost::mutex::scoped_lock lock (mutex_);
|
||||
io_service_.stop ();
|
||||
not_empty_.notify_one ();
|
||||
LOG(WARNING) << "Error during read: " << ec;
|
||||
boost::mutex::scoped_lock lock(mutex_);
|
||||
io_service_.stop();
|
||||
not_empty_.notify_one();
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
// Unpack read data
|
||||
boost::mutex::scoped_lock lock (mutex_);
|
||||
not_full_.wait (lock,
|
||||
boost::bind (&rtl_tcp_signal_source_c::not_full,
|
||||
this));
|
||||
boost::mutex::scoped_lock lock(mutex_);
|
||||
not_full_.wait(lock,
|
||||
boost::bind(&rtl_tcp_signal_source_c::not_full,
|
||||
this));
|
||||
|
||||
for (size_t i = 0; i < bytes_transferred; i++)
|
||||
{
|
||||
while (!not_full( ))
|
||||
while (!not_full())
|
||||
{
|
||||
// uh-oh, buffer overflow
|
||||
// wait until there's space for more
|
||||
not_empty_.notify_one (); // needed?
|
||||
not_full_.wait (lock,
|
||||
boost::bind (&rtl_tcp_signal_source_c::not_full,
|
||||
this));
|
||||
not_empty_.notify_one(); // needed?
|
||||
not_full_.wait(lock,
|
||||
boost::bind(&rtl_tcp_signal_source_c::not_full,
|
||||
this));
|
||||
}
|
||||
|
||||
buffer_.push_front (lookup_[data_[i]]);
|
||||
buffer_.push_front(lookup_[data_[i]]);
|
||||
unread_++;
|
||||
}
|
||||
}
|
||||
// let woker know that more data is available
|
||||
not_empty_.notify_one ();
|
||||
not_empty_.notify_one();
|
||||
// Read some more
|
||||
boost::asio::async_read (socket_,
|
||||
boost::asio::buffer (data_),
|
||||
boost::bind (&rtl_tcp_signal_source_c::handle_read,
|
||||
this, _1, _2));
|
||||
boost::asio::async_read(socket_,
|
||||
boost::asio::buffer(data_),
|
||||
boost::bind(&rtl_tcp_signal_source_c::handle_read,
|
||||
this, _1, _2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@
|
||||
class rtl_tcp_signal_source_c;
|
||||
|
||||
typedef boost::shared_ptr<rtl_tcp_signal_source_c>
|
||||
rtl_tcp_signal_source_c_sptr;
|
||||
rtl_tcp_signal_source_c_sptr;
|
||||
|
||||
rtl_tcp_signal_source_c_sptr
|
||||
rtl_tcp_make_signal_source_c(const std::string &address,
|
||||
short port,
|
||||
bool flip_iq = false);
|
||||
short port,
|
||||
bool flip_iq = false);
|
||||
|
||||
/*!
|
||||
* \brief This class reads interleaved I/Q samples
|
||||
@@ -66,27 +66,27 @@ class rtl_tcp_signal_source_c : public gr::sync_block
|
||||
public:
|
||||
~rtl_tcp_signal_source_c();
|
||||
|
||||
int work (int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
int work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
|
||||
void set_frequency (int frequency);
|
||||
void set_sample_rate (int sample_rate);
|
||||
void set_agc_mode (bool agc);
|
||||
void set_gain (int gain);
|
||||
void set_if_gain (int gain);
|
||||
void set_frequency(int frequency);
|
||||
void set_sample_rate(int sample_rate);
|
||||
void set_agc_mode(bool agc);
|
||||
void set_gain(int gain);
|
||||
void set_if_gain(int gain);
|
||||
|
||||
private:
|
||||
typedef boost::circular_buffer_space_optimized<float> buffer_type;
|
||||
|
||||
friend rtl_tcp_signal_source_c_sptr
|
||||
rtl_tcp_make_signal_source_c(const std::string &address,
|
||||
short port,
|
||||
bool flip_iq);
|
||||
short port,
|
||||
bool flip_iq);
|
||||
|
||||
rtl_tcp_signal_source_c(const std::string &address,
|
||||
short port,
|
||||
bool flip_iq);
|
||||
short port,
|
||||
bool flip_iq);
|
||||
|
||||
rtl_tcp_dongle_info info_;
|
||||
|
||||
@@ -107,18 +107,18 @@ private:
|
||||
boost::array<float, 0xff> lookup_;
|
||||
|
||||
// async read callback
|
||||
void handle_read (const boost::system::error_code &ec,
|
||||
size_t bytes_transferred);
|
||||
void handle_read(const boost::system::error_code &ec,
|
||||
size_t bytes_transferred);
|
||||
|
||||
inline bool not_full ( ) const
|
||||
inline bool not_full() const
|
||||
{
|
||||
return unread_ < buffer_.capacity( );
|
||||
return unread_ < buffer_.capacity();
|
||||
}
|
||||
|
||||
inline bool not_empty ( ) const
|
||||
inline bool not_empty() const
|
||||
{
|
||||
return unread_ > 0 || io_service_.stopped ();
|
||||
return unread_ > 0 || io_service_.stopped();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_C_H
|
||||
#endif // GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_C_H
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
|
||||
struct byte_2bit_struct
|
||||
{
|
||||
signed sample_0:2; // <- 2 bits wide only
|
||||
signed sample_1:2; // <- 2 bits wide only
|
||||
signed sample_2:2; // <- 2 bits wide only
|
||||
signed sample_3:2; // <- 2 bits wide only
|
||||
signed sample_0 : 2; // <- 2 bits wide only
|
||||
signed sample_1 : 2; // <- 2 bits wide only
|
||||
signed sample_2 : 2; // <- 2 bits wide only
|
||||
signed sample_3 : 2; // <- 2 bits wide only
|
||||
};
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ bool systemIsBigEndian()
|
||||
char c[4];
|
||||
} test_int = {0x01020304};
|
||||
|
||||
return test_int.c[0] == 1;
|
||||
return test_int.c[0] == 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,12 +64,14 @@ bool systemBytesAreBigEndian()
|
||||
{
|
||||
byte_and_samples b;
|
||||
b.byte = static_cast<int8_t>(0x01);
|
||||
if(*(char *)&b.byte == 1) return false;
|
||||
else return true;
|
||||
if (*(char *)&b.byte == 1)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void swapEndianness( int8_t const *in, std::vector< int8_t > &out, size_t item_size, unsigned int ninput_items )
|
||||
void swapEndianness(int8_t const *in, std::vector<int8_t> &out, size_t item_size, unsigned int ninput_items)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int j = 0;
|
||||
@@ -77,11 +79,11 @@ void swapEndianness( int8_t const *in, std::vector< int8_t > &out, size_t item_s
|
||||
int l = 0;
|
||||
size_t skip = item_size - 1;
|
||||
|
||||
for( i = 0; i < ninput_items; ++i )
|
||||
for (i = 0; i < ninput_items; ++i)
|
||||
{
|
||||
k = j + skip;
|
||||
l = j;
|
||||
while( k >= l )
|
||||
while (k >= l)
|
||||
{
|
||||
out[j++] = in[k--];
|
||||
}
|
||||
@@ -89,28 +91,27 @@ void swapEndianness( int8_t const *in, std::vector< int8_t > &out, size_t item_s
|
||||
}
|
||||
|
||||
|
||||
unpack_2bit_samples_sptr make_unpack_2bit_samples( bool big_endian_bytes,
|
||||
size_t item_size,
|
||||
bool big_endian_items,
|
||||
bool reverse_interleaving )
|
||||
unpack_2bit_samples_sptr make_unpack_2bit_samples(bool big_endian_bytes,
|
||||
size_t item_size,
|
||||
bool big_endian_items,
|
||||
bool reverse_interleaving)
|
||||
{
|
||||
return unpack_2bit_samples_sptr(
|
||||
new unpack_2bit_samples( big_endian_bytes,
|
||||
item_size,
|
||||
big_endian_items,
|
||||
reverse_interleaving )
|
||||
);
|
||||
new unpack_2bit_samples(big_endian_bytes,
|
||||
item_size,
|
||||
big_endian_items,
|
||||
reverse_interleaving));
|
||||
}
|
||||
|
||||
|
||||
unpack_2bit_samples::unpack_2bit_samples( bool big_endian_bytes,
|
||||
size_t item_size,
|
||||
bool big_endian_items,
|
||||
bool reverse_interleaving )
|
||||
unpack_2bit_samples::unpack_2bit_samples(bool big_endian_bytes,
|
||||
size_t item_size,
|
||||
bool big_endian_items,
|
||||
bool reverse_interleaving)
|
||||
: sync_interpolator("unpack_2bit_samples",
|
||||
gr::io_signature::make(1, 1, item_size),
|
||||
gr::io_signature::make(1, 1, sizeof(char)),
|
||||
4*item_size ), // we make 4 bytes out for every byte in
|
||||
gr::io_signature::make(1, 1, item_size),
|
||||
gr::io_signature::make(1, 1, sizeof(char)),
|
||||
4 * item_size), // we make 4 bytes out for every byte in
|
||||
big_endian_bytes_(big_endian_bytes),
|
||||
item_size_(item_size),
|
||||
big_endian_items_(big_endian_items),
|
||||
@@ -119,38 +120,39 @@ unpack_2bit_samples::unpack_2bit_samples( bool big_endian_bytes,
|
||||
{
|
||||
bool big_endian_system = systemIsBigEndian();
|
||||
|
||||
// Only swap the item bytes if the item size > 1 byte and the system
|
||||
// Only swap the item bytes if the item size > 1 byte and the system
|
||||
// endianess is not the same as the item endianness:
|
||||
swap_endian_items_ = ( item_size_ > 1 ) &&
|
||||
( big_endian_system != big_endian_items);
|
||||
swap_endian_items_ = (item_size_ > 1) &&
|
||||
(big_endian_system != big_endian_items);
|
||||
|
||||
bool big_endian_bytes_system = systemBytesAreBigEndian();
|
||||
|
||||
swap_endian_bytes_ = ( big_endian_bytes_system != big_endian_bytes_ );
|
||||
swap_endian_bytes_ = (big_endian_bytes_system != big_endian_bytes_);
|
||||
}
|
||||
|
||||
|
||||
unpack_2bit_samples::~unpack_2bit_samples()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int unpack_2bit_samples::work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
signed char const *in = reinterpret_cast<signed char const *>(input_items[0]);
|
||||
int8_t *out = reinterpret_cast<int8_t*>(output_items[0]);
|
||||
int8_t *out = reinterpret_cast<int8_t *>(output_items[0]);
|
||||
|
||||
size_t ninput_bytes = noutput_items/4;
|
||||
size_t ninput_items = ninput_bytes/item_size_;
|
||||
size_t ninput_bytes = noutput_items / 4;
|
||||
size_t ninput_items = ninput_bytes / item_size_;
|
||||
|
||||
// Handle endian swap if needed
|
||||
if( swap_endian_items_ )
|
||||
if (swap_endian_items_)
|
||||
{
|
||||
work_buffer_.reserve( ninput_bytes );
|
||||
swapEndianness( in, work_buffer_, item_size_, ninput_items );
|
||||
work_buffer_.reserve(ninput_bytes);
|
||||
swapEndianness(in, work_buffer_, item_size_, ninput_items);
|
||||
|
||||
in = const_cast< signed char const *> ( &work_buffer_[0] );
|
||||
in = const_cast<signed char const *>(&work_buffer_[0]);
|
||||
}
|
||||
|
||||
// Here the in pointer can be interpreted as a stream of bytes to be
|
||||
@@ -161,65 +163,64 @@ int unpack_2bit_samples::work(int noutput_items,
|
||||
byte_and_samples raw_byte;
|
||||
int n = 0;
|
||||
|
||||
if( !reverse_interleaving_ )
|
||||
if (!reverse_interleaving_)
|
||||
{
|
||||
if( swap_endian_bytes_ )
|
||||
if (swap_endian_bytes_)
|
||||
{
|
||||
for(unsigned int i = 0; i < ninput_bytes; ++i)
|
||||
for (unsigned int i = 0; i < ninput_bytes; ++i)
|
||||
{
|
||||
// Read packed input sample (1 byte = 4 samples)
|
||||
raw_byte.byte = in[i];
|
||||
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_3 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_2 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_1 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_0 + 1 );
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_3 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_2 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_1 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_0 + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(unsigned int i = 0; i < ninput_bytes; ++i )
|
||||
for (unsigned int i = 0; i < ninput_bytes; ++i)
|
||||
{
|
||||
// Read packed input sample (1 byte = 4 samples)
|
||||
raw_byte.byte = in[i];
|
||||
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_0 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_1 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_2 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_3 + 1 );
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_0 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_1 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_2 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_3 + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( swap_endian_bytes_ )
|
||||
if (swap_endian_bytes_)
|
||||
{
|
||||
for(unsigned int i = 0; i < ninput_bytes; ++i)
|
||||
for (unsigned int i = 0; i < ninput_bytes; ++i)
|
||||
{
|
||||
// Read packed input sample (1 byte = 4 samples)
|
||||
raw_byte.byte = in[i];
|
||||
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_2 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_3 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_0 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_1 + 1 );
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_2 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_3 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_0 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_1 + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(unsigned int i = 0; i < ninput_bytes; ++i )
|
||||
for (unsigned int i = 0; i < ninput_bytes; ++i)
|
||||
{
|
||||
// Read packed input sample (1 byte = 4 samples)
|
||||
raw_byte.byte = in[i];
|
||||
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_1 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_0 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_3 + 1 );
|
||||
out[n++] = static_cast<int8_t>( 2*raw_byte.samples.sample_2 + 1 );
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_1 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_0 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_3 + 1);
|
||||
out[n++] = static_cast<int8_t>(2 * raw_byte.samples.sample_2 + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return noutput_items;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,43 +75,43 @@ class unpack_2bit_samples;
|
||||
|
||||
typedef boost::shared_ptr<unpack_2bit_samples> unpack_2bit_samples_sptr;
|
||||
|
||||
unpack_2bit_samples_sptr make_unpack_2bit_samples( bool big_endian_bytes,
|
||||
size_t item_size,
|
||||
bool big_endian_items,
|
||||
bool reverse_interleaving = false );
|
||||
unpack_2bit_samples_sptr make_unpack_2bit_samples(bool big_endian_bytes,
|
||||
size_t item_size,
|
||||
bool big_endian_items,
|
||||
bool reverse_interleaving = false);
|
||||
|
||||
/*!
|
||||
* \brief This class takes 2 bit samples that have been packed into bytes or
|
||||
* shorts as input and generates a byte for each sample. It generates eight
|
||||
* times as much data as is input (every two bits become 16 bits)
|
||||
*/
|
||||
class unpack_2bit_samples: public gr::sync_interpolator
|
||||
class unpack_2bit_samples : public gr::sync_interpolator
|
||||
{
|
||||
private:
|
||||
friend unpack_2bit_samples_sptr
|
||||
make_unpack_2bit_samples_sptr( bool big_endian_bytes,
|
||||
size_t item_size,
|
||||
bool big_endian_items,
|
||||
bool reverse_interleaving);
|
||||
make_unpack_2bit_samples_sptr(bool big_endian_bytes,
|
||||
size_t item_size,
|
||||
bool big_endian_items,
|
||||
bool reverse_interleaving);
|
||||
bool big_endian_bytes_;
|
||||
size_t item_size_;
|
||||
bool big_endian_items_;
|
||||
bool swap_endian_items_;
|
||||
bool swap_endian_bytes_;
|
||||
bool reverse_interleaving_;
|
||||
std::vector< int8_t > work_buffer_;
|
||||
std::vector<int8_t> work_buffer_;
|
||||
|
||||
public:
|
||||
unpack_2bit_samples( bool big_endianBytes,
|
||||
size_t item_size,
|
||||
bool big_endian_items,
|
||||
bool reverse_interleaving );
|
||||
unpack_2bit_samples(bool big_endianBytes,
|
||||
size_t item_size,
|
||||
bool big_endian_items,
|
||||
bool reverse_interleaving);
|
||||
|
||||
~unpack_2bit_samples();
|
||||
|
||||
int work (int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
int work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
struct byte_2bit_struct
|
||||
{
|
||||
signed two_bit_sample:2; // <- 2 bits wide only
|
||||
signed two_bit_sample : 2; // <- 2 bits wide only
|
||||
};
|
||||
|
||||
|
||||
@@ -49,26 +49,28 @@ unpack_byte_2bit_cpx_samples_sptr make_unpack_byte_2bit_cpx_samples()
|
||||
|
||||
|
||||
unpack_byte_2bit_cpx_samples::unpack_byte_2bit_cpx_samples() : sync_interpolator("unpack_byte_2bit_cpx_samples",
|
||||
gr::io_signature::make(1, 1, sizeof(signed char)),
|
||||
gr::io_signature::make(1, 1, sizeof(short)),
|
||||
4)
|
||||
{}
|
||||
gr::io_signature::make(1, 1, sizeof(signed char)),
|
||||
gr::io_signature::make(1, 1, sizeof(short)),
|
||||
4)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unpack_byte_2bit_cpx_samples::~unpack_byte_2bit_cpx_samples()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int unpack_byte_2bit_cpx_samples::work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
const signed char *in = reinterpret_cast<const signed char *>(input_items[0]);
|
||||
short *out = reinterpret_cast<short *>(output_items[0]);
|
||||
|
||||
byte_2bit_struct sample;
|
||||
int n = 0;
|
||||
for(int i = 0; i < noutput_items/4; i++)
|
||||
for (int i = 0; i < noutput_items / 4; i++)
|
||||
{
|
||||
// Read packed input sample (1 byte = 2 complex samples)
|
||||
//* Packing Order
|
||||
|
||||
@@ -47,7 +47,7 @@ unpack_byte_2bit_cpx_samples_sptr make_unpack_byte_2bit_cpx_samples();
|
||||
* \brief This class implements conversion between byte packet samples to 2bit_cpx samples
|
||||
* 1 byte = 2 x complex 2bit I, + 2bit Q samples
|
||||
*/
|
||||
class unpack_byte_2bit_cpx_samples: public gr::sync_interpolator
|
||||
class unpack_byte_2bit_cpx_samples : public gr::sync_interpolator
|
||||
{
|
||||
private:
|
||||
friend unpack_byte_2bit_cpx_samples_sptr make_unpack_byte_2bit_cpx_samples_sptr();
|
||||
@@ -55,9 +55,9 @@ private:
|
||||
public:
|
||||
unpack_byte_2bit_cpx_samples();
|
||||
~unpack_byte_2bit_cpx_samples();
|
||||
int work (int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
int work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
struct byte_2bit_struct
|
||||
{
|
||||
signed two_bit_sample:2; // <- 2 bits wide only
|
||||
signed two_bit_sample : 2; // <- 2 bits wide only
|
||||
};
|
||||
|
||||
|
||||
@@ -45,39 +45,41 @@ unpack_byte_2bit_samples_sptr make_unpack_byte_2bit_samples()
|
||||
|
||||
|
||||
unpack_byte_2bit_samples::unpack_byte_2bit_samples() : sync_interpolator("unpack_byte_2bit_samples",
|
||||
gr::io_signature::make(1, 1, sizeof(signed char)),
|
||||
gr::io_signature::make(1, 1, sizeof(float)),
|
||||
4)
|
||||
{}
|
||||
gr::io_signature::make(1, 1, sizeof(signed char)),
|
||||
gr::io_signature::make(1, 1, sizeof(float)),
|
||||
4)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unpack_byte_2bit_samples::~unpack_byte_2bit_samples()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int unpack_byte_2bit_samples::work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
const signed char *in = reinterpret_cast<const signed char *>(input_items[0]);
|
||||
float *out = reinterpret_cast<float *>(output_items[0]);
|
||||
|
||||
byte_2bit_struct sample;
|
||||
int n = 0;
|
||||
for(int i = 0; i < noutput_items/4; i++)
|
||||
for (int i = 0; i < noutput_items / 4; i++)
|
||||
{
|
||||
// Read packed input sample (1 byte = 4 samples)
|
||||
signed char c = in[i];
|
||||
sample.two_bit_sample = c & 3;
|
||||
out[n++] = static_cast<float>(sample.two_bit_sample);
|
||||
|
||||
sample.two_bit_sample = (c>>2) & 3;
|
||||
sample.two_bit_sample = (c >> 2) & 3;
|
||||
out[n++] = static_cast<float>(sample.two_bit_sample);
|
||||
|
||||
sample.two_bit_sample = (c>>4) & 3;
|
||||
sample.two_bit_sample = (c >> 4) & 3;
|
||||
out[n++] = static_cast<float>(sample.two_bit_sample);
|
||||
|
||||
sample.two_bit_sample = (c>>6) & 3;
|
||||
sample.two_bit_sample = (c >> 6) & 3;
|
||||
out[n++] = static_cast<float>(sample.two_bit_sample);
|
||||
}
|
||||
return noutput_items;
|
||||
|
||||
@@ -43,7 +43,7 @@ unpack_byte_2bit_samples_sptr make_unpack_byte_2bit_samples();
|
||||
* \brief This class implements conversion between byte packet samples to 2bit samples
|
||||
* 1 byte = 4 2bit samples
|
||||
*/
|
||||
class unpack_byte_2bit_samples: public gr::sync_interpolator
|
||||
class unpack_byte_2bit_samples : public gr::sync_interpolator
|
||||
{
|
||||
private:
|
||||
friend unpack_byte_2bit_samples_sptr
|
||||
@@ -52,9 +52,9 @@ private:
|
||||
public:
|
||||
unpack_byte_2bit_samples();
|
||||
~unpack_byte_2bit_samples();
|
||||
int work (int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
int work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <gnuradio/io_signature.h>
|
||||
|
||||
|
||||
|
||||
unpack_intspir_1bit_samples_sptr make_unpack_intspir_1bit_samples()
|
||||
{
|
||||
return unpack_intspir_1bit_samples_sptr(new unpack_intspir_1bit_samples());
|
||||
@@ -41,31 +40,33 @@ unpack_intspir_1bit_samples_sptr make_unpack_intspir_1bit_samples()
|
||||
|
||||
|
||||
unpack_intspir_1bit_samples::unpack_intspir_1bit_samples() : sync_interpolator("unpack_intspir_1bit_samples",
|
||||
gr::io_signature::make(1, 1, sizeof(int)),
|
||||
gr::io_signature::make(1, 1, sizeof(float)),
|
||||
2)
|
||||
{}
|
||||
gr::io_signature::make(1, 1, sizeof(int)),
|
||||
gr::io_signature::make(1, 1, sizeof(float)),
|
||||
2)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unpack_intspir_1bit_samples::~unpack_intspir_1bit_samples()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int unpack_intspir_1bit_samples::work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
const signed int *in = reinterpret_cast<const signed int *>(input_items[0]);
|
||||
float *out = reinterpret_cast<float*>(output_items[0]);
|
||||
float *out = reinterpret_cast<float *>(output_items[0]);
|
||||
|
||||
int n = 0;
|
||||
int channel = 1;
|
||||
for(int i = 0; i < noutput_items/2; i++)
|
||||
for (int i = 0; i < noutput_items / 2; i++)
|
||||
{
|
||||
// Read packed input sample (1 byte = 1 complex sample)
|
||||
// For historical reasons, values are float versions of short int limits (32767)
|
||||
signed int val = in[i];
|
||||
if(((val >> ((channel - 1)*2)) & 1) == 1)
|
||||
if (((val >> ((channel - 1) * 2)) & 1) == 1)
|
||||
{
|
||||
out[n++] = static_cast<float>(32767.0);
|
||||
}
|
||||
@@ -73,7 +74,7 @@ int unpack_intspir_1bit_samples::work(int noutput_items,
|
||||
{
|
||||
out[n++] = static_cast<float>(-32767.0);
|
||||
}
|
||||
if(((val >> (2*channel - 1)) & 1) == 1)
|
||||
if (((val >> (2 * channel - 1)) & 1) == 1)
|
||||
{
|
||||
out[n++] = static_cast<float>(32767.0);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ unpack_intspir_1bit_samples_sptr make_unpack_intspir_1bit_samples();
|
||||
* \brief This class implements conversion between byte packet samples to 2bit samples
|
||||
* 1 byte = 4 2bit samples
|
||||
*/
|
||||
class unpack_intspir_1bit_samples: public gr::sync_interpolator
|
||||
class unpack_intspir_1bit_samples : public gr::sync_interpolator
|
||||
{
|
||||
private:
|
||||
friend unpack_intspir_1bit_samples_sptr
|
||||
@@ -52,9 +52,9 @@ private:
|
||||
public:
|
||||
unpack_intspir_1bit_samples();
|
||||
~unpack_intspir_1bit_samples();
|
||||
int work (int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
int work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -40,8 +40,8 @@ unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int a
|
||||
|
||||
|
||||
unpack_spir_gss6450_samples::unpack_spir_gss6450_samples(unsigned int adc_nbit) : gr::sync_interpolator("unpack_spir_gss6450_samples",
|
||||
gr::io_signature::make(1, 1, sizeof(int)),
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)), 16 / adc_nbit)
|
||||
gr::io_signature::make(1, 1, sizeof(int)),
|
||||
gr::io_signature::make(1, 1, sizeof(gr_complex)), 16 / adc_nbit)
|
||||
{
|
||||
adc_bits = adc_nbit;
|
||||
samples_per_int = 16 / adc_bits;
|
||||
@@ -53,43 +53,50 @@ unpack_spir_gss6450_samples::unpack_spir_gss6450_samples(unsigned int adc_nbit)
|
||||
|
||||
|
||||
unpack_spir_gss6450_samples::~unpack_spir_gss6450_samples()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int unpack_spir_gss6450_samples::work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
|
||||
gr_vector_const_void_star& input_items, gr_vector_void_star& output_items)
|
||||
{
|
||||
const int* in = reinterpret_cast<const int*>(input_items[0]);
|
||||
gr_complex* out = reinterpret_cast<gr_complex*>(output_items[0]);
|
||||
unsigned int n_sample = 0;
|
||||
unsigned int in_counter = 0;
|
||||
std::bitset<32> bs;
|
||||
for(int i = 0; i < noutput_items; i++)
|
||||
{
|
||||
bs = in[in_counter];
|
||||
int i_shift = adc_bits * 2 * (samples_per_int - n_sample - 1) + adc_bits;
|
||||
int q_shift = adc_bits * 2 * (samples_per_int - n_sample - 1);
|
||||
for(unsigned int k = 0; k < adc_bits; k++)
|
||||
for (int i = 0; i < noutput_items; i++)
|
||||
{
|
||||
i_data[k] = bs[i_shift + k];
|
||||
q_data[k] = bs[q_shift + k];
|
||||
bs = in[in_counter];
|
||||
int i_shift = adc_bits * 2 * (samples_per_int - n_sample - 1) + adc_bits;
|
||||
int q_shift = adc_bits * 2 * (samples_per_int - n_sample - 1);
|
||||
for (unsigned int k = 0; k < adc_bits; k++)
|
||||
{
|
||||
i_data[k] = bs[i_shift + k];
|
||||
q_data[k] = bs[q_shift + k];
|
||||
}
|
||||
out[i] = gr_complex(static_cast<float>(compute_two_complement(i_data.to_ulong())) + 0.5,
|
||||
static_cast<float>(compute_two_complement(q_data.to_ulong())) + 0.5);
|
||||
n_sample++;
|
||||
if (n_sample == samples_per_int)
|
||||
{
|
||||
n_sample = 0;
|
||||
in_counter++;
|
||||
}
|
||||
}
|
||||
out[i] = gr_complex(static_cast<float>(compute_two_complement(i_data.to_ulong())) + 0.5,
|
||||
static_cast<float>(compute_two_complement(q_data.to_ulong())) + 0.5);
|
||||
n_sample++;
|
||||
if(n_sample == samples_per_int)
|
||||
{
|
||||
n_sample = 0;
|
||||
in_counter++;
|
||||
}
|
||||
}
|
||||
return noutput_items;
|
||||
}
|
||||
|
||||
int unpack_spir_gss6450_samples::compute_two_complement(unsigned long data)
|
||||
{
|
||||
int res = 0;
|
||||
if( static_cast<int>(data) < two_compl_thres) { res = static_cast<int>(data); }
|
||||
else { res = static_cast<int>(data) - adc_bits_two_pow; }
|
||||
if (static_cast<int>(data) < two_compl_thres)
|
||||
{
|
||||
res = static_cast<int>(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = static_cast<int>(data) - adc_bits_two_pow;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@ typedef boost::shared_ptr<unpack_spir_gss6450_samples> unpack_spir_gss6450_sampl
|
||||
unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int adc_nbit);
|
||||
|
||||
|
||||
class unpack_spir_gss6450_samples: public gr::sync_interpolator
|
||||
class unpack_spir_gss6450_samples : public gr::sync_interpolator
|
||||
{
|
||||
public:
|
||||
int work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
|
||||
friend unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples_sptr(unsigned int adc_nbit);
|
||||
unpack_spir_gss6450_samples(unsigned int adc_nbit);
|
||||
~unpack_spir_gss6450_samples();
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "rtl_tcp_commands.h"
|
||||
#include <string>
|
||||
|
||||
boost::system::error_code rtl_tcp_command (RTL_TCP_COMMAND id, unsigned param, boost::asio::ip::tcp::socket &socket)
|
||||
boost::system::error_code rtl_tcp_command(RTL_TCP_COMMAND id, unsigned param, boost::asio::ip::tcp::socket &socket)
|
||||
{
|
||||
// Data payload
|
||||
unsigned char data[sizeof(unsigned char) + sizeof(unsigned)];
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
|
||||
/// Command IDs for configuration rtl_tcp
|
||||
enum RTL_TCP_COMMAND {
|
||||
enum RTL_TCP_COMMAND
|
||||
{
|
||||
RTL_TCP_SET_FREQUENCY = 1,
|
||||
RTL_TCP_SET_SAMPLE_RATE = 2,
|
||||
RTL_TCP_SET_GAIN_MODE = 3,
|
||||
@@ -48,7 +49,7 @@ enum RTL_TCP_COMMAND {
|
||||
/*!
|
||||
* \brief Send a command to rtl_tcp over the given socket.
|
||||
*/
|
||||
boost::system::error_code rtl_tcp_command (RTL_TCP_COMMAND id, unsigned param,
|
||||
boost::asio::ip::tcp::socket &socket);
|
||||
boost::system::error_code rtl_tcp_command(RTL_TCP_COMMAND id, unsigned param,
|
||||
boost::asio::ip::tcp::socket &socket);
|
||||
|
||||
#endif // GNSS_SDR_RTL_TCP_COMMANDS_H
|
||||
#endif // GNSS_SDR_RTL_TCP_COMMANDS_H
|
||||
|
||||
@@ -69,23 +69,23 @@ boost::system::error_code rtl_tcp_dongle_info::read(boost::asio::ip::tcp::socket
|
||||
|
||||
const char *rtl_tcp_dongle_info::get_type_name() const
|
||||
{
|
||||
switch(get_tuner_type())
|
||||
{
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
case TUNER_E4000:
|
||||
return "E4000";
|
||||
case TUNER_FC0012:
|
||||
return "FC0012";
|
||||
case TUNER_FC0013:
|
||||
return "FC0013";
|
||||
case TUNER_FC2580:
|
||||
return "FC2580";
|
||||
case TUNER_R820T:
|
||||
return "R820T";
|
||||
case TUNER_R828D:
|
||||
return "R828D";
|
||||
}
|
||||
switch (get_tuner_type())
|
||||
{
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
case TUNER_E4000:
|
||||
return "E4000";
|
||||
case TUNER_FC0012:
|
||||
return "FC0012";
|
||||
case TUNER_FC0013:
|
||||
return "FC0013";
|
||||
case TUNER_FC2580:
|
||||
return "FC2580";
|
||||
case TUNER_R820T:
|
||||
return "R820T";
|
||||
case TUNER_R828D:
|
||||
return "R828D";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,29 +96,29 @@ double rtl_tcp_dongle_info::clip_gain(int gain) const
|
||||
|
||||
std::vector<double> gains;
|
||||
switch (get_tuner_type())
|
||||
{
|
||||
case TUNER_E4000:
|
||||
gains = { -10, 15, 40, 65, 90, 115, 140, 165, 190, 215,
|
||||
240, 290, 340, 420 };
|
||||
break;
|
||||
case TUNER_FC0012:
|
||||
gains = { -99, -40, 71, 179, 192 };
|
||||
break;
|
||||
case TUNER_FC0013:
|
||||
gains = { -99, -73, -65, -63, -60, -58, -54, 58, 61,
|
||||
{
|
||||
case TUNER_E4000:
|
||||
gains = {-10, 15, 40, 65, 90, 115, 140, 165, 190, 215,
|
||||
240, 290, 340, 420};
|
||||
break;
|
||||
case TUNER_FC0012:
|
||||
gains = {-99, -40, 71, 179, 192};
|
||||
break;
|
||||
case TUNER_FC0013:
|
||||
gains = {-99, -73, -65, -63, -60, -58, -54, 58, 61,
|
||||
63, 65, 67, 68, 70, 71, 179, 181, 182,
|
||||
184, 186, 188, 191, 197 };
|
||||
break;
|
||||
case TUNER_R820T:
|
||||
gains = { 0, 9, 14, 27, 37, 77, 87, 125, 144, 157,
|
||||
184, 186, 188, 191, 197};
|
||||
break;
|
||||
case TUNER_R820T:
|
||||
gains = {0, 9, 14, 27, 37, 77, 87, 125, 144, 157,
|
||||
166, 197, 207, 229, 254, 280, 297, 328,
|
||||
338, 364, 372, 386, 402, 421, 434, 439,
|
||||
445, 480, 496 };
|
||||
break;
|
||||
default:
|
||||
// no gains
|
||||
break;
|
||||
}
|
||||
445, 480, 496};
|
||||
break;
|
||||
default:
|
||||
// no gains
|
||||
break;
|
||||
}
|
||||
|
||||
// clip
|
||||
if (gains.size() == 0)
|
||||
@@ -130,22 +130,22 @@ double rtl_tcp_dongle_info::clip_gain(int gain) const
|
||||
{
|
||||
double last_stop = gains.front();
|
||||
BOOST_FOREACH (double g, gains)
|
||||
{
|
||||
g /= 10.0;
|
||||
{
|
||||
g /= 10.0;
|
||||
|
||||
if (gain < g)
|
||||
{
|
||||
if (std::abs(gain - g) < std::abs(gain - last_stop))
|
||||
{
|
||||
return g;
|
||||
}
|
||||
else
|
||||
{
|
||||
return last_stop;
|
||||
}
|
||||
}
|
||||
last_stop = g;
|
||||
}
|
||||
if (gain < g)
|
||||
{
|
||||
if (std::abs(gain - g) < std::abs(gain - last_stop))
|
||||
{
|
||||
return g;
|
||||
}
|
||||
else
|
||||
{
|
||||
return last_stop;
|
||||
}
|
||||
}
|
||||
last_stop = g;
|
||||
}
|
||||
return last_stop;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,4 +80,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif // GNSS_SDR_RTL_TCP_DONGLE_INFO_H
|
||||
#endif // GNSS_SDR_RTL_TCP_DONGLE_INFO_H
|
||||
|
||||
Reference in New Issue
Block a user