1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-10 12:13:07 +00:00

moving things to trunk

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@72 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez
2011-10-01 18:45:20 +00:00
parent 0d9423d5ed
commit 228fa3b797
199 changed files with 126904 additions and 0 deletions

View File

@@ -0,0 +1,252 @@
/*!
* \file file_signal_source.cc
* \brief Brief description of the file here
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
* Javier Arribas, 2011 jarribas(at)cttc.es
*
* Detailed description of the file here if needed.
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#include "file_signal_source.h"
#include "gnss_sdr_valve.h"
#include "configuration_interface.h"
#include <string>
#include <iostream>
#include <glog/log_severity.h>
#include <glog/logging.h>
#include <gnuradio/gr_io_signature.h>
using google::LogMessage;
FileSignalSource::FileSignalSource(ConfigurationInterface* configuration,
std::string role, unsigned int in_streams, unsigned int out_streams,
gr_msg_queue_sptr queue) :
role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(
queue)
{
std::string default_filename = "./signal_samples/signal.dat";
std::string default_item_type = "short";
std::string default_dump_filename = "./data/signal_source.dat";
samples_ = configuration->property(role + ".samples", 0);
sampling_frequency_ = configuration->property(role
+ ".sampling_frequency", 0);
filename_ = configuration->property(role + ".filename", default_filename);
item_type_ = configuration->property(role + ".item_type",
default_item_type);
repeat_ = configuration->property(role + ".repeat", false);
dump_ = configuration->property(role + ".dump", false);
dump_filename_ = configuration->property(role + ".dump_filename",
default_dump_filename);
enable_throttle_control_ = configuration->property(role
+ ".enable_throttle_control", false);
if (item_type_.compare("gr_complex") == 0)
{
item_size_ = sizeof(gr_complex);
}
else if (item_type_.compare("float") == 0)
{
item_size_ = sizeof(float);
}
else if (item_type_.compare("short") == 0)
{
item_size_ = sizeof(short);
}
else
{
LOG_AT_LEVEL(WARNING) << item_type_
<< " unrecognized item type. Using short.";
item_size_ = sizeof(short);
}
file_source_
= gr_make_file_source(item_size_, filename_.c_str(), repeat_);
DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")";
// if samples != 0 then enable a flow valve to stop the process after n samples
if (samples_ != 0)
{
valve_ = gnss_sdr_make_valve(item_size_, samples_, queue_);
DLOG(INFO) << "valve(" << valve_->unique_id() << ")";
}
if (dump_)
{
sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str());
DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")";
}
if (enable_throttle_control_)
{
throttle_ = gr_make_throttle(item_size_, sampling_frequency_);
}
DLOG(INFO) << "File source filename " << filename_;
DLOG(INFO) << "Samples " << samples_;
DLOG(INFO) << "Sampling frequency " << sampling_frequency_;
DLOG(INFO) << "Item type " << item_type_;
DLOG(INFO) << "Item size " << item_size_;
DLOG(INFO) << "Repeat " << repeat_;
DLOG(INFO) << "Dump " << dump_;
DLOG(INFO) << "Dump filename " << dump_filename_;
}
FileSignalSource::~FileSignalSource()
{
}
void FileSignalSource::connect(gr_top_block_sptr top_block)
{
if (samples_ != 0)
{
if (enable_throttle_control_ == true)
{
top_block->connect(file_source_, 0, throttle_, 0);
DLOG(INFO) << "connected file source to throttle";
top_block->connect(throttle_, 0, valve_, 0);
DLOG(INFO) << "connected throttle to valve";
if (dump_)
{
top_block->connect(valve_, 0, sink_, 0);
DLOG(INFO) << "connected valve to file sink";
}
}
else
{
top_block->connect(file_source_, 0, valve_, 0);
DLOG(INFO) << "connected file source to valve";
if (dump_)
{
top_block->connect(valve_, 0, sink_, 0);
DLOG(INFO) << "connected valve to file sink";
}
}
}
else
{
if (enable_throttle_control_ == true)
{
top_block->connect(file_source_, 0, throttle_, 0);
DLOG(INFO) << "connected file source to throttle";
if (dump_)
{
top_block->connect(file_source_, 0, sink_, 0);
DLOG(INFO) << "connected file source to sink";
}
}
else
{
if (dump_)
{
top_block->connect(file_source_, 0, sink_, 0);
DLOG(INFO) << "connected file source to sink";
}
}
}
}
void FileSignalSource::disconnect(gr_top_block_sptr top_block)
{
if (samples_ != 0)
{
if (enable_throttle_control_ == true)
{
top_block->disconnect(file_source_, 0, throttle_, 0);
DLOG(INFO) << "disconnected file source to throttle";
top_block->disconnect(throttle_, 0, valve_, 0);
DLOG(INFO) << "disconnected throttle to valve";
if (dump_)
{
top_block->disconnect(valve_, 0, sink_, 0);
DLOG(INFO) << "disconnected valve to file sink";
}
}
else
{
top_block->disconnect(file_source_, 0, valve_, 0);
DLOG(INFO) << "disconnected file source to valve";
if (dump_)
{
top_block->disconnect(valve_, 0, sink_, 0);
DLOG(INFO) << "disconnected valve to file sink";
}
}
}
else
{
if (enable_throttle_control_ == true)
{
top_block->disconnect(file_source_, 0, throttle_, 0);
DLOG(INFO) << "disconnected file source to throttle";
if (dump_)
{
top_block->disconnect(file_source_, 0, sink_, 0);
DLOG(INFO) << "disconnected file source to sink";
}
}
else
{
if (dump_)
{
top_block->disconnect(file_source_, 0, sink_, 0);
DLOG(INFO) << "disconnected file source to sink";
}
}
}
}
gr_basic_block_sptr FileSignalSource::get_left_block()
{
LOG_AT_LEVEL(WARNING)
<< "Left block of a signal source should not be retrieved";
return gr_block_sptr();
}
gr_basic_block_sptr FileSignalSource::get_right_block()
{
if (samples_ != 0)
{
return valve_;
}
else
{
if (enable_throttle_control_ == true)
{
return throttle_;
}
else
{
return file_source_;
}
}
}

View File

@@ -0,0 +1,123 @@
/*!
* \file file_signal_source.h
* \brief Brief description of the file here
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
*
* This class represents a file signal source. Internally it uses a GNU Radio's gr_file_source
* a a connector to the data.
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef FILE_SIGNAL_SOURCE_H_
#define FILE_SIGNAL_SOURCE_H_
#include "gnss_block_interface.h"
#include <gnuradio/gr_file_source.h>
#include <gnuradio/gr_file_sink.h>
#include <gnuradio/gr_throttle.h>
#include <gnuradio/gr_hier_block2.h>
#include <gnuradio/gr_msg_queue.h>
class ConfigurationInterface;
class FileSignalSource: public GNSSBlockInterface
{
public:
FileSignalSource(ConfigurationInterface* configuration, std::string role,
unsigned int in_streams, unsigned int out_streams,
gr_msg_queue_sptr queue);
virtual ~FileSignalSource();
std::string role()
{
return role_;
}
std::string implementation()
{
return "FileSignalSource";
}
size_t item_size()
{
return item_size_;
}
void connect(gr_top_block_sptr top_block);
void disconnect(gr_top_block_sptr top_block);
gr_basic_block_sptr get_left_block();
gr_basic_block_sptr get_right_block();
std::string filename()
{
return filename_;
}
std::string item_type()
{
return item_type_;
}
bool repeat()
{
return repeat_;
}
long sampling_frequency()
{
return sampling_frequency_;
}
long samples()
{
return samples_;
}
private:
long samples_;
long sampling_frequency_;
std::string filename_;
std::string item_type_;
bool repeat_;
bool dump_;
std::string dump_filename_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
gr_file_source_sptr file_source_;
gr_block_sptr valve_;
gr_block_sptr sink_;
gr_block_sptr throttle_;
gr_msg_queue_sptr queue_;
size_t item_size_;
// Throttle control
bool enable_throttle_control_;
};
#endif /*FILE_SIGNAL_SOURCE_H_*/

