1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-11 04:33:06 +00:00

rtl_tcp specific signal source block

This commit is contained in:
Anthony Arnold
2015-05-08 16:59:38 +10:00
parent c9300c45a0
commit 128a7452d5
8 changed files with 672 additions and 42 deletions

View File

@@ -25,7 +25,7 @@ if(ENABLE_GN3S)
# find_package(GrGN3S)
# if not found, build it with ExternalPackage_Add
include(ExternalProject)
include(ExternalProject)
ExternalProject_Add(
gr-gn3s
SOURCE_DIR ${CMAKE_SOURCE_DIR}/drivers/gr-gn3s
@@ -34,21 +34,21 @@ if(ENABLE_GN3S)
PATCH_COMMAND ""
INSTALL_COMMAND ""
)
# Set up variables
set(GRGN3S_INCLUDE_DIRS ${GRGN3S_DIR}/include ${GRGN3S_DIR} ${GRGN3S_DIR}/src)
set(GRGN3S_LIBRARIES
set(GRGN3S_LIBRARIES
"${CMAKE_CURRENT_BINARY_DIR}/../../../../gr-gn3s/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gr-gn3s${CMAKE_SHARED_LIBRARY_SUFFIX}"
)
)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${GRGN3S_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${GRGN3S_INCLUDE_DIRS})
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} gn3s_signal_source.cc)
# Copy GN3S firmware binary file to install folder
message(STATUS "Copying the GN3S firmware binary file to install folder")
file(COPY ${CMAKE_SOURCE_DIR}/firmware/GN3S_v2/bin/gn3s_firmware.ihx
message(STATUS "Copying the GN3S firmware binary file to install folder")
file(COPY ${CMAKE_SOURCE_DIR}/firmware/GN3S_v2/bin/gn3s_firmware.ihx
DESTINATION ${CMAKE_SOURCE_DIR}/install/
)
)
endif(ENABLE_GN3S)
if(ENABLE_FLEXIBAND)
@@ -61,15 +61,15 @@ if(ENABLE_FLEXIBAND)
find_package(teleorbit REQUIRED)
if(NOT TELEORBIT_FOUND)
message(FATAL_ERROR "Teleorbit Flexiband GNURadio driver required to build gnss-sdr with the optional FLEXIBAND adapter")
endif(NOT TELEORBIT_FOUND)
endif(NOT TELEORBIT_FOUND)
# Set up variables
set(FLEXIBAND_DRIVER_INCLUDE_DIRS
${OPT_DRIVER_INCLUDE_DIRS}
set(FLEXIBAND_DRIVER_INCLUDE_DIRS
${OPT_DRIVER_INCLUDE_DIRS}
${TELEORBIT_INCLUDE_DIR}/teleorbit
)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${TELEORBIT_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${FLEXIBAND_DRIVER_INCLUDE_DIRS})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${FLEXIBAND_DRIVER_INCLUDE_DIRS})
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} flexiband_signal_source.cc)
endif(ENABLE_FLEXIBAND)
@@ -83,7 +83,7 @@ if(ENABLE_ARRAY)
endif(OS_IS_MACOSX)
# find_package(GrDbfcttc)
# if not found, build it with ExternalPackage_Add
include(ExternalProject)
include(ExternalProject)
ExternalProject_Add(
gr-dbfcttc
SOURCE_DIR ${CMAKE_SOURCE_DIR}/drivers/gr-dbfcttc
@@ -93,12 +93,12 @@ if(ENABLE_ARRAY)
CMAKE_ARGS ${MACOSX_ARGS}
INSTALL_COMMAND ""
)
# Set up variables
set(GRDBFCTTC_INCLUDE_DIRS ${GRDBFCTTC_DIR}/include ${GRDBFCTTC_DIR} ${GRDBFCTTC_DIR}/src)
set(GRDBFCTTC_LIBRARIES
set(GRDBFCTTC_LIBRARIES
"${CMAKE_CURRENT_BINARY_DIR}/../../../../gr-dbfcttc/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gnuradio-dbfcttc${CMAKE_SHARED_LIBRARY_SUFFIX}"
)
)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${GRDBFCTTC_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${GRDBFCTTC_INCLUDE_DIRS})
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} raw_array_signal_source.cc)
@@ -108,33 +108,34 @@ endif(ENABLE_ARRAY)
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 OSMOSDR driver")
endif(NOT GROSMOSDR_FOUND)
endif(NOT GROSMOSDR_FOUND)
# set OSMO include dirs
set(OSMO_DRIVER_INCLUDE_DIRS
${OPT_DRIVER_INCLUDE_DIRS}
set(OSMO_DRIVER_INCLUDE_DIRS
${OPT_DRIVER_INCLUDE_DIRS}
${GROSMOSDR_INCLUDE_DIR}/osmosdr
)
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} ${OSMO_DRIVER_INCLUDE_DIRS})
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)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${UHD_LIBRARIES} ${GNURADIO_UHD_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${UHD_INCLUDE_DIRS})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${UHD_INCLUDE_DIRS})
endif(ENABLE_UHD)
set(SIGNAL_SOURCE_ADAPTER_SOURCES file_signal_source.cc
gen_signal_source.cc
nsr_file_signal_source.cc
set(SIGNAL_SOURCE_ADAPTER_SOURCES file_signal_source.cc
gen_signal_source.cc
nsr_file_signal_source.cc
spir_file_signal_source.cc
rtl_tcp_signal_source.cc
${OPT_DRIVER_SOURCES}
)
@@ -147,7 +148,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/algorithms/libs
${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/gnuradio_blocks
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
${VOLK_INCLUDE_DIRS}
@@ -162,10 +163,10 @@ add_definitions(-DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}")
file(GLOB SIGNAL_SOURCE_ADAPTER_HEADERS "*.h")
add_library(signal_source_adapters ${SIGNAL_SOURCE_ADAPTER_SOURCES} ${SIGNAL_SOURCE_ADAPTER_HEADERS})
source_group(Headers FILES ${SIGNAL_SOURCE_ADAPTER_HEADERS})
target_link_libraries(signal_source_adapters signal_source_gr_blocks
${Boost_LIBRARIES}
${GNURADIO_PMT_LIBRARIES}
${GNURADIO_BLOCKS_LIBRARIES}
${OPT_LIBRARIES}
target_link_libraries(signal_source_adapters signal_source_gr_blocks
${Boost_LIBRARIES}
${GNURADIO_PMT_LIBRARIES}
${GNURADIO_BLOCKS_LIBRARIES}
${OPT_LIBRARIES}
gnss_sp_libs
)

View File

@@ -0,0 +1,188 @@
/*!
* \file rtl_tcp_signal_source.cc
* \brief Signal source for the Realtek RTL2832U USB dongle DVB-T receiver
* over TCP.
* (see http://sdr.osmocom.org/trac/wiki/rtl-sdr for more information)
* \author Anthony Arnold, 2015. anthony.arnold(at)uqconnect.edu.au
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2015 (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 "rtl_tcp_signal_source.h"
#include <glog/logging.h>
#include <iostream>
#include <boost/format.hpp>
#include "configuration_interface.h"
#include "gnss_sdr_valve.h"
#include "GPS_L1_CA.h"
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)
{
// DUMP PARAMETERS
std::string empty = "";
std::string default_dump_file = "./data/signal_source.dat";
std::string default_item_type = "gr_complex";
samples_ = configuration->property(role + ".samples", 0);
dump_ = configuration->property(role + ".dump", false);
dump_filename_ = configuration->property(role + ".dump_filename",
default_dump_file);
// rtl_tcp PARAMTERS
std::string default_address = "127.0.0.1";
short default_port = 1234;
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);
rf_gain_ = configuration->property(role + ".rf_gain", (double)40.0);
if_gain_ = configuration->property(role + ".if_gain", (double)40.0);
sample_rate_ = configuration->property(role + ".sampling_frequency", (double)2.0e6);
item_type_ = configuration->property(role + ".item_type", default_item_type);
address_ = configuration->property(role + ".address", default_address);
port_ = configuration->property(role + ".port", default_port);
if (item_type_.compare("short") == 0)
{
item_size_ = sizeof(short);
}
else if (item_type_.compare("gr_complex") == 0)
{
item_size_ = sizeof(gr_complex);
// 1. Make the gr block
try
{
std::cout << "Connecting to " << address_ << ":" << port_ << std::endl;
LOG (INFO) << "Connecting to " << address_ << ":" << port_;
signal_source_ = rtl_tcp_make_signal_source_cc (address_, port_);
}
catch( boost::exception & e )
{
DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
}
// 2 set sampling rate
signal_source_->set_sample_rate(sample_rate_);
// 3. set rx frequency
signal_source_->set_frequency(freq_);
// 4. set rx gain
/*if (this->AGC_enabled_ == true)
{
osmosdr_source_->set_gain_mode(true);
std::cout << "AGC enabled" << std::endl;
LOG(INFO) << "AGC enabled";
}
else
{
osmosdr_source_->set_gain_mode(false);
osmosdr_source_->set_gain(gain_, 0);
osmosdr_source_->set_if_gain(if_gain_, 0);
osmosdr_source_->set_bb_gain(rf_gain_, 0);
}*/
}
else
{
LOG(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() << ")";
}
if (dump_)
{
DLOG(INFO) << "Dumping output into file " << dump_filename_;
file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str());
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
}
deinterleave_ = gr::blocks::deinterleave::make (sizeof (float));
ftoc_ = gr::blocks::float_to_complex::make ( 1 );
}
RtlTcpSignalSource::~RtlTcpSignalSource()
{}
void RtlTcpSignalSource::connect(gr::top_block_sptr top_block) {
// deinterleave and convert to complex
top_block->connect (signal_source_, 0, deinterleave_, 0);
top_block->connect (deinterleave_, 0, ftoc_, 0);
top_block->connect (deinterleave_, 1, ftoc_, 1);
if ( samples_ ) {
top_block->connect (ftoc_, 0, valve_, 0);
DLOG(INFO) << "connected rtl tcp 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(ftoc_, 0, file_sink_, 0);
DLOG(INFO) << "connected rtl tcp source to file sink";
}
}
void RtlTcpSignalSource::disconnect(gr::top_block_sptr top_block) {
top_block->disconnect (signal_source_, 0, deinterleave_, 0);
top_block->disconnect (deinterleave_, 0, ftoc_, 0);
top_block->disconnect (deinterleave_, 1, ftoc_, 1);
if ( samples_ ) {
top_block->disconnect (ftoc_, 0, valve_, 0);
if ( dump_ ) {
top_block->disconnect(valve_, 0, file_sink_, 0);
}
}
else if ( dump_ ) {
top_block->disconnect(ftoc_, 0, file_sink_, 0);
}
}
gr::basic_block_sptr RtlTcpSignalSource::get_left_block() {
LOG(WARNING) << "Trying to get signal source left block.";
return gr::basic_block_sptr();
}
gr::basic_block_sptr RtlTcpSignalSource::get_right_block() {
if (samples_ != 0) {
return valve_;
}
else {
return ftoc_;
}
}

View File

@@ -0,0 +1,114 @@
/*!
* \file rtl_tcp_signal_source.h
* \brief Signal source which reads from rtl_tcp.
* (see http://sdr.osmocom.org/trac/wiki/rtl-sdr for more information)
* \author Anthony Arnold, 2015. anthony.arnold(at)uqconnect.edu.au
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2015 (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 GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H
#define GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H
#include <string>
#include <boost/shared_ptr.hpp>
#include <gnuradio/msg_queue.h>
#include <gnuradio/blocks/file_sink.h>
#include <gnuradio/blocks/deinterleave.h>
#include <gnuradio/blocks/float_to_complex.h>
#include "rtl_tcp_signal_source_cc.h"
#include "gnss_block_interface.h"
class ConfigurationInterface;
/*!
* \brief This class reads from rtl_tcp, which streams interleaved
* I/Q samples over TCP.
* (see http://sdr.osmocom.org/trac/wiki/rtl-sdr)
*/
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);
virtual ~RtlTcpSignalSource();
std::string role()
{
return role_;
}
/*!
* \brief Returns "RtlTcp_Signal_Source"
*/
std::string implementation()
{
return "RtlTcp_Signal_Source";
}
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_;
// rtl_tcp settings
std::string address_;
short port_;
bool AGC_enabled_;
double sample_rate_;
unsigned int in_stream_;
unsigned int out_stream_;
double freq_;
double gain_;
double if_gain_;
double rf_gain_;
std::string item_type_;
size_t item_size_;
long samples_;
bool dump_;
std::string dump_filename_;
rtl_tcp_signal_source_cc_sptr signal_source_;
gr::blocks::deinterleave::sptr deinterleave_;
gr::blocks::float_to_complex::sptr ftoc_;
boost::shared_ptr<gr::block> valve_;
gr::blocks::file_sink::sptr file_sink_;
boost::shared_ptr<gr::msg_queue> queue_;
};
#endif /*GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H */