1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-26 03:54:55 +00:00

Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into fix_observables

This commit is contained in:
Javier Arribas
2018-05-31 17:26:38 +02:00
32 changed files with 568 additions and 1620 deletions

View File

@@ -471,7 +471,7 @@ void *rtksvrthread(void *arg)
q = svr->buff[i] + svr->buffsize;
/* read receiver raw/rtcm data from input stream */
if ((n = strread(svr->stream + i, p, q - p)) <= 0)
if ((n = strread(svr->stream + i, p, static_cast<int>(q[0]) - static_cast<int>(p[0]))) <= 0)
{
continue;
}

View File

@@ -120,8 +120,8 @@ serial_t *openserial(const char *path, int mode, char *msg)
std::string s_aux = "/dev/" + std::string(port);
s_aux.resize(128, '\0');
int n = s_aux.length();
if (n < 128)
for (int i = 0; i < n; i++) dev[i] = s_aux[i];
for (int i = 0; i < n; i++) dev[i] = s_aux[i];
if (n == 0) dev[0] = '\0';
if ((mode & STR_MODE_R) && (mode & STR_MODE_W))
rw = O_RDWR;
@@ -1493,7 +1493,6 @@ void decodeftppath(const char *path, char *addr, char *file, char *user,
*q = '\0';
if (passwd) strcpy(passwd, q + 1);
}
*q = '\0';
if (user) strcpy(user, buff);
}
else

View File

