mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-02-04 13:19:19 +00:00
Code cleaning
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@183 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
parent
572981888a
commit
e3f8b0aeaa
@ -2,5 +2,5 @@ project : build-dir ../../../../build ;
|
||||
|
||||
obj file_signal_source : file_signal_source.cc ;
|
||||
obj uhd_signal_source : uhd_signal_source.cc ;
|
||||
#obj usrp1_signal_source : usrp1_signal_source.cc ;
|
||||
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
* \brief Universal Hardware Driver signal source
|
||||
* \author Javier Arribas, 2012. jarribas(at)cttc.es
|
||||
*
|
||||
* Detailed description of the file here if needed.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
@ -31,22 +29,18 @@
|
||||
*/
|
||||
|
||||
#include "uhd_signal_source.h"
|
||||
|
||||
//#include <uhd/usrp/multi_usrp.hpp>
|
||||
#include <gnuradio/gr_uhd_usrp_source.h>
|
||||
|
||||
#include <uhd/types/device_addr.hpp>
|
||||
#include <uhd/exception.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include <gnuradio/gr_file_sink.h>
|
||||
|
||||
#include "configuration_interface.h"
|
||||
#include "gnss_sdr_valve.h"
|
||||
|
||||
#include <glog/log_severity.h>
|
||||
#include <glog/logging.h>
|
||||
#include <iostream>
|
||||
#include "GPS_L1_CA.h"
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
@ -76,7 +70,7 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration,
|
||||
|
||||
subdevice_=configuration->property(role + ".subdevice",empty);
|
||||
|
||||
freq_ = configuration->property(role + ".freq", (double)1.57542e9);
|
||||
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
|
||||
gain_ = configuration->property(role + ".gain", (double)50.0);
|
||||
sample_rate_ = configuration->property(role + ".sampling_frequency", (double)4.0e6);
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
/*!
|
||||
* \file uhd_signal_source.h
|
||||
* \brief Universal Hardware Driver signal source
|
||||
* \brief Interface for the Universal Hardware Driver signal source
|
||||
* \author Javier Arribas, 2012. jarribas(at)cttc.es
|
||||
*
|
||||
* Detailed description of the file here if needed.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
@ -30,20 +28,20 @@
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef UHD_SIGNAL_SOURCE_H_
|
||||
#define UHD_SIGNAL_SOURCE_H_
|
||||
#ifndef GNSS_SDR_UHD_SIGNAL_SOURCE_H_
|
||||
#define GNSS_SDR_UHD_SIGNAL_SOURCE_H_
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
//#include <uhd/usrp/multi_usrp.hpp>
|
||||
#include <gnuradio/gr_uhd_usrp_source.h>
|
||||
|
||||
#include <gnuradio/gr_hier_block2.h>
|
||||
#include <gnuradio/gr_msg_queue.h>
|
||||
|
||||
#include "gnss_block_interface.h"
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
@ -93,10 +91,6 @@ private:
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
|
||||
//uhd::usrp::multi_usrp::sptr uhd_source_;
|
||||
|
||||
//boost::shared_ptr<uhd_usrp_source>
|
||||
|
||||
boost::shared_ptr<uhd_usrp_source> uhd_source_;
|
||||
|
||||
gr_block_sptr valve_;
|
||||
@ -104,4 +98,4 @@ private:
|
||||
gr_msg_queue_sptr queue_;
|
||||
};
|
||||
|
||||
#endif /*UHD_SIGNAL_SOURCE_H_*/
|
||||
#endif /*GNSS_SDR_UHD_SIGNAL_SOURCE_H_*/
|
||||
|
@ -1,222 +0,0 @@
|
||||
/*!
|
||||
* \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_));
|
||||
|
||||
/*!
|
||||
* The function side_and_name does not work on gnuradio 3.4.2..
|
||||
* 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_;
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*!
|
||||
* \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_*/
|
Loading…
Reference in New Issue
Block a user