diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ff7c7216..0556af7b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ file(RELATIVE_PATH RELATIVE_CMAKE_CALL ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRE option(ENABLE_GN3S "Enable the use of the GN3S dongle as signal source (experimental)" OFF) option(ENABLE_ARRAY "Enable the use of CTTC's antenna array front-end as signal source (experimental)" OFF) -option(ENABLE_RTLSDR "Enable the use of RTL dongles as signal source (experimental)" OFF) +option(ENABLE_OSMOSDR "Enable the use of OsmoSDR and compatible front-ends (RTL-based dongles, HackRF, etc.) as signal source (experimental)" OFF) option(ENABLE_OPENCL "Enable building of processing blocks implemented with OpenCL (experimental)" OFF) option(ENABLE_GPERFTOOLS "Enable linking to Gperftools libraries (tcmalloc and profiler)" OFF) option(ENABLE_GENERIC_ARCH "Builds a portable binary" OFF) @@ -971,20 +971,18 @@ endif(ENABLE_ARRAY) if($ENV{RTLSDR_DRIVER}) message(STATUS "RTLSDR_DRIVER environment variable found." ) - set(ENABLE_RTLSDR ON) + set(ENABLE_OSMOSDR ON) endif($ENV{RTLSDR_DRIVER}) if(RAW_ARRAY_DRIVER) - set(ENABLE_RTLSDR ON) + set(ENABLE_OSMOSDR ON) endif(RAW_ARRAY_DRIVER) -if(ENABLE_RTLSDR) - message(STATUS "The driver for RTL-based dongles will be compiled." ) - message(STATUS "You can disable it with 'cmake -DENABLE_RTLSDR=OFF ../'" ) - # find libosmosdr (done in src/algorithms/signal_sources/adapters) - # find gr-osmosdr (done in src/algorithms/signal_sources/adapters) -else(ENABLE_RTLSDR) - message(STATUS "The (optional) driver for RTL-based dongles is not enabled." ) - message(STATUS "Enable it with 'cmake -DENABLE_RTLSDR=ON ../' to add support for Realtek's RTL2832U-based USB dongles." ) -endif(ENABLE_RTLSDR) +if(ENABLE_OSMOSDR) + message(STATUS "The driver for OsmoSDR and other font-ends (HackRF, Realtek's RTL2832U-based dongles) will be compiled." ) + message(STATUS "You can disable it with 'cmake -DENABLE_OSMOSDR=OFF ../'" ) +else(ENABLE_OSMOSDR) + message(STATUS "The (optional) driver for OsmoSDR and related front-ends is not enabled." ) + message(STATUS "Enable it with 'cmake -DENABLE_OSMOSDR=ON ../' to add support for OsmoSDR and other font-ends (HackRF, Realtek's RTL2832U-based USB dongles, etc.)" ) +endif(ENABLE_OSMOSDR) ######################################################################## diff --git a/README.md b/README.md index 96f79baf2..b6ce1fd61 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Before building GNSS-SDR, you need to install all the required dependencies. If $ sudo apt-get install build-essential cmake git libboost-dev libboost-date-time-dev \ libboost-system-dev libboost-filesystem-dev libboost-thread-dev \ libboost-serialization-dev libboost-program-options-dev libboost-test-dev \ - liblog4cpp5-dev libuhd-dev gnuradio-dev libblas-dev liblapack-dev gfortran \ + liblog4cpp5-dev libuhd-dev gnuradio-dev gr-osmosdr libblas-dev liblapack-dev gfortran \ libarmadillo-dev libgflags-dev libgoogle-glog-dev libssl-dev libgtest-dev ~~~~~~ @@ -287,7 +287,7 @@ GNSS-SDR comes with a pre-compiled custom GN3S firmware available at gnss-sdr/fi -###### Build RTL-SDR support (OPTIONAL): +###### Build OSMOSDR support (OPTIONAL): Install the [OsmoSDR](http://sdr.osmocom.org/trac/ "OsmoSDR's Homepage") library and GNU Radio's source block: @@ -313,15 +313,15 @@ $ sudo ldconfig ~~~~~~ -Then configure GNSS-SDR to build the Rtlsdr_Signal_Source by: +Then, configure GNSS-SDR to build the Osmosdr_Signal_Source by: ~~~~~~ -$ cmake -DENABLE_RTLSDR=ON ../ +$ cmake -DENABLE_OSMOSDR=ON ../ $ make $ sudo make install ~~~~~~ -(in order to disable the Rtlsdr_Signal_Source compilation, you can pass -DENABLE_RTLSDR=OFF to cmake and build GNSS-SDR again). +(in order to disable the Osmosdr_Signal_Source compilation, you can pass -DENABLE_OSMOSDR=OFF to cmake and build GNSS-SDR again). @@ -346,7 +346,7 @@ $ make $ sudo make install ~~~~~~ -Using this option, all SIMD instructions are accessed via VOLK, which automatically includes versions of each function for different SIMD instruction sets, then detects at runtime which to use, or if there are none, substitutes a generic, non-SIMD implementation. +Using this option, all SIMD instructions are exclusively accessed via VOLK, which automatically includes versions of each function for different SIMD instruction sets, then detects at runtime which to use, or if there are none, substitutes a generic, non-SIMD implementation. diff --git a/cmake/Modules/FindGrOsmoSDR.cmake b/cmake/Modules/FindGrOsmoSDR.cmake index 260a47e06..e39bd6b80 100644 --- a/cmake/Modules/FindGrOsmoSDR.cmake +++ b/cmake/Modules/FindGrOsmoSDR.cmake @@ -20,7 +20,7 @@ FIND_PATH(GROSMOSDR_INCLUDE_DIR - NAMES osmosdr/source_c.h + NAMES osmosdr/source.h osmosdr/api.h HINTS ${GrOsmoSDR_ROOT_DIR}/include PATHS /usr/local/include diff --git a/conf/gnss-sdr_GPS_L1_rtlsdr_realtime.conf b/conf/gnss-sdr_GPS_L1_rtlsdr_realtime.conf index c01f498c3..693059eaf 100644 --- a/conf/gnss-sdr_GPS_L1_rtlsdr_realtime.conf +++ b/conf/gnss-sdr_GPS_L1_rtlsdr_realtime.conf @@ -27,8 +27,8 @@ GNSS-SDR.SUPL_LAC=0x59e2 GNSS-SDR.SUPL_CI=0x31b0 ;######### SIGNAL_SOURCE CONFIG ############ -;#implementation: Use [File_Signal_Source] or [UHD_Signal_Source] or [GN3S_Signal_Source] [RTLSDR_Signal_Source] -SignalSource.implementation=Rtlsdr_Signal_Source +;#implementation: Use [File_Signal_Source] or [UHD_Signal_Source] or [GN3S_Signal_Source] [Osmosdr_Signal_Source] +SignalSource.implementation=Osmosdr_Signal_Source ;#filename: path to file with the captured GNSS signal samples to be processed SignalSource.filename=/media/DATALOGGER_/signals/RTL-SDR/geo/pmt4.dat diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index dddf99bf9..37a318407 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/CMakeLists.txt @@ -83,23 +83,24 @@ if(ENABLE_ARRAY) endif(ENABLE_ARRAY) -if(ENABLE_RTLSDR) +if(ENABLE_OSMOSDR) ################################################################################ # OsmoSDR - http://sdr.osmocom.org/trac/ ################################################################################ find_package(GrOsmoSDR REQUIRED) - if(NOT GROSMOSDR_FOUND) - message(FATAL_ERROR "gr-osmosdr required to build gnss-sdr with the optional RTLSDR driver") - endif(NOT GROSMOSDR_FOUND) - # set RTL include dirs - set(RTL_DRIVER_INCLUDE_DIRS + if(NOT GROSMOSDR_FOUND) + message(FATAL_ERROR "gr-osmosdr required to build gnss-sdr with the optional OSMOSDR driver") + endif(NOT GROSMOSDR_FOUND) + + # set OSMO include dirs + set(OSMO_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${GROSMOSDR_INCLUDE_DIR}/osmosdr ) - set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} rtlsdr_signal_source.cc) + set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} osmosdr_signal_source.cc) set(OPT_LIBRARIES ${OPT_LIBRARIES} ${GROSMOSDR_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${RTL_DRIVER_INCLUDE_DIRS}) -endif(ENABLE_RTLSDR) + set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${OSMO_DRIVER_INCLUDE_DIRS}) +endif(ENABLE_OSMOSDR) if(ENABLE_UHD) set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} uhd_signal_source.cc) diff --git a/src/algorithms/signal_source/adapters/rtlsdr_signal_source.cc b/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc similarity index 74% rename from src/algorithms/signal_source/adapters/rtlsdr_signal_source.cc rename to src/algorithms/signal_source/adapters/osmosdr_signal_source.cc index 3cdc7a03e..baec96f43 100644 --- a/src/algorithms/signal_source/adapters/rtlsdr_signal_source.cc +++ b/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc @@ -1,5 +1,5 @@ /*! - * \file rtlsdr_signal_source.cc + * \file osmosdr_signal_source.cc * \brief Signal source for the Realtek RTL2832U USB dongle DVB-T receiver * (see http://sdr.osmocom.org/trac/wiki/rtl-sdr for more information) * \author Javier Arribas, 2012. jarribas(at)cttc.es @@ -29,7 +29,7 @@ * ------------------------------------------------------------------------- */ -#include "rtlsdr_signal_source.h" +#include "osmosdr_signal_source.h" #include #include #include @@ -42,7 +42,7 @@ using google::LogMessage; -RtlsdrSignalSource::RtlsdrSignalSource(ConfigurationInterface* configuration, +OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration, std::string role, unsigned int in_stream, unsigned int out_stream, boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), @@ -57,7 +57,7 @@ RtlsdrSignalSource::RtlsdrSignalSource(ConfigurationInterface* configuration, dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); - // RTLSDR Driver parameters + // OSMOSDR Driver parameters AGC_enabled_ = configuration->property(role + ".AGC_enabled", true); freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ); gain_ = configuration->property(role + ".gain", (double)40.0); @@ -76,7 +76,7 @@ RtlsdrSignalSource::RtlsdrSignalSource(ConfigurationInterface* configuration, // 1. Make the driver instance try { - rtlsdr_source_ = osmosdr::source::make(); + osmosdr_source_ = osmosdr::source::make(); } catch( boost::exception & e ) { @@ -84,34 +84,34 @@ RtlsdrSignalSource::RtlsdrSignalSource(ConfigurationInterface* configuration, } // 2 set sampling rate - rtlsdr_source_->set_sample_rate(sample_rate_); - std::cout << boost::format("Actual RX Rate: %f [SPS]...") % (rtlsdr_source_->get_sample_rate()) << std::endl ; - LOG(INFO) << boost::format("Actual RX Rate: %f [SPS]...") % (rtlsdr_source_->get_sample_rate()); + osmosdr_source_->set_sample_rate(sample_rate_); + 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 - rtlsdr_source_->set_center_freq(freq_); - std::cout << boost::format("Actual RX Freq: %f [Hz]...") % (rtlsdr_source_->get_center_freq()) << std::endl ; - LOG(INFO) << boost::format("Actual RX Freq: %f [Hz]...") % (rtlsdr_source_->get_center_freq()); + osmosdr_source_->set_center_freq(freq_); + 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]...") % (rtlsdr_source_->get_center_freq() - freq_) ; - LOG(INFO) << boost::format("PLL Frequency tune error %f [Hz]...") % (rtlsdr_source_->get_center_freq() - freq_) ; + std::cout << 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) { - rtlsdr_source_->set_gain_mode(true); + osmosdr_source_->set_gain_mode(true); std::cout << "AGC enabled" << std::endl; LOG(INFO) << "AGC enabled"; } else { - rtlsdr_source_->set_gain_mode(false); - rtlsdr_source_->set_gain(gain_, 0); - rtlsdr_source_->set_if_gain(rf_gain_, 0); - rtlsdr_source_->set_bb_gain(if_gain_, 0); - std::cout << boost::format("Actual RX Gain: %f dB...") % rtlsdr_source_->get_gain() << std::endl; - LOG(INFO) << boost::format("Actual RX Gain: %f dB...") % rtlsdr_source_->get_gain(); + osmosdr_source_->set_gain_mode(false); + osmosdr_source_->set_gain(gain_, 0); + osmosdr_source_->set_if_gain(rf_gain_, 0); + osmosdr_source_->set_bb_gain(if_gain_, 0); + std::cout << boost::format("Actual RX Gain: %f dB...") % osmosdr_source_->get_gain() << std::endl; + LOG(INFO) << boost::format("Actual RX Gain: %f dB...") % osmosdr_source_->get_gain(); } } else @@ -137,17 +137,17 @@ RtlsdrSignalSource::RtlsdrSignalSource(ConfigurationInterface* configuration, -RtlsdrSignalSource::~RtlsdrSignalSource() +OsmosdrSignalSource::~OsmosdrSignalSource() {} -void RtlsdrSignalSource::connect(gr::top_block_sptr top_block) +void OsmosdrSignalSource::connect(gr::top_block_sptr top_block) { if (samples_ != 0) { - top_block->connect(rtlsdr_source_, 0, valve_, 0); - DLOG(INFO) << "connected rtlsdr source to valve"; + top_block->connect(osmosdr_source_, 0, valve_, 0); + DLOG(INFO) << "connected osmosdr source to valve"; if (dump_) { top_block->connect(valve_, 0, file_sink_, 0); @@ -158,19 +158,19 @@ void RtlsdrSignalSource::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(rtlsdr_source_, 0, file_sink_, 0); - DLOG(INFO) << "connected rtlsdr source to file sink"; + top_block->connect(osmosdr_source_, 0, file_sink_, 0); + DLOG(INFO) << "connected osmosdr source to file sink"; } } } -void RtlsdrSignalSource::disconnect(gr::top_block_sptr top_block) +void OsmosdrSignalSource::disconnect(gr::top_block_sptr top_block) { if (samples_ != 0) { - top_block->disconnect(rtlsdr_source_, 0, valve_, 0); + top_block->disconnect(osmosdr_source_, 0, valve_, 0); if (dump_) { top_block->disconnect(valve_, 0, file_sink_, 0); @@ -180,14 +180,14 @@ void RtlsdrSignalSource::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(rtlsdr_source_, 0, file_sink_, 0); + top_block->disconnect(osmosdr_source_, 0, file_sink_, 0); } } } -gr::basic_block_sptr RtlsdrSignalSource::get_left_block() +gr::basic_block_sptr OsmosdrSignalSource::get_left_block() { LOG(WARNING) << "Trying to get signal source left block."; return gr::basic_block_sptr(); @@ -195,7 +195,7 @@ gr::basic_block_sptr RtlsdrSignalSource::get_left_block() -gr::basic_block_sptr RtlsdrSignalSource::get_right_block() +gr::basic_block_sptr OsmosdrSignalSource::get_right_block() { if (samples_ != 0) { @@ -203,6 +203,6 @@ gr::basic_block_sptr RtlsdrSignalSource::get_right_block() } else { - return rtlsdr_source_; + return osmosdr_source_; } } diff --git a/src/algorithms/signal_source/adapters/rtlsdr_signal_source.h b/src/algorithms/signal_source/adapters/osmosdr_signal_source.h similarity index 75% rename from src/algorithms/signal_source/adapters/rtlsdr_signal_source.h rename to src/algorithms/signal_source/adapters/osmosdr_signal_source.h index 1b5a700a2..90fc550c4 100644 --- a/src/algorithms/signal_source/adapters/rtlsdr_signal_source.h +++ b/src/algorithms/signal_source/adapters/osmosdr_signal_source.h @@ -1,6 +1,7 @@ /*! - * \file rtlsdr_signal_source.h - * \brief Signal source for the Realtek RTL2832U USB dongle DVB-T receiver + * \file osmosdr_signal_source.h + * \brief Signal source wrapper for OsmoSDR-compatible front-ends, such as + * HackRF or Realtek's RTL2832U-based USB dongle DVB-T receivers * (see http://sdr.osmocom.org/trac/wiki/rtl-sdr for more information) * \author Javier Arribas, 2012. jarribas(at)cttc.es * @@ -29,8 +30,8 @@ * ------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_RTLSDR_SIGNAL_SOURCE_H_ -#define GNSS_SDR_RTLSDR_SIGNAL_SOURCE_H_ +#ifndef GNSS_SDR_OSMOSDR_SIGNAL_SOURCE_H_ +#define GNSS_SDR_OSMOSDR_SIGNAL_SOURCE_H_ #include #include @@ -42,16 +43,18 @@ class ConfigurationInterface; /*! - * \brief This class reads samples from Realtek RTL2832U USB dongle DVB-T receiver (see http://sdr.osmocom.org/trac/wiki/rtl-sdr) + * \brief This class reads samples OsmoSDR-compatible front-ends, such as + * HackRF or Realtek's RTL2832U-based USB dongle DVB-T receivers + * (see http://sdr.osmocom.org/trac/wiki/rtl-sdr) */ -class RtlsdrSignalSource: public GNSSBlockInterface +class OsmosdrSignalSource: public GNSSBlockInterface { public: - RtlsdrSignalSource(ConfigurationInterface* configuration, + OsmosdrSignalSource(ConfigurationInterface* configuration, std::string role, unsigned int in_stream, unsigned int out_stream, boost::shared_ptr queue); - virtual ~RtlsdrSignalSource(); + virtual ~OsmosdrSignalSource(); std::string role() { @@ -59,11 +62,11 @@ public: } /*! - * \brief Returns "Rtlsdr_Signal_Source" + * \brief Returns "Osmosdr_Signal_Source" */ std::string implementation() { - return "Rtlsdr_Signal_Source"; + return "Osmosdr_Signal_Source"; } size_t item_size() { @@ -96,11 +99,11 @@ private: bool dump_; std::string dump_filename_; - osmosdr::source::sptr rtlsdr_source_; + osmosdr::source::sptr osmosdr_source_; boost::shared_ptr valve_; gr::blocks::file_sink::sptr file_sink_; boost::shared_ptr queue_; }; -#endif /*GNSS_SDR_RTLSDR_SIGNAL_SOURCE_H_*/ +#endif /*GNSS_SDR_OSMOSDR_SIGNAL_SOURCE_H_*/ diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index 9362f9a2f..e185f87c3 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/CMakeLists.txt @@ -73,9 +73,9 @@ if(ENABLE_ARRAY) add_definitions(-DRAW_ARRAY_DRIVER=1) endif(ENABLE_ARRAY) -if(ENABLE_RTLSDR) - add_definitions(-DRTLSDR_DRIVER=1) -endif(ENABLE_RTLSDR) +if(ENABLE_OSMOSDR) + add_definitions(-DOSMOSDR_DRIVER=1) +endif(ENABLE_OSMOSDR) if(ENABLE_UHD) add_definitions(-DUHD_DRIVER=1) diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 3d63b61a8..64014f0ec 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -100,8 +100,8 @@ #include "raw_array_signal_source.h" #endif -#if RTLSDR_DRIVER - #include "rtlsdr_signal_source.h" +#if OSMOSDR_DRIVER + #include "osmosdr_signal_source.h" #endif #if UHD_DRIVER @@ -417,10 +417,10 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } #endif -#if RTLSDR_DRIVER - else if (implementation.compare("Rtlsdr_Signal_Source") == 0) +#if OSMOSDR_DRIVER + else if (implementation.compare("Osmosdr_Signal_Source") == 0) { - std::unique_ptr block_(new RtlsdrSignalSource(configuration.get(), role, in_streams, + std::unique_ptr block_(new OsmosdrSignalSource(configuration.get(), role, in_streams, out_streams, queue)); block = std::move(block_); }