@@ -20,7 +20,7 @@
# This tag specifies the encoding used for all characters in the config file
# that follow. The default is UTF-8 which is also the encoding used for all text
# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
# built into libc) for the transcoding. See https://www.gnu.org/software/libiconv
# for the list of possible encodings.
# The default value is: UTF-8.
@@ -287,7 +287,7 @@ EXTENSION_MAPPING =
# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
# according to the Markdown format, which allows for more readable
# documentation. See http://daringfireball.net/projects/markdown/ for details.
# documentation. See https://daringfireball.net/projects/markdown/ for details.
# The output of markdown processing is further processed by doxygen, so you can
# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
# case of backward compatibilities issues.
@@ -320,7 +320,7 @@ BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
# https://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
# will parse them like normal C++ but will assume all classes use public instead
# of private inheritance when no explicit protection keyword is present.
# The default value is: NO.
@@ -679,7 +679,7 @@ LAYOUT_FILE = @PROJECT_SOURCE_DIR@/DoxygenLayout.xml
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
# the reference definitions. This must be a list of .bib files. The .bib
# extension is automatically appended if omitted. This requires the bibtex tool
# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
# For LaTeX the style of the bibliography can be controlled using
# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
# search path. Do not use file names with spaces, bibtex cannot handle them. See
@@ -761,7 +761,7 @@ INPUT = @PROJECT_SOURCE_DIR@
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
# documentation (see: http://www.gnu.org/software/libiconv) for the list of
# documentation (see: https://www.gnu.org/software/libiconv) for the list of
# possible encodings.
# The default value is: UTF-8.
@@ -994,7 +994,7 @@ SOURCE_TOOLTIPS = YES
# If the USE_HTAGS tag is set to YES then the references to source code will
# point to the HTML generated by the htags(1) tool instead of doxygen built-in
# source browser. The htags tool is part of GNU's global source tagging system
# (see http://www.gnu.org/software/global/global.html). You will need version
# (see https://www.gnu.org/software/global/global.html). You will need version
# 4.8.6 or higher.
#
# To use it do the following:
@@ -1137,7 +1137,7 @@ HTML_EXTRA_FILES =
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
# will adjust the colors in the stylesheet and background images according to
# this color. Hue is specified as an angle on a colorwheel, see
# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
# purple, and 360 is red again.
# Minimum value: 0, maximum value: 359, default value: 220.
@@ -1195,13 +1195,12 @@ HTML_INDEX_NUM_ENTRIES = 100
# If the GENERATE_DOCSET tag is set to YES, additional index files will be
# generated that can be used as input for Apple's Xcode 3 integrated development
# environment (see: http://developer.apple.com/tools/xcode/), introduced with
# environment (see: https://developer.apple.com/xcode/), introduced with
# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
# Makefile in the HTML output directory. Running make will produce the docset in
# that directory and running make install will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
# for more information.
# startup.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1240,7 +1239,7 @@ DOCSET_PUBLISHER_NAME = Publisher
# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on
# Windows.
#
# The HTML Help Workshop contains a compiler that can convert all HTML output
@@ -1453,7 +1452,7 @@ FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# http://www.mathjax.org) which uses client side Javascript for the rendering
# https://www.mathjax.org) which uses client side Javascript for the rendering
# instead of using prerendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path
@@ -1465,7 +1464,7 @@ USE_MATHJAX = NO
# When MathJax is enabled you can set the default output format to be used for
# the MathJax output. See the MathJax site (see:
# http://docs.mathjax.org/en/latest/output.html) for more details.
# https://docs.mathjax.org/en/latest/output.html) for more details.
# Possible values are: HTML-CSS (which is slower, but has the best
# compatibility), NativeMML (i.e. MathML) and SVG.
# The default value is: HTML-CSS.
@@ -1480,11 +1479,11 @@ MATHJAX_FORMAT = HTML-CSS
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
# Content Delivery Network so you can quickly see the result without installing
# MathJax. However, it is strongly recommended to install a local copy of
# MathJax from http://www.mathjax.org before deployment.
# The default value is: http://cdn.mathjax.org/mathjax/latest.
# MathJax from https://www.mathjax.org before deployment.
# The default value is: https://cdnjs.com/libraries/mathjax/.
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
MATHJAX_RELPATH = https://cdnjs.com/libraries/mathjax/
# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
# extension names that should be enabled during MathJax rendering. For example
@@ -1495,7 +1494,7 @@ MATHJAX_EXTENSIONS =
# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
# of code that will be used on startup of the MathJax code. See the MathJax site
# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
# (see: https://docs.mathjax.org/en/latest/output.html) for more details. For an
# example see the documentation.
# This tag requires that the tag USE_MATHJAX is set to YES.
@@ -1542,7 +1541,7 @@ SERVER_BASED_SEARCH = NO
#
# Doxygen ships with an example indexer ( doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
# Xapian (see: http://xapian.org/).
# Xapian (see: https://xapian.org/).
#
# See the section "External Indexing and Searching" for details.
# The default value is: NO.
@@ -1555,7 +1554,7 @@ EXTERNAL_SEARCH = NO
#
# Doxygen ships with an example indexer ( doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
# Xapian (see: http://xapian.org/). See the section "External Indexing and
# Xapian (see: https://xapian.org/). See the section "External Indexing and
# Searching" for details.
# This tag requires that the tag SEARCHENGINE is set to YES.
@@ -1726,7 +1725,7 @@ LATEX_SOURCE_CODE = NO
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
# bibliography, e.g. plainnat, or ieeetr. See
# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
# The default value is: plain.
# This tag requires that the tag GENERATE_LATEX is set to YES.

View File

@@ -565,6 +565,11 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc,
std::cerr << " - " << name << std::endl;
return false;
}
catch (std::string s)
{
std::cerr << "Error: " << s << std::endl;
return false;
}
//pull the input scalars into their own vector
std::vector<volk_gnsssdr_type_t> inputsc;

View File