View File

@@ -0,0 +1,4 @@
project : build-dir ../../../../build ;
obj file_signal_source : file_signal_source.cc ;
obj usrp1_signal_source : usrp1_signal_source.cc ;

View File

@@ -0,0 +1,219 @@
/*!
* \file usrp1_signal_source.cc
* \brief Brief description of the file here
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
*
* Detailed description of the file here if needed.
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#include "usrp1_signal_source.h"
#include <gnuradio/usrp_source_s.h>
#include <gnuradio/usrp_source_c.h>
#include <gnuradio/gr_file_sink.h>
#include "configuration_interface.h"
#include "gnss_sdr_valve.h"
#include <glog/log_severity.h>
#include <glog/logging.h>
using google::LogMessage;
Usrp1SignalSource::Usrp1SignalSource(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 empty = "";
std::string default_dump_file = "./data/signal_source.dat";
std::string default_item_type = "short";
which_board_ = configuration->property(role + ".which_board", 0);
decim_rate_ = configuration->property(role + ".decim_rate", 16);
nchan_ = configuration->property(role + ".nchan", 1);
mux_ = configuration->property(role + ".mux", -1);
mode_ = configuration->property(role + ".mode", 0);
fusb_block_size_ = configuration->property(role + ".fusb_block_size", 0);
fusb_nblocks_ = configuration->property(role + ".fusb_nblocks", 0);
fpga_filename_ = configuration->property(role + ".fpga_filename", empty);
firmware_filename_ = configuration->property(role + ".firmware_filename",
empty);
spec_side_ = configuration->property(role + ".spec_side", 0);
spec_subdev_ = configuration->property(role + ".spec_subdev", 0);
freq_ = configuration->property(role + ".freq", (double)1.57542e9);
gain_ = configuration->property(role + ".gain", (float)40.0);
item_type_ = configuration->property(role + ".item_type",
default_item_type);
samples_ = configuration->property(role + ".samples", 0);
dump_ = configuration->property(role + ".dump", false);
dump_filename_ = configuration->property(role + ".dump_filename",
default_dump_file);
if (item_type_.compare("short") == 0)
{
item_size_ = sizeof(short);
usrp_source_ = usrp_make_source_s(which_board_, decim_rate_, nchan_,
mux_, mode_, fusb_block_size_, fusb_nblocks_, fpga_filename_,
firmware_filename_);
}
else if (item_type_.compare("gr_complex") == 0)
{
item_size_ = sizeof(gr_complex);
usrp_source_ = usrp_make_source_c(which_board_, decim_rate_, nchan_,
mux_, mode_, fusb_block_size_, fusb_nblocks_, fpga_filename_,
firmware_filename_);
}
else
{
LOG_AT_LEVEL(WARNING) << item_type_
<< " unrecognized item type. Using short.";
item_size_ = sizeof(short);
usrp_source_ = usrp_make_source_s(which_board_, decim_rate_, nchan_,
mux_, mode_, fusb_block_size_, fusb_nblocks_, fpga_filename_,
firmware_filename_);
}
DLOG(INFO) << "usrp_source(" << usrp_source_->unique_id() << ")";
if (samples_ != 0)
{
DLOG(INFO) << "Send STOP signal after " << samples_ << " samples";
valve_ = gnss_sdr_make_valve(item_size_, samples_, queue_);
DLOG(INFO) << "valve(" << valve_->unique_id() << ")";
}
if (dump_)
{
DLOG(INFO) << "Dumping output into file " << dump_filename_;
file_sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str());
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
}
DLOG(INFO) << "Item size " << item_size_;
db_base_sptr subdev = usrp_source_->selected_subdev(usrp_subdev_spec(
spec_side_, spec_subdev_));
DLOG(INFO) << "Subdevice name is " << subdev->side_and_name();
DLOG(INFO) << "Subdevice frequency ranges from " << subdev->freq_min()
<< " to " << subdev->freq_max();
mux_ = usrp_source_->determine_rx_mux_value(usrp_subdev_spec(spec_side_,
spec_subdev_));
DLOG(INFO) << "Mux is " << mux_;
usrp_source_->set_mux(mux_);
if (gain_ == -1)
{
gain_ = (subdev->gain_min() + subdev->gain_max()) / 2.0;
}
DLOG(INFO) << "Gain is " << gain_;
subdev->set_gain(gain_);
usrp_tune_result r;
bool ok = usrp_source_->tune(0, subdev, freq_, &r); //DDC 0
if (!ok)
{
LOG_AT_LEVEL(FATAL) << "Could not set frequency " << freq_
<< " for USRP";
}
DLOG(INFO) << "Frequency set to " << freq_;
DLOG(INFO) << "Decimation set to " << decim_rate_;
}
Usrp1SignalSource::~Usrp1SignalSource()
{
}
void Usrp1SignalSource::connect(gr_top_block_sptr top_block)
{
if (samples_ != 0)
{
top_block->connect(usrp_source_, 0, valve_, 0);
DLOG(INFO) << "connected usrp source to valve";
if (dump_)
{
top_block->connect(valve_, 0, file_sink_, 0);
DLOG(INFO) << "connected valve to file sink";
}
}
else
{
if (dump_)
{
top_block->connect(usrp_source_, 0, file_sink_, 0);
DLOG(INFO) << "connected usrp source to file sink";
}
}
}
void Usrp1SignalSource::disconnect(gr_top_block_sptr top_block)
{
if (samples_ != 0)
{
top_block->disconnect(usrp_source_, 0, valve_, 0);
if (dump_)
{
top_block->disconnect(valve_, 0, file_sink_, 0);
}
}
else
{
if (dump_)
{
top_block->disconnect(usrp_source_, 0, file_sink_, 0);
}
}
}
gr_basic_block_sptr Usrp1SignalSource::get_left_block()
{
LOG_AT_LEVEL(WARNING) << "Trying to get signal source left block.";
return gr_basic_block_sptr();
}
gr_basic_block_sptr Usrp1SignalSource::get_right_block()
{
if (samples_ != 0)
{
return valve_;
}
else
{
return usrp_source_;
}
}

View File

@@ -0,0 +1,106 @@
/*!
* \file usrp1_signal_source.h
* \brief This class represents a USRP signal source
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
*
* Detailed description of the file here if needed.
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef USRP1_SIGNAL_SOURCE_H_
#define USRP1_SIGNAL_SOURCE_H_
#include <boost/shared_ptr.hpp>
#include <gnuradio/gr_hier_block2.h>
#include <gnuradio/gr_msg_queue.h>
#include "gnss_block_interface.h"
class ConfigurationInterface;
class usrp_source_base;
typedef boost::shared_ptr<usrp_source_base> usrp_source_base_sptr;
class Usrp1SignalSource: public GNSSBlockInterface
{
public:
Usrp1SignalSource(ConfigurationInterface* configuration,
std::string role, unsigned int in_stream,
unsigned int out_stream, gr_msg_queue_sptr queue);
virtual ~Usrp1SignalSource();
std::string role()
{
return role_;
}
std::string implementation()
{
return "Usrp1SignalSource";
}
size_t item_size()
{
return item_size_;
}
void connect(gr_top_block_sptr top_block);
void disconnect(gr_top_block_sptr top_block);
gr_basic_block_sptr get_left_block();
gr_basic_block_sptr get_right_block();
private:
std::string role_;
unsigned int in_stream_;
unsigned int out_stream_;
int which_board_;
unsigned int decim_rate_;
int nchan_;
int mux_;
int mode_;
int fusb_block_size_;
int fusb_nblocks_;
std::string fpga_filename_;
std::string firmware_filename_;
unsigned int spec_side_;
unsigned int spec_subdev_;
double freq_;
float gain_;
std::string item_type_;
size_t item_size_;
long samples_;
bool dump_;
std::string dump_filename_;
usrp_source_base_sptr usrp_source_;
gr_block_sptr valve_;
gr_block_sptr file_sink_;
gr_msg_queue_sptr queue_;
};
#endif /*USRP1_SIGNAL_SOURCE_H_*/

View File

@@ -0,0 +1,2 @@
build-project adapters ;
# build-project gnuradio_blocks ;