diff --git a/src/algorithms/signal_source/adapters/jamfile.jam b/src/algorithms/signal_source/adapters/jamfile.jam index db5b9ee14..fcbfc4349 100644 --- a/src/algorithms/signal_source/adapters/jamfile.jam +++ b/src/algorithms/signal_source/adapters/jamfile.jam @@ -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 ; + diff --git a/src/algorithms/signal_source/adapters/uhd_signal_source.cc b/src/algorithms/signal_source/adapters/uhd_signal_source.cc index 5e4c9006e..5e3f099b6 100644 --- a/src/algorithms/signal_source/adapters/uhd_signal_source.cc +++ b/src/algorithms/signal_source/adapters/uhd_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,33 +29,29 @@ */ #include "uhd_signal_source.h" - //#include #include - #include #include #include - #include - #include "configuration_interface.h" #include "gnss_sdr_valve.h" - #include #include #include +#include "GPS_L1_CA.h" using google::LogMessage; UhdSignalSource::UhdSignalSource(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) + role_(role), in_stream_(in_stream), out_stream_(out_stream), + queue_(queue) { - // DUMP PARAMETERS + // DUMP PARAMETERS std::string empty = ""; std::string default_dump_file = "./data/signal_source.dat"; std::string default_item_type = "short"; @@ -70,13 +64,13 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, uhd::device_addr_t dev_addr; device_address_= configuration->property(role + ".device_address",empty); if (empty.compare(empty)!=0) - { - dev_addr["addr0"]=device_address_; - } + { + dev_addr["addr0"]=device_address_; + } 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); @@ -85,82 +79,82 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, item_type_ = configuration->property(role + ".item_type", default_item_type); if (item_type_.compare("short") == 0) - { - item_size_ = sizeof(short); - } + { + item_size_ = sizeof(short); + } else if (item_type_.compare("gr_complex") == 0) - { - // 1. Make the uhd driver instance - //uhd_source_= uhd::usrp::multi_usrp::make(dev_addr); + { + // 1. Make the uhd driver instance + //uhd_source_= uhd::usrp::multi_usrp::make(dev_addr); - // sigle source - // * \param device_addr the address to identify the hardware - // * \param io_type the desired output data type - uhd_source_= uhd_make_usrp_source(dev_addr,uhd::stream_args_t("fc32")); + // sigle source + // * \param device_addr the address to identify the hardware + // * \param io_type the desired output data type + uhd_source_= uhd_make_usrp_source(dev_addr,uhd::stream_args_t("fc32")); - // 2.1 set sampling clock reference - //Lock mboard clocks internal, external, or mimo - std::string clk_reference="internal"; - uhd_source_->set_clock_source(clk_reference); + // 2.1 set sampling clock reference + //Lock mboard clocks internal, external, or mimo + std::string clk_reference="internal"; + uhd_source_->set_clock_source(clk_reference); - // 2.2 set sampling rate - uhd_source_->set_samp_rate(sample_rate_); - std::cout << boost::format("Actual RX Rate: %f [SPS]...") % (uhd_source_->get_samp_rate()) << std::endl << std::endl; - DLOG(INFO) << boost::format("Actual RX Rate: %f [SPS]...") % (uhd_source_->get_samp_rate()) << std::endl << std::endl; + // 2.2 set sampling rate + uhd_source_->set_samp_rate(sample_rate_); + std::cout << boost::format("Actual RX Rate: %f [SPS]...") % (uhd_source_->get_samp_rate()) << std::endl << std::endl; + DLOG(INFO) << boost::format("Actual RX Rate: %f [SPS]...") % (uhd_source_->get_samp_rate()) << std::endl << std::endl; - // 3. set rx frequency - uhd_source_->set_center_freq(freq_); - std::cout << boost::format("Actual RX Freq: %f [Hz]...") % (uhd_source_->get_center_freq()) << std::endl << std::endl; - DLOG(INFO) << boost::format("Actual RX Freq: %f [Hz]...") % (uhd_source_->get_center_freq()) << std::endl << std::endl; + // 3. set rx frequency + uhd_source_->set_center_freq(freq_); + std::cout << boost::format("Actual RX Freq: %f [Hz]...") % (uhd_source_->get_center_freq()) << std::endl << std::endl; + DLOG(INFO) << boost::format("Actual RX Freq: %f [Hz]...") % (uhd_source_->get_center_freq()) << std::endl << std::endl; - // 4. set rx gain - uhd_source_->set_gain(gain_); - std::cout << boost::format("Actual RX Gain: %f dB...") % uhd_source_->get_gain() << std::endl << std::endl; - DLOG(INFO) << boost::format("Actual RX Gain: %f dB...") % uhd_source_->get_gain() << std::endl << std::endl; + // 4. set rx gain + uhd_source_->set_gain(gain_); + std::cout << boost::format("Actual RX Gain: %f dB...") % uhd_source_->get_gain() << std::endl << std::endl; + DLOG(INFO) << boost::format("Actual RX Gain: %f dB...") % uhd_source_->get_gain() << std::endl << std::endl; - //5. set the IF filter bandwidth + //5. set the IF filter bandwidth - std::cout << boost::format("Setting RX Bandwidth: %f [Hz]...") % IF_bandwidth_hz_ << std::endl; - uhd_source_->set_bandwidth(IF_bandwidth_hz_); - ///std::cout << boost::format("Actual RX Bandwidth: %f MHz...") % uhd_source_->get_rx_bandwidth() << std::endl << std::endl; - //DLOG(INFO) << boost::format("Actual RX Bandwidth: %f MHz...") % uhd_source_->get_rx_bandwidth() << std::endl << std::endl; + std::cout << boost::format("Setting RX Bandwidth: %f [Hz]...") % IF_bandwidth_hz_ << std::endl; + uhd_source_->set_bandwidth(IF_bandwidth_hz_); + ///std::cout << boost::format("Actual RX Bandwidth: %f MHz...") % uhd_source_->get_rx_bandwidth() << std::endl << std::endl; + //DLOG(INFO) << boost::format("Actual RX Bandwidth: %f MHz...") % uhd_source_->get_rx_bandwidth() << std::endl << std::endl; - //set the antenna (optional) - //uhd_source_->set_antenna(ant); + //set the antenna (optional) + //uhd_source_->set_antenna(ant); - //LO lock status - //Check Ref and LO Lock detect - //std::vector sensor_names; - //sensor_names = uhd_source_->get_rx_sensor_names(0); - //if (std::find(sensor_names.begin(), sensor_names.end(), "lo_locked") != sensor_names.end()) { - // uhd::sensor_value_t lo_locked = uhd_source_->get_rx_sensor("lo_locked",0); - // std::cout << boost::format("Checking RX: %s ...") % lo_locked.to_pp_string() << std::endl; - //UHD_ASSERT_THROW(lo_locked.to_bool()); - //} + //LO lock status + //Check Ref and LO Lock detect + //std::vector sensor_names; + //sensor_names = uhd_source_->get_rx_sensor_names(0); + //if (std::find(sensor_names.begin(), sensor_names.end(), "lo_locked") != sensor_names.end()) { + // uhd::sensor_value_t lo_locked = uhd_source_->get_rx_sensor("lo_locked",0); + // std::cout << boost::format("Checking RX: %s ...") % lo_locked.to_pp_string() << std::endl; + //UHD_ASSERT_THROW(lo_locked.to_bool()); + //} - uhd_source_->set_subdev_spec(subdevice_); - } + uhd_source_->set_subdev_spec(subdevice_); + } else - { - LOG_AT_LEVEL(WARNING) << item_type_ - << " unrecognized item type. Using short."; - item_size_ = sizeof(short); - } + { + LOG_AT_LEVEL(WARNING) << item_type_ + << " unrecognized item type. Using short."; + item_size_ = sizeof(short); + } 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() << ")"; - } + { + 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) << "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() << ")"; + } } @@ -172,45 +166,45 @@ void UhdSignalSource::connect(gr_top_block_sptr top_block) { if (samples_ != 0) - { - top_block->connect(uhd_source_, 0, valve_, 0); - DLOG(INFO) << "connected usrp source to valve"; + { + top_block->connect(uhd_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"; + if (dump_) + { + top_block->connect(valve_, 0, file_sink_, 0); + DLOG(INFO) << "connected valve to file sink"; + } } - } else - { - if (dump_) { - top_block->connect(uhd_source_, 0, file_sink_, 0); - DLOG(INFO) << "connected usrp source to file sink"; + if (dump_) + { + top_block->connect(uhd_source_, 0, file_sink_, 0); + DLOG(INFO) << "connected usrp source to file sink"; + } } - } } void UhdSignalSource::disconnect(gr_top_block_sptr top_block) { if (samples_ != 0) - { - top_block->disconnect(uhd_source_, 0, valve_, 0); + { + top_block->disconnect(uhd_source_, 0, valve_, 0); - if (dump_) - { - top_block->disconnect(valve_, 0, file_sink_, 0); + if (dump_) + { + top_block->disconnect(valve_, 0, file_sink_, 0); + } } - } else - { - if (dump_) { - top_block->disconnect(uhd_source_, 0, file_sink_, 0); + if (dump_) + { + top_block->disconnect(uhd_source_, 0, file_sink_, 0); + } } - } } gr_basic_block_sptr UhdSignalSource::get_left_block() @@ -222,11 +216,11 @@ gr_basic_block_sptr UhdSignalSource::get_left_block() gr_basic_block_sptr UhdSignalSource::get_right_block() { if (samples_ != 0) - { - return valve_; - } + { + return valve_; + } else - { - return uhd_source_; - } + { + return uhd_source_; + } } diff --git a/src/algorithms/signal_source/adapters/uhd_signal_source.h b/src/algorithms/signal_source/adapters/uhd_signal_source.h index ab51d2f46..7b57c623e 100644 --- a/src/algorithms/signal_source/adapters/uhd_signal_source.h +++ b/src/algorithms/signal_source/adapters/uhd_signal_source.h @@ -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 -//#include #include - #include #include - #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 - boost::shared_ptr 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_*/ diff --git a/src/algorithms/signal_source/adapters/usrp1_signal_source.cc b/src/algorithms/signal_source/adapters/usrp1_signal_source.cc deleted file mode 100644 index 9f3388f6a..000000000 --- a/src/algorithms/signal_source/adapters/usrp1_signal_source.cc +++ /dev/null @@ -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 . - * - * ------------------------------------------------------------------------- - */ - -#include "usrp1_signal_source.h" - -#include -#include -#include - -#include "configuration_interface.h" -#include "gnss_sdr_valve.h" - -#include -#include - -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_; - } -} diff --git a/src/algorithms/signal_source/adapters/usrp1_signal_source.h b/src/algorithms/signal_source/adapters/usrp1_signal_source.h deleted file mode 100644 index 7dbbffaf5..000000000 --- a/src/algorithms/signal_source/adapters/usrp1_signal_source.h +++ /dev/null @@ -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 . - * - * ------------------------------------------------------------------------- - */ - -#ifndef USRP1_SIGNAL_SOURCE_H_ -#define USRP1_SIGNAL_SOURCE_H_ - -#include - -#include -#include - -#include "gnss_block_interface.h" - -class ConfigurationInterface; -class usrp_source_base; -typedef boost::shared_ptr 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_*/