@@ -25,6 +25,7 @@
#include <iostream> // for operator<<, basic_ostream, endl, char...
#include <fstream> // IWYU pragma: keep
#include <map> // for map, map<>::iterator, _Rb_tree_iterator
#include <sstream> // for stringstream
#include <string> // for string, operator<<
#include <utility> // for pair
#include <vector> // for vector
@@ -48,15 +49,16 @@ int main(int argc, char* argv[])
std::vector<volk_gnsssdr_test_results_t> results;
if (argc > 1)
{
const size_t len = std::char_traits<char>::length(argv[1]);
if (len == 0 || len > 2046)
std::stringstream ss;
ss << argv[1];
if (ss.fail())
{
std::cerr << "Test name is too long." << std::endl;
std::cerr << "Test name not correctly set." << std::endl;
return 0;
}
for (unsigned int ii = 0; ii < test_cases.size(); ++ii)
{
if (std::string(argv[1]) == test_cases[ii].name())
if (ss.str() == test_cases[ii].name())
{
volk_gnsssdr_test_case_t test_case = test_cases[ii];
if (run_volk_gnsssdr_tests(test_case.desc(), test_case.kernel_ptr(),

View File

@@ -76,8 +76,7 @@ This will put the code for the new kernel into
Other kernels must be added by hand. See the following webpages for
more information about creating VOLK kernels:
http://gnuradio.org/doc/doxygen/volk_gnsssdr_guide.html
http://gnuradio.org/redmine/projects/gnuradio/wiki/Volk
https://www.gnuradio.org/doc/doxygen/volk_guide.html
======================================================================

View File

@@ -22,62 +22,42 @@ list(SORT SIGNAL_SOURCE_ADAPTER_HEADERS)
# Optional drivers
if(ENABLE_RAW_UDP)
# - Try to find libpcap include dirs and libraries
#
# Usage of this module as follows:
#
# find_package(PCAP)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# PCAP_ROOT_DIR Set this variable to the root installation of
# libpcap if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# PCAP_FOUND System has libpcap, include and library dirs found
# PCAP_INCLUDE_DIR The libpcap include directories.
# PCAP_LIBRARY The libpcap library (possibly includes a thread
# library e.g. required by pf_ring's libpcap)
# HAVE_PF_RING If a found version of libpcap supports PF_RING
find_package(PCAP)
if(NOT PCAP_FOUND)
message(FATAL_ERROR "PCAP required to compile custom UDP packet sample source (ENABLE_RAW_UDP)")
endif()
get_filename_component(PCAP_LIBRARY_DIRS ${PCAP_LIBRARY} DIRECTORY CACHE)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${PCAP_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${PCAP_INCLUDE_DIRS})
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} custom_udp_signal_source.cc)
find_package(PCAP)
if(NOT PCAP_FOUND)
message(FATAL_ERROR "PCAP required to compile custom UDP packet sample source (ENABLE_RAW_UDP)")
endif(NOT PCAP_FOUND)
get_filename_component(PCAP_LIBRARY_DIRS ${PCAP_LIBRARY} DIRECTORY CACHE)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${PCAP_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${PCAP_INCLUDE_DIRS})
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} custom_udp_signal_source.cc)
endif(ENABLE_RAW_UDP)
if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
find_package(Griio REQUIRED)
if(NOT IIO_FOUND)
message(STATUS "gnuradio-iio not found, its installation is required.")
message(STATUS "Please build and install the following projects:")
message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio")
message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio")
message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio")
message(FATAL_ERROR "gnuradio-iio is required for building gnss-sdr with this option enabled.")
endif(NOT IIO_FOUND)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS})
find_package(Griio REQUIRED)
if(NOT IIO_FOUND)
message(STATUS "gnuradio-iio not found, its installation is required.")
message(STATUS "Please build and install the following projects:")
message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio")
message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio")
message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio")
message(FATAL_ERROR "gnuradio-iio is required for building gnss-sdr with this option enabled.")
endif(NOT IIO_FOUND)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS})
endif(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
if(ENABLE_AD9361)
find_package(libiio REQUIRED)
if(NOT LIBIIO_FOUND)
message(STATUS "libiio not found, its installation is required.")
message(STATUS "Please build and install the following projects:")
message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio")
message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio")
message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio")
message(FATAL_ERROR "libiio is required for building gnss-sdr with this option enabled.")
endif(NOT LIBIIO_FOUND)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${LIBIIO_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${LIBIIO_INCLUDE_DIRS})
find_package(libiio REQUIRED)
if(NOT LIBIIO_FOUND)
message(STATUS "libiio not found, its installation is required.")
message(STATUS "Please build and install the following projects:")
message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio")
message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio")
message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio")
message(FATAL_ERROR "libiio is required for building gnss-sdr with this option enabled.")
endif(NOT LIBIIO_FOUND)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${LIBIIO_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${LIBIIO_INCLUDE_DIRS})
endif(ENABLE_AD9361)

View File

@@ -36,6 +36,7 @@
#include "GPS_L1_CA.h"
#include "GPS_L2C.h"
#include <glog/logging.h>
#include <exception>
#include <iostream> // for cout, endl
#ifdef __APPLE__
@@ -122,7 +123,14 @@ Ad9361FpgaSignalSource::~Ad9361FpgaSignalSource()
if (enable_dds_lo_)
{
ad9361_disable_lo_local();
try
{
ad9361_disable_lo_local();
}
catch (const std::exception& e)
{
LOG(WARNING) << "Problem closing the Ad9361FpgaSignalSource: " << e.what();
}
}
// std::cout<<"* AD9361 Destroying context\n";
@@ -132,12 +140,18 @@ Ad9361FpgaSignalSource::~Ad9361FpgaSignalSource()
void Ad9361FpgaSignalSource::connect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
DLOG(INFO) << "AD9361 FPGA source nothing to connect";
}
void Ad9361FpgaSignalSource::disconnect(gr::top_block_sptr top_block)
{
if (top_block)
{ /* top_block is not null */
};
DLOG(INFO) << "AD9361 FPGA source nothing to disconnect";
}

View File

@@ -1,6 +1,6 @@
/*!
* \filei fmcomms2_signal_source.cc
* \brief signal source for sdr hardware from analog devices based on
* \file fmcomms2_signal_source.cc
* \brief Signal source for SDR hardware from Analog Devices based on
* fmcomms2 evaluation board.
* \author Rodrigo Muñoz, 2017, rmunozl(at)inacap.cl
*
@@ -36,6 +36,7 @@
#include "GPS_L1_CA.h"
#include "GPS_L2C.h"
#include <glog/logging.h>
#include <exception>
#include <iostream>
@@ -70,7 +71,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
dump_ = configuration->property(role + ".dump", false);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
//AD9361 Local Oscillator generation for dual band operation
// AD9361 Local Oscillator generation for dual band operation
enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false);
freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - 1000);
freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000);
@@ -104,7 +105,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
rf_port_select_.c_str(), filter_file_.c_str(),
filter_auto_);
//configure LO
// configure LO
if (enable_dds_lo_ == true)
{
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
@@ -135,7 +136,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
gain_mode_rx2_.c_str(), rf_gain_rx2_,
rf_port_select_.c_str(), filter_file_.c_str(),
filter_auto_);
//configure LO
// configure LO
if (enable_dds_lo_ == true)
{
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
@@ -179,7 +180,14 @@ Fmcomms2SignalSource::~Fmcomms2SignalSource()
{
if (enable_dds_lo_ == true)
{
ad9361_disable_lo_remote(uri_);
try
{
ad9361_disable_lo_remote(uri_);
}
catch (const std::exception& e)
{
LOG(WARNING) << "Exception thrown in Fmcomms2SignalSource destructor: " << e.what();
}
}
}

View File

@@ -18,34 +18,14 @@
if(ENABLE_RAW_UDP)
# - Try to find libpcap include dirs and libraries
#
# Usage of this module as follows:
#
# find_package(PCAP)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# PCAP_ROOT_DIR Set this variable to the root installation of
# libpcap if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# PCAP_FOUND System has libpcap, include and library dirs found
# PCAP_INCLUDE_DIR The libpcap include directories.
# PCAP_LIBRARY The libpcap library (possibly includes a thread
# library e.g. required by pf_ring's libpcap)
# HAVE_PF_RING If a found version of libpcap supports PF_RING
find_package(PCAP)
if(NOT PCAP_FOUND)
message(FATAL_ERROR "PCAP required to compile custom UDP packet sample source (ENABLE_RAW_UDP)")
endif()
get_filename_component(PCAP_LIBRARY_DIRS ${PCAP_LIBRARY} DIRECTORY CACHE)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${PCAP_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${PCAP_INCLUDE_DIRS})
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} gr_complex_ip_packet_source.cc)
find_package(PCAP)
if(NOT PCAP_FOUND)
message(FATAL_ERROR "PCAP required to compile custom UDP packet sample source (ENABLE_RAW_UDP)")
endif(NOT PCAP_FOUND)
get_filename_component(PCAP_LIBRARY_DIRS ${PCAP_LIBRARY} DIRECTORY CACHE)
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${PCAP_LIBRARIES})
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${PCAP_INCLUDE_DIRS})
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} gr_complex_ip_packet_source.cc)
endif(ENABLE_RAW_UDP)
set(SIGNAL_SOURCE_GR_BLOCKS_SOURCES

View File

@@ -33,10 +33,8 @@
#include "gr_complex_ip_packet_source.h"
#include <gnuradio/io_signature.h>
//#include <cstdlib>
#define FIFO_SIZE 1472000
const int FIFO_SIZE = 1472000;
/* 4 bytes IP address */
@@ -48,6 +46,7 @@ typedef struct gr_ip_address
u_char byte4;
} gr_ip_address;
/* IPv4 header */
typedef struct gr_ip_header
{
@@ -64,6 +63,7 @@ typedef struct gr_ip_header
u_int op_pad; // Option + Padding
} gr_ip_header;
/* UDP header*/
typedef struct gr_udp_header
{
@@ -73,6 +73,7 @@ typedef struct gr_udp_header
u_short crc; // Checksum
} gr_udp_header;
gr_complex_ip_packet_source::sptr
gr_complex_ip_packet_source::make(std::string src_device,
std::string origin_address,
@@ -93,6 +94,7 @@ gr_complex_ip_packet_source::make(std::string src_device,
IQ_swap_));
}
/*
* The private constructor
*/
@@ -106,9 +108,8 @@ gr_complex_ip_packet_source::gr_complex_ip_packet_source(std::string src_device,
bool IQ_swap_)
: gr::sync_block("gr_complex_ip_packet_source",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(1, 4, item_size)) //1 to 4 baseband complex channels
gr::io_signature::make(1, 4, item_size)) // 1 to 4 baseband complex channels
{
// constructor code here
std::cout << "Start Ethernet packet capture\n";
d_n_baseband_channels = n_baseband_channels;
@@ -133,7 +134,7 @@ gr_complex_ip_packet_source::gr_complex_ip_packet_source(std::string src_device,
d_udp_payload_size = udp_packet_size;
d_fifo_full = false;
//allocate signal samples buffer
// allocate signal samples buffer
fifo_buff = new char[FIFO_SIZE];
fifo_read_ptr = 0;
fifo_write_ptr = 0;
@@ -143,14 +144,16 @@ gr_complex_ip_packet_source::gr_complex_ip_packet_source(std::string src_device,
d_sock_raw = 0;
d_pcap_thread = NULL;
descr = NULL;
memset(reinterpret_cast<char *>(&si_me), 0, sizeof(si_me));
}
//Called by gnuradio to enable drivers, etc for i/o devices.
// Called by gnuradio to enable drivers, etc for i/o devices.
bool gr_complex_ip_packet_source::start()
{
std::cout << "gr_complex_ip_packet_source START\n";
//open the ethernet device
// open the ethernet device
if (open() == true)
{
// start pcap capture thread
@@ -163,7 +166,8 @@ bool gr_complex_ip_packet_source::start()
}
}
//Called by gnuradio to disable drivers, etc for i/o devices.
// Called by gnuradio to disable drivers, etc for i/o devices.
bool gr_complex_ip_packet_source::stop()
{
std::cout << "gr_complex_ip_packet_source STOP\n";
@@ -176,42 +180,44 @@ bool gr_complex_ip_packet_source::stop()
return true;
}
bool gr_complex_ip_packet_source::open()
{
char errbuf[PCAP_ERRBUF_SIZE];
boost::mutex::scoped_lock lock(d_mutex); // hold mutex for duration of this function
/* open device for reading */
// open device for reading
descr = pcap_open_live(d_src_device.c_str(), 1500, 1, 1000, errbuf);
if (descr == NULL)
{
std::cout << "Error openning Ethernet device " << d_src_device << std::endl;
printf("Fatal Error in pcap_open_live(): %s\n", errbuf);
std::cout << "Error opening Ethernet device " << d_src_device << std::endl;
std::cout << "Fatal Error in pcap_open_live(): " << std::string(errbuf) << std::endl;
return false;
}
//bind UDP port to avoid automatic reply with ICMP port ureacheable packets from kernel
// bind UDP port to avoid automatic reply with ICMP port unreachable packets from kernel
d_sock_raw = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (d_sock_raw == -1)
{
std::cout << "Error openning UDP socket" << std::endl;
std::cout << "Error opening UDP socket" << std::endl;
return false;
}
// zero out the structure
memset((char *)&si_me, 0, sizeof(si_me));
memset(reinterpret_cast<char *>(&si_me), 0, sizeof(si_me));
si_me.sin_family = AF_INET;
si_me.sin_port = htons(d_udp_port);
si_me.sin_addr.s_addr = htonl(INADDR_ANY);
//bind socket to port
if (bind(d_sock_raw, (struct sockaddr *)&si_me, sizeof(si_me)) == -1)
// bind socket to port
if (bind(d_sock_raw, reinterpret_cast<struct sockaddr *>(&si_me), sizeof(si_me)) == -1)
{
std::cout << "Error openning UDP socket" << std::endl;
std::cout << "Error opening UDP socket" << std::endl;
return false;
}
return true;
}
gr_complex_ip_packet_source::~gr_complex_ip_packet_source()
{
if (d_pcap_thread != NULL)
@@ -222,35 +228,36 @@ gr_complex_ip_packet_source::~gr_complex_ip_packet_source()
std::cout << "Stop Ethernet packet capture\n";
}
void gr_complex_ip_packet_source::static_pcap_callback(u_char *args, const struct pcap_pkthdr *pkthdr,
const u_char *packet)
{
gr_complex_ip_packet_source *bridge = (gr_complex_ip_packet_source *)args;
gr_complex_ip_packet_source *bridge = reinterpret_cast<gr_complex_ip_packet_source *>(args);
bridge->pcap_callback(args, pkthdr, packet);
}
void gr_complex_ip_packet_source::pcap_callback(__attribute__((unused)) u_char *args, __attribute__((unused)) const struct pcap_pkthdr *pkthdr,
const u_char *packet)
{
boost::mutex::scoped_lock lock(d_mutex); // hold mutex for duration of this function
gr_ip_header *ih;
gr_udp_header *uh;
const gr_ip_header *ih;
const gr_udp_header *uh;
// eth frame parameters
// **** UDP RAW PACKET DECODER ****
if ((packet[12] == 0x08) & (packet[13] == 0x00)) //IP FRAME
if ((packet[12] == 0x08) & (packet[13] == 0x00)) // IP FRAME
{
/* retireve the position of the ip header */
ih = (gr_ip_header *)(packet +
14); //length of ethernet header
// retrieve the position of the ip header
ih = reinterpret_cast<const gr_ip_header *>(packet + 14); // length of ethernet header
/* retireve the position of the udp header */
// retrieve the position of the udp header
u_int ip_len;
ip_len = (ih->ver_ihl & 0xf) * 4;
uh = (gr_udp_header *)((u_char *)ih + ip_len);
uh = reinterpret_cast<const gr_udp_header *>(reinterpret_cast<const u_char *>(ih) + ip_len);
/* convert from network byte order to host byte order */
// convert from network byte order to host byte order
//u_short sport;
u_short dport;
dport = ntohs(uh->dport);
@@ -271,44 +278,45 @@ void gr_complex_ip_packet_source::pcap_callback(__attribute__((unused)) u_char *
// dport);
// std::cout<<"uh->len:"<<ntohs(uh->len)<<std::endl;
int payload_lenght_bytes = ntohs(uh->len) - 8; //total udp packet lenght minus the header lenght
//read the payload bytes and insert them into the shared circular buffer
u_char *udp_payload = ((u_char *)uh + sizeof(gr_udp_header));
if (fifo_items <= (FIFO_SIZE - payload_lenght_bytes))
int payload_length_bytes = ntohs(uh->len) - 8; // total udp packet length minus the header length
// read the payload bytes and insert them into the shared circular buffer
const u_char *udp_payload = (reinterpret_cast<const u_char *>(uh) + sizeof(gr_udp_header));
if (fifo_items <= (FIFO_SIZE - payload_length_bytes))
{
int aligned_write_items = FIFO_SIZE - fifo_write_ptr;
if (aligned_write_items >= payload_lenght_bytes)
if (aligned_write_items >= payload_length_bytes)
{
//write all in a single memcpy
memcpy(&fifo_buff[fifo_write_ptr], &udp_payload[0], payload_lenght_bytes); //size in bytes
fifo_write_ptr += payload_lenght_bytes;
// write all in a single memcpy
memcpy(&fifo_buff[fifo_write_ptr], &udp_payload[0], payload_length_bytes); // size in bytes
fifo_write_ptr += payload_length_bytes;
if (fifo_write_ptr == FIFO_SIZE) fifo_write_ptr = 0;
fifo_items += payload_lenght_bytes;
fifo_items += payload_length_bytes;
}
else
{
//two step wrap write
memcpy(&fifo_buff[fifo_write_ptr], &udp_payload[0], aligned_write_items); //size in bytes
fifo_write_ptr = payload_lenght_bytes - aligned_write_items;
memcpy(&fifo_buff[0], &udp_payload[aligned_write_items], fifo_write_ptr); //size in bytes
fifo_items += payload_lenght_bytes;
// two step wrap write
memcpy(&fifo_buff[fifo_write_ptr], &udp_payload[0], aligned_write_items); // size in bytes
fifo_write_ptr = payload_length_bytes - aligned_write_items;
memcpy(&fifo_buff[0], &udp_payload[aligned_write_items], fifo_write_ptr); // size in bytes
fifo_items += payload_length_bytes;
}
}
else
{
//notify overflow
// notify overflow
std::cout << "O" << std::flush;
}
}
}
}
void gr_complex_ip_packet_source::my_pcap_loop_thread(pcap_t *pcap_handle)
void gr_complex_ip_packet_source::my_pcap_loop_thread(pcap_t *pcap_handle)
{
pcap_loop(pcap_handle, -1, gr_complex_ip_packet_source::static_pcap_callback, (u_char *)this);
pcap_loop(pcap_handle, -1, gr_complex_ip_packet_source::static_pcap_callback, reinterpret_cast<u_char *>(this));
}
void gr_complex_ip_packet_source::demux_samples(gr_vector_void_star output_items, int num_samples_readed)
{
int8_t real;
@@ -318,22 +326,22 @@ void gr_complex_ip_packet_source::demux_samples(gr_vector_void_star output_items
{
switch (d_wire_sample_type)
{
case 1: //interleaved byte samples
case 1: // interleaved byte samples
for (long unsigned int i = 0; i < output_items.size(); i++)
{
real = fifo_buff[fifo_read_ptr++];
imag = fifo_buff[fifo_read_ptr++];
if (d_IQ_swap)
{
(static_cast<gr_complex *>(output_items[i]))[n] = gr_complex(real, imag);
static_cast<gr_complex *>(output_items[i])[n] = gr_complex(real, imag);
}
else
{
(static_cast<gr_complex *>(output_items[i]))[n] = gr_complex(imag, real);
static_cast<gr_complex *>(output_items[i])[n] = gr_complex(imag, real);
}
}
break;
case 2: // 4bits samples
case 2: // 4-bit samples
for (long unsigned int i = 0; i < output_items.size(); i++)
{
tmp_char2 = fifo_buff[fifo_read_ptr] & 0x0F;
@@ -357,11 +365,11 @@ void gr_complex_ip_packet_source::demux_samples(gr_vector_void_star output_items
}
if (d_IQ_swap)
{
(static_cast<gr_complex *>(output_items[i]))[n] = gr_complex(imag, real);
static_cast<gr_complex *>(output_items[i])[n] = gr_complex(imag, real);
}
else
{
(static_cast<gr_complex *>(output_items[i]))[n] = gr_complex(real, imag);
static_cast<gr_complex *>(output_items[i])[n] = gr_complex(real, imag);
}
}
break;
@@ -373,6 +381,7 @@ void gr_complex_ip_packet_source::demux_samples(gr_vector_void_star output_items
}
}
int gr_complex_ip_packet_source::work(int noutput_items,
__attribute__((unused)) gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
@@ -390,44 +399,44 @@ int gr_complex_ip_packet_source::work(int noutput_items,
int bytes_requested;
switch (d_wire_sample_type)
{
case 1: //complex byte samples
case 1: // complex byte samples
bytes_requested = noutput_items * d_bytes_per_sample;
if (bytes_requested < fifo_items)
{
num_samples_readed = noutput_items; //read all
num_samples_readed = noutput_items; // read all
}
else
{
num_samples_readed = fifo_items / d_bytes_per_sample; //read what we have
num_samples_readed = fifo_items / d_bytes_per_sample; // read what we have
}
break;
case 2: //complex 4 bits samples
case 2: // complex 4 bits samples
bytes_requested = noutput_items * d_bytes_per_sample;
if (bytes_requested < fifo_items)
{
num_samples_readed = noutput_items; //read all
num_samples_readed = noutput_items; // read all
}
else
{
num_samples_readed = fifo_items / d_bytes_per_sample; //read what we have
num_samples_readed = fifo_items / d_bytes_per_sample; // read what we have
}
break;
default: //complex byte samples
default: // complex byte samples
bytes_requested = noutput_items * d_bytes_per_sample;
if (bytes_requested < fifo_items)
{
num_samples_readed = noutput_items; //read all
num_samples_readed = noutput_items; // read all
}
else
{
num_samples_readed = fifo_items / d_bytes_per_sample; //read what we have
num_samples_readed = fifo_items / d_bytes_per_sample; // read what we have
}
}
bytes_requested = num_samples_readed * d_bytes_per_sample;
//read all in a single loop
// read all in a single loop
demux_samples(output_items, num_samples_readed); // it also increases the fifo read pointer
//update fifo items
// update fifo items
fifo_items = fifo_items - bytes_requested;
for (long unsigned int n = 0; n < output_items.size(); n++)

View File

@@ -154,7 +154,7 @@ rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
rtl_tcp_signal_source_c::~rtl_tcp_signal_source_c()
{
boost::mutex::scoped_lock lock(mutex_);
mutex_.unlock();
io_service_.stop();
not_empty_.notify_one();
not_full_.notify_one();

View File

@@ -281,7 +281,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0));
clear_tracking_vars();
// map memory pointers of correlator outputs
if (d_veml)
@@ -328,17 +328,14 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
{
// Extra correlator for the data component
correlator_data_cpu.init(2 * trk_parameters.vector_length, 1);
d_Prompt_Data = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_Prompt_Data[0] = gr_complex(0.0, 0.0);
d_data_code = static_cast<float *>(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment()));
}
else
{
d_Prompt_Data = nullptr;
d_data_code = nullptr;
}
//--- Initializations ---//
// --- Initializations ---
// Initial code frequency basis of NCO
d_code_freq_chips = d_code_chip_rate;
// Residual code phase (in chips)
@@ -359,8 +356,8 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
d_CN0_SNV_dB_Hz = 0.0;
d_carrier_lock_fail_counter = 0;
d_carrier_lock_threshold = trk_parameters.carrier_lock_th;
clear_tracking_vars();
d_Prompt_Data = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_Prompt_Data[0] = gr_complex(0.0, 0.0);
d_acquisition_gnss_synchro = nullptr;
d_channel = 0;
@@ -383,9 +380,8 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
void dll_pll_veml_tracking::start_tracking()
{
gr::thread::scoped_lock l(d_setlock);
/*
* correct the code phase according to the delay between acq and trk
*/
// correct the code phase according to the delay between acq and trk
d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples;
d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz;
d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples;
@@ -396,7 +392,7 @@ void dll_pll_veml_tracking::start_tracking()
DLOG(INFO) << "Number of seconds between Acquisition and Tracking = " << acq_trk_diff_seconds;
// Doppler effect Fd = (C / (C + Vr)) * F
double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq;
// new chip and prn sequence periods based on acq Doppler
// new chip and PRN sequence periods based on acq Doppler
d_code_freq_chips = radial_velocity * d_code_chip_rate;
d_code_phase_step_chips = d_code_freq_chips / trk_parameters.fs_in;
double T_chip_mod_seconds = 1.0 / d_code_freq_chips;
@@ -564,9 +560,9 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking()
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_tracking_code);
volk_gnsssdr_free(d_Prompt_Data);
if (trk_parameters.track_pilot)
{
volk_gnsssdr_free(d_Prompt_Data);
volk_gnsssdr_free(d_data_code);
correlator_data_cpu.free();
}
@@ -735,7 +731,7 @@ void dll_pll_veml_tracking::run_dll_pll()
void dll_pll_veml_tracking::clear_tracking_vars()
{
std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0));
if (trk_parameters.track_pilot) *d_Prompt_Data = gr_complex(0.0, 0.0);
if (trk_parameters.track_pilot) d_Prompt_Data[0] = gr_complex(0.0, 0.0);
d_carr_error_hz = 0.0;
d_carr_error_filt_hz = 0.0;
d_code_error_chips = 0.0;