mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-09-10 06:19:48 +00:00
Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into next
This commit is contained in:
commit
fe86f3d2ad
@ -2286,6 +2286,15 @@ else()
|
|||||||
TYPE OPTIONAL
|
TYPE OPTIONAL
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
find_package(LIBAD9361)
|
||||||
|
set_package_properties(LIBAD9361 PROPERTIES
|
||||||
|
PURPOSE "Used for configuring the AD9361 chipset"
|
||||||
|
TYPE OPTIONAL
|
||||||
|
)
|
||||||
|
if(NOT LIBAD9361_FOUND)
|
||||||
|
set(ENABLE_AD9361 OFF)
|
||||||
|
set(ENABLE_FMCOMMS2 OFF)
|
||||||
|
endif()
|
||||||
if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
|
if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
|
||||||
if(NOT GRIIO_FOUND)
|
if(NOT GRIIO_FOUND)
|
||||||
message(STATUS "gnuradio-iio not found, its installation is required.")
|
message(STATUS "gnuradio-iio not found, its installation is required.")
|
||||||
@ -2566,9 +2575,9 @@ add_subdirectory(src)
|
|||||||
################################################################################
|
################################################################################
|
||||||
add_feature_info(ENABLE_UHD ENABLE_UHD "Enables UHD_Signal_Source for using RF front-ends from the USRP family. Requires gr-uhd.")
|
add_feature_info(ENABLE_UHD ENABLE_UHD "Enables UHD_Signal_Source for using RF front-ends from the USRP family. Requires gr-uhd.")
|
||||||
add_feature_info(ENABLE_OSMOSDR ENABLE_OSMOSDR "Enables Osmosdr_Signal_Source and RtlTcp_Signal_Source for using RF front-ends compatible with the OsmoSDR driver. Requires gr-osmosdr.")
|
add_feature_info(ENABLE_OSMOSDR ENABLE_OSMOSDR "Enables Osmosdr_Signal_Source and RtlTcp_Signal_Source for using RF front-ends compatible with the OsmoSDR driver. Requires gr-osmosdr.")
|
||||||
add_feature_info(ENABLE_FMCOMMS2 ENABLE_FMCOMMS2 "Enables Fmcomms2_Signal_Source for FMCOMMS2/3/4 devices. Requires gr-iio.")
|
add_feature_info(ENABLE_FMCOMMS2 ENABLE_FMCOMMS2 "Enables Fmcomms2_Signal_Source for FMCOMMS2/3/4 devices. Requires gr-iio and libad9361-dev.")
|
||||||
add_feature_info(ENABLE_PLUTOSDR ENABLE_PLUTOSDR "Enables Plutosdr_Signal_Source for using ADALM-PLUTO boards. Requires gr-iio.")
|
add_feature_info(ENABLE_PLUTOSDR ENABLE_PLUTOSDR "Enables Plutosdr_Signal_Source for using ADALM-PLUTO boards. Requires gr-iio.")
|
||||||
add_feature_info(ENABLE_AD9361 ENABLE_AD9361 "Enables Ad9361_Fpga_Signal_Source for devices with the AD9361 chipset. Requires libiio.")
|
add_feature_info(ENABLE_AD9361 ENABLE_AD9361 "Enables Ad9361_Fpga_Signal_Source for devices with the AD9361 chipset. Requires libiio and libad9361-dev.")
|
||||||
add_feature_info(ENABLE_RAW_UDP ENABLE_RAW_UDP "Enables Custom_UDP_Signal_Source for custom UDP packet sample source. Requires libpcap.")
|
add_feature_info(ENABLE_RAW_UDP ENABLE_RAW_UDP "Enables Custom_UDP_Signal_Source for custom UDP packet sample source. Requires libpcap.")
|
||||||
add_feature_info(ENABLE_FLEXIBAND ENABLE_FLEXIBAND "Enables Flexiband_Signal_Source for using Teleorbit's Flexiband RF front-end. Requires gr-teleorbit.")
|
add_feature_info(ENABLE_FLEXIBAND ENABLE_FLEXIBAND "Enables Flexiband_Signal_Source for using Teleorbit's Flexiband RF front-end. Requires gr-teleorbit.")
|
||||||
add_feature_info(ENABLE_GN3S ENABLE_GN3S "Enables Gn3s_Signal_Source for using the GN3S v2 dongle. Requires gr-gn3s.")
|
add_feature_info(ENABLE_GN3S ENABLE_GN3S "Enables Gn3s_Signal_Source for using the GN3S v2 dongle. Requires gr-gn3s.")
|
||||||
|
124
cmake/Modules/FindLIBAD9361.cmake
Normal file
124
cmake/Modules/FindLIBAD9361.cmake
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors)
|
||||||
|
#
|
||||||
|
# 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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#
|
||||||
|
# Provides the following imported target:
|
||||||
|
# Iio::iio
|
||||||
|
#
|
||||||
|
|
||||||
|
if(NOT COMMAND feature_summary)
|
||||||
|
include(FeatureSummary)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
|
||||||
|
include(FindPkgConfig)
|
||||||
|
pkg_check_modules(PC_LIBAD9361 libad9361)
|
||||||
|
|
||||||
|
find_path(
|
||||||
|
LIBAD9361_INCLUDE_DIRS
|
||||||
|
NAMES ad9361.h
|
||||||
|
HINTS ${PC_LIBAD9361_INCLUDEDIR}
|
||||||
|
PATHS /usr/include
|
||||||
|
/usr/local/include
|
||||||
|
/opt/local/include
|
||||||
|
${CMAKE_INSTALL_PREFIX}/include
|
||||||
|
${LIBAD9361_ROOT}/include
|
||||||
|
$ENV{LIBAD9361_ROOT}/include
|
||||||
|
$ENV{LIBAD9361_DIR}/include
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(
|
||||||
|
LIBAD9361_LIBRARIES
|
||||||
|
NAMES ad9361
|
||||||
|
HINTS ${PC_LIBAD9361_LIBDIR}
|
||||||
|
PATHS /usr/lib
|
||||||
|
/usr/lib64
|
||||||
|
/usr/lib/x86_64-linux-gnu
|
||||||
|
/usr/lib/i386-linux-gnu
|
||||||
|
/usr/lib/alpha-linux-gnu
|
||||||
|
/usr/lib/aarch64-linux-gnu
|
||||||
|
/usr/lib/arm-linux-gnueabi
|
||||||
|
/usr/lib/arm-linux-gnueabihf
|
||||||
|
/usr/lib/hppa-linux-gnu
|
||||||
|
/usr/lib/i686-gnu
|
||||||
|
/usr/lib/i686-linux-gnu
|
||||||
|
/usr/lib/x86_64-kfreebsd-gnu
|
||||||
|
/usr/lib/i686-kfreebsd-gnu
|
||||||
|
/usr/lib/m68k-linux-gnu
|
||||||
|
/usr/lib/mips-linux-gnu
|
||||||
|
/usr/lib/mips64el-linux-gnuabi64
|
||||||
|
/usr/lib/mipsel-linux-gnu
|
||||||
|
/usr/lib/powerpc-linux-gnu
|
||||||
|
/usr/lib/powerpc-linux-gnuspe
|
||||||
|
/usr/lib/powerpc64-linux-gnu
|
||||||
|
/usr/lib/powerpc64le-linux-gnu
|
||||||
|
/usr/lib/s390x-linux-gnu
|
||||||
|
/usr/lib/sparc64-linux-gnu
|
||||||
|
/usr/lib/x86_64-linux-gnux32
|
||||||
|
/usr/lib/sh4-linux-gnu
|
||||||
|
/usr/lib/riscv64-linux-gnu
|
||||||
|
/usr/local/lib
|
||||||
|
/usr/local/lib64
|
||||||
|
/opt/local/lib
|
||||||
|
/Library/Frameworks/ad9361.framework
|
||||||
|
${CMAKE_INSTALL_PREFIX}/lib
|
||||||
|
${CMAKE_INSTALL_PREFIX}/lib64
|
||||||
|
${LIBAD9361_ROOT}/lib
|
||||||
|
$ENV{LIBAD9361_ROOT}/lib
|
||||||
|
${LIBAD9361_ROOT}/lib64
|
||||||
|
$ENV{LIBAD9361_ROOT}/lib64
|
||||||
|
$ENV{LIBAD9361_DIR}/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LIBAD9361_LIBRARIES AND APPLE)
|
||||||
|
if(LIBAD9361_LIBRARIES MATCHES "framework")
|
||||||
|
set(LIBAD9361_LIBRARIES ${LIBAD9361_LIBRARIES}/ad9361)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(LIBAD9361 DEFAULT_MSG LIBAD9361_LIBRARIES LIBAD9361_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
if(PC_LIBAD9361_VERSION)
|
||||||
|
set(LIBAD9361_VERSION ${PC_LIBAD9361_VERSION})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBAD9361_FOUND AND LIBAD9361_VERSION)
|
||||||
|
set_package_properties(LIBAD9361 PROPERTIES
|
||||||
|
DESCRIPTION "A library for interfacing with AD936X RF transceivers (found: v${LIBAD9361_VERSION})"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
set_package_properties(LIBAD9361 PROPERTIES
|
||||||
|
DESCRIPTION "A library for interfacing with AD936X RF transceivers"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_package_properties(LIBAD9361 PROPERTIES
|
||||||
|
URL "https://github.com/analogdevicesinc/libad9361-iio"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LIBAD9361_FOUND AND NOT TARGET Iio::ad9361)
|
||||||
|
add_library(Iio::ad9361 SHARED IMPORTED)
|
||||||
|
set_target_properties(Iio::ad9361 PROPERTIES
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
|
||||||
|
IMPORTED_LOCATION "${LIBAD9361_LIBRARIES}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${LIBAD9361_INCLUDE_DIRS}"
|
||||||
|
INTERFACE_LINK_LIBRARIES "${LIBAD9361_LIBRARIES}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(LIBAD9361_LIBRARIES LIBAD9361_INCLUDE_DIRS)
|
@ -57,7 +57,7 @@ if(ENABLE_GN3S)
|
|||||||
# GN3S (USB dongle)
|
# GN3S (USB dongle)
|
||||||
##############################################
|
##############################################
|
||||||
if(NOT GRGN3S_FOUND)
|
if(NOT GRGN3S_FOUND)
|
||||||
message(" gr-gn3s not found, install it from https://github.com/gnss-sdr/gr-gn3s ")
|
message(" gr-gn3s not found, install it from https://github.com/gnss-sdr/gr-gn3s")
|
||||||
message(FATAL_ERROR "gr-gn3s required for building gnss-sdr with this option enabled")
|
message(FATAL_ERROR "gr-gn3s required for building gnss-sdr with this option enabled")
|
||||||
endif()
|
endif()
|
||||||
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} gn3s_signal_source.cc)
|
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} gn3s_signal_source.cc)
|
||||||
@ -76,7 +76,7 @@ if(ENABLE_ARRAY)
|
|||||||
# DBFCTTC GNSS EXPERIMENTAL ARRAY PROTOTYPE
|
# DBFCTTC GNSS EXPERIMENTAL ARRAY PROTOTYPE
|
||||||
##############################################
|
##############################################
|
||||||
if(NOT GRDBFCTTC_FOUND)
|
if(NOT GRDBFCTTC_FOUND)
|
||||||
message(" gr-dbfcttc not found, install it from https://github.com/gnss-sdr/gr-dbfcttc ")
|
message(" gr-dbfcttc not found, install it from https://github.com/gnss-sdr/gr-dbfcttc")
|
||||||
message(FATAL_ERROR "gr-dbfcttc required for building gnss-sdr with this option enabled")
|
message(FATAL_ERROR "gr-dbfcttc required for building gnss-sdr with this option enabled")
|
||||||
endif()
|
endif()
|
||||||
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} raw_array_signal_source.cc)
|
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} raw_array_signal_source.cc)
|
||||||
@ -189,6 +189,16 @@ if(ENABLE_AD9361 AND LIBIIO_FOUND)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_AD9361 OR ENABLE_FMCOMMS2 OR ENABLE_PLUTOSDR)
|
||||||
|
if(LIBAD9361_VERSION)
|
||||||
|
if(LIBAD9361_VERSION VERSION_GREATER 0.1)
|
||||||
|
target_compile_definitions(signal_source_adapters
|
||||||
|
PRIVATE -DLIBAD9361_VERSION_GREATER_THAN_01=1
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_FLEXIBAND AND TELEORBIT_FOUND)
|
if(ENABLE_FLEXIBAND AND TELEORBIT_FOUND)
|
||||||
target_link_libraries(signal_source_adapters
|
target_link_libraries(signal_source_adapters
|
||||||
PRIVATE
|
PRIVATE
|
||||||
@ -210,7 +220,6 @@ if(ENABLE_ARRAY AND GRDBFCTTC_FOUND)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
|
if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
|
||||||
if(GR_IIO_INCLUDE_HAS_GNURADIO)
|
if(GR_IIO_INCLUDE_HAS_GNURADIO)
|
||||||
target_compile_definitions(signal_source_adapters
|
target_compile_definitions(signal_source_adapters
|
||||||
@ -226,6 +235,8 @@ if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
|
|||||||
PUBLIC
|
PUBLIC
|
||||||
Gnuradio::iio
|
Gnuradio::iio
|
||||||
Boost::chrono
|
Boost::chrono
|
||||||
|
PRIVATE
|
||||||
|
Iio::iio
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -37,12 +37,14 @@
|
|||||||
#include "configuration_interface.h"
|
#include "configuration_interface.h"
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <iio.h>
|
#include <iio.h>
|
||||||
#include <exception>
|
#include <algorithm> // for max
|
||||||
#include <fcntl.h> // for open, O_WRONLY
|
#include <cmath> // for abs
|
||||||
#include <fstream> // for std::ifstream
|
#include <exception> // for exceptions
|
||||||
#include <iostream> // for cout, endl
|
#include <fcntl.h> // for open, O_WRONLY
|
||||||
#include <string> // for string manipulation
|
#include <fstream> // for std::ifstream
|
||||||
#include <unistd.h> // for write
|
#include <iostream> // for cout, endl
|
||||||
|
#include <string> // for string manipulation
|
||||||
|
#include <unistd.h> // for write
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -277,34 +279,55 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface *configura
|
|||||||
const std::string &role, unsigned int in_stream, unsigned int out_stream,
|
const std::string &role, unsigned int in_stream, unsigned int out_stream,
|
||||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue))
|
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue))
|
||||||
{
|
{
|
||||||
|
std::string default_gain_mode("slow_attack");
|
||||||
|
double default_tx_attenuation_db = -10.0;
|
||||||
|
double default_manual_gain_rx1 = 64.0;
|
||||||
|
double default_manual_gain_rx2 = 64.0;
|
||||||
|
uint64_t default_bandwidth = 12500000;
|
||||||
|
std::string default_rf_port_select("A_BALANCED");
|
||||||
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
|
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
|
||||||
sample_rate_ = configuration->property(role + ".sampling_frequency", 12500000);
|
sample_rate_ = configuration->property(role + ".sampling_frequency", 12500000);
|
||||||
bandwidth_ = configuration->property(role + ".bandwidth", 12500000);
|
bandwidth_ = configuration->property(role + ".bandwidth", default_bandwidth);
|
||||||
rx1_en_ = configuration->property(role + ".rx1_enable", true);
|
|
||||||
rx2_en_ = configuration->property(role + ".rx2_enable", true);
|
|
||||||
buffer_size_ = configuration->property(role + ".buffer_size", 0xA0000);
|
|
||||||
quadrature_ = configuration->property(role + ".quadrature", true);
|
quadrature_ = configuration->property(role + ".quadrature", true);
|
||||||
rf_dc_ = configuration->property(role + ".rf_dc", true);
|
rf_dc_ = configuration->property(role + ".rf_dc", true);
|
||||||
bb_dc_ = configuration->property(role + ".bb_dc", true);
|
bb_dc_ = configuration->property(role + ".bb_dc", true);
|
||||||
gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", std::string("manual"));
|
gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", default_gain_mode);
|
||||||
gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", std::string("manual"));
|
gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", default_gain_mode);
|
||||||
rf_gain_rx1_ = configuration->property(role + ".gain_rx1", 64.0);
|
rf_gain_rx1_ = configuration->property(role + ".gain_rx1", default_manual_gain_rx1);
|
||||||
rf_gain_rx2_ = configuration->property(role + ".gain_rx2", 64.0);
|
rf_gain_rx2_ = configuration->property(role + ".gain_rx2", default_manual_gain_rx2);
|
||||||
rf_port_select_ = configuration->property(role + ".rf_port_select", std::string("A_BALANCED"));
|
rf_port_select_ = configuration->property(role + ".rf_port_select", default_rf_port_select);
|
||||||
filter_file_ = configuration->property(role + ".filter_file", std::string(""));
|
filter_file_ = configuration->property(role + ".filter_file", std::string(""));
|
||||||
filter_auto_ = configuration->property(role + ".filter_auto", true);
|
filter_filename_ = configuration->property(role + ".filter_filename", filter_file_);
|
||||||
samples_ = configuration->property(role + ".samples", 0);
|
filter_auto_ = configuration->property(role + ".filter_auto", false);
|
||||||
|
if (filter_auto_)
|
||||||
|
{
|
||||||
|
filter_source_ = configuration->property(role + ".filter_source", std::string("Auto"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filter_source_ = configuration->property(role + ".filter_source", std::string("Off"));
|
||||||
|
}
|
||||||
|
Fpass_ = configuration->property(role + ".Fpass", 0.0);
|
||||||
|
Fstop_ = configuration->property(role + ".Fstop", 0.0);
|
||||||
enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false);
|
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);
|
freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000);
|
||||||
|
freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - freq_dds_tx_hz_);
|
||||||
scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", -3.0);
|
scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", -3.0);
|
||||||
|
tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", default_tx_attenuation_db);
|
||||||
|
tx_bandwidth_ = configuration->property(role + ".tx_bandwidth", 500000);
|
||||||
phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0);
|
phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0);
|
||||||
tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", 0.0);
|
|
||||||
|
|
||||||
// turn switch to A/D position
|
// turn switch to A/D position
|
||||||
std::string default_device_name = "/dev/uio1";
|
std::string default_device_name = "/dev/uio1";
|
||||||
std::string device_name = configuration->property(role + ".devicename", default_device_name);
|
std::string device_name = configuration->property(role + ".devicename", default_device_name);
|
||||||
switch_position = configuration->property(role + ".switch_position", 0);
|
switch_position = configuration->property(role + ".switch_position", 0);
|
||||||
|
if (switch_position != 0 && switch_position != 2)
|
||||||
|
{
|
||||||
|
std::cout << "SignalSource.switch_position configuration parameter must be either 0: read from file(s) via DMA, or 2: read from AD9361" << std::endl;
|
||||||
|
std::cout << "SignalSource.switch_position configuration parameter set to its default value switch_position=0 - read from file(s)" << std::endl;
|
||||||
|
switch_position = 0;
|
||||||
|
}
|
||||||
|
|
||||||
switch_fpga = std::make_shared<Fpga_Switch>(device_name);
|
switch_fpga = std::make_shared<Fpga_Switch>(device_name);
|
||||||
switch_fpga->set_switch_position(switch_position);
|
switch_fpga->set_switch_position(switch_position);
|
||||||
|
|
||||||
@ -348,8 +371,9 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface *configura
|
|||||||
std::cout << "Configuration parameter rf_port_select should take one of these values:" << std::endl;
|
std::cout << "Configuration parameter rf_port_select should take one of these values:" << std::endl;
|
||||||
std::cout << " A_BALANCED, B_BALANCED, A_N, B_N, B_P, C_N, C_P, TX_MONITOR1, TX_MONITOR2, TX_MONITOR1_2" << std::endl;
|
std::cout << " A_BALANCED, B_BALANCED, A_N, B_N, B_P, C_N, C_P, TX_MONITOR1, TX_MONITOR2, TX_MONITOR1_2" << std::endl;
|
||||||
std::cout << "Error: provided value rf_port_select=" << rf_port_select_ << " is not among valid values" << std::endl;
|
std::cout << "Error: provided value rf_port_select=" << rf_port_select_ << " is not among valid values" << std::endl;
|
||||||
std::cout << " This parameter has been set to its default value rf_port_select=A_BALANCED" << std::endl;
|
std::cout << " This parameter has been set to its default value rf_port_select=" << default_rf_port_select << std::endl;
|
||||||
rf_port_select_ = std::string("A_BALANCED");
|
rf_port_select_ = default_rf_port_select;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for rf_port_select parameter. Set to rf_port_select=" << default_rf_port_select;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gain_mode_rx1_ != "manual") and (gain_mode_rx1_ != "slow_attack") and (gain_mode_rx1_ != "fast_attack") and (gain_mode_rx1_ != "hybrid"))
|
if ((gain_mode_rx1_ != "manual") and (gain_mode_rx1_ != "slow_attack") and (gain_mode_rx1_ != "fast_attack") and (gain_mode_rx1_ != "hybrid"))
|
||||||
@ -357,8 +381,9 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface *configura
|
|||||||
std::cout << "Configuration parameter gain_mode_rx1 should take one of these values:" << std::endl;
|
std::cout << "Configuration parameter gain_mode_rx1 should take one of these values:" << std::endl;
|
||||||
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
|
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
|
||||||
std::cout << "Error: provided value gain_mode_rx1=" << gain_mode_rx1_ << " is not among valid values" << std::endl;
|
std::cout << "Error: provided value gain_mode_rx1=" << gain_mode_rx1_ << " is not among valid values" << std::endl;
|
||||||
std::cout << " This parameter has been set to its default value gain_mode_rx1=manual" << std::endl;
|
std::cout << " This parameter has been set to its default value gain_mode_rx1=" << default_gain_mode << std::endl;
|
||||||
gain_mode_rx1_ = std::string("manual");
|
gain_mode_rx1_ = default_gain_mode;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for gain_mode_rx1 parameter. Set to gain_mode_rx1=" << default_gain_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gain_mode_rx2_ != "manual") and (gain_mode_rx2_ != "slow_attack") and (gain_mode_rx2_ != "fast_attack") and (gain_mode_rx2_ != "hybrid"))
|
if ((gain_mode_rx2_ != "manual") and (gain_mode_rx2_ != "slow_attack") and (gain_mode_rx2_ != "fast_attack") and (gain_mode_rx2_ != "hybrid"))
|
||||||
@ -366,38 +391,116 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface *configura
|
|||||||
std::cout << "Configuration parameter gain_mode_rx2 should take one of these values:" << std::endl;
|
std::cout << "Configuration parameter gain_mode_rx2 should take one of these values:" << std::endl;
|
||||||
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
|
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
|
||||||
std::cout << "Error: provided value gain_mode_rx2=" << gain_mode_rx2_ << " is not among valid values" << std::endl;
|
std::cout << "Error: provided value gain_mode_rx2=" << gain_mode_rx2_ << " is not among valid values" << std::endl;
|
||||||
std::cout << " This parameter has been set to its default value gain_mode_rx2=manual" << std::endl;
|
std::cout << " This parameter has been set to its default value gain_mode_rx2=" << default_gain_mode << std::endl;
|
||||||
gain_mode_rx2_ = std::string("manual");
|
gain_mode_rx2_ = default_gain_mode;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for gain_mode_rx2 parameter. Set to gain_mode_rx2=" << default_gain_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gain_mode_rx1_ == "manual")
|
||||||
|
{
|
||||||
|
if (rf_gain_rx1_ > 73.0 or rf_gain_rx1_ < -1.0)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter rf_gain_rx1 should take values between -1.0 and 73 dB" << std::endl;
|
||||||
|
std::cout << "Error: provided value rf_gain_rx1=" << rf_gain_rx1_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value rf_gain_rx1=" << default_manual_gain_rx1 << std::endl;
|
||||||
|
rf_gain_rx1_ = default_manual_gain_rx1;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for rf_gain_rx1 parameter. Set to rf_gain_rx1=" << default_manual_gain_rx1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gain_mode_rx2_ == "manual")
|
||||||
|
{
|
||||||
|
if (rf_gain_rx2_ > 73.0 or rf_gain_rx2_ < -1.0)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter rf_gain_rx2 should take values between -1.0 and 73 dB" << std::endl;
|
||||||
|
std::cout << "Error: provided value rf_gain_rx2=" << rf_gain_rx2_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value rf_gain_rx2=" << default_manual_gain_rx2 << std::endl;
|
||||||
|
rf_gain_rx2_ = default_manual_gain_rx2;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for rf_gain_rx2 parameter. Set to rf_gain_rx2=" << default_manual_gain_rx2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((filter_source_ != "Off") and (filter_source_ != "Auto") and (filter_source_ != "File") and (filter_source_ != "Design"))
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter filter_source should take one of these values:" << std::endl;
|
||||||
|
std::cout << " Off: Disable filter" << std::endl;
|
||||||
|
std::cout << " Auto: Use auto-generated filters" << std::endl;
|
||||||
|
std::cout << " File: User-provided filter in filter_filename parameter" << std::endl;
|
||||||
|
std::cout << " Design: Create filter from Fpass, Fstop, sampling_frequency and bandwidth parameters" << std::endl;
|
||||||
|
std::cout << "Error: provided value filter_source=" << filter_source_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value filter_source=Off" << std::endl;
|
||||||
|
filter_source_ = std::string("Off");
|
||||||
|
LOG(WARNING) << "Invalid configuration value for filter_source parameter. Set to filter_source=Off";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bandwidth_ < 200000 or bandwidth_ > 56000000)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter bandwidth should take values between 200000 and 56000000 Hz" << std::endl;
|
||||||
|
std::cout << "Error: provided value bandwidth=" << bandwidth_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value bandwidth=" << default_bandwidth << std::endl;
|
||||||
|
bandwidth_ = default_bandwidth;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for bandwidth parameter. Set to bandwidth=" << default_bandwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "LO frequency : " << freq_ << " Hz" << std::endl;
|
std::cout << "LO frequency : " << freq_ << " Hz" << std::endl;
|
||||||
config_ad9361_rx_local(bandwidth_,
|
try
|
||||||
sample_rate_,
|
{
|
||||||
freq_,
|
config_ad9361_rx_local(bandwidth_,
|
||||||
rf_port_select_,
|
sample_rate_,
|
||||||
gain_mode_rx1_,
|
freq_,
|
||||||
gain_mode_rx2_,
|
rf_port_select_,
|
||||||
rf_gain_rx1_,
|
gain_mode_rx1_,
|
||||||
rf_gain_rx2_,
|
gain_mode_rx2_,
|
||||||
quadrature_,
|
rf_gain_rx1_,
|
||||||
rf_dc_,
|
rf_gain_rx2_,
|
||||||
bb_dc_);
|
quadrature_,
|
||||||
|
rf_dc_,
|
||||||
|
bb_dc_,
|
||||||
|
filter_source_,
|
||||||
|
filter_filename_,
|
||||||
|
Fpass_,
|
||||||
|
Fstop_);
|
||||||
|
}
|
||||||
|
catch (const std::runtime_error &e)
|
||||||
|
{
|
||||||
|
std::cout << "Exception cached when configuring the RX chain: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
// LOCAL OSCILLATOR DDS GENERATOR FOR DUAL FREQUENCY OPERATION
|
// LOCAL OSCILLATOR DDS GENERATOR FOR DUAL FREQUENCY OPERATION
|
||||||
if (enable_dds_lo_ == true)
|
if (enable_dds_lo_ == true)
|
||||||
{
|
{
|
||||||
config_ad9361_lo_local(bandwidth_,
|
if (tx_bandwidth_ < static_cast<uint64_t>(std::floor(static_cast<float>(freq_dds_tx_hz_) * 1.1)) or (tx_bandwidth_ < 200000) or (tx_bandwidth_ > 1000000))
|
||||||
sample_rate_,
|
{
|
||||||
freq_rf_tx_hz_,
|
std::cout << "Configuration parameter tx_bandwidth value should be between " << std::max(static_cast<float>(freq_dds_tx_hz_) * 1.1, 200000.0) << " and 1000000 Hz" << std::endl;
|
||||||
tx_attenuation_db_,
|
std::cout << "Error: provided value tx_bandwidth=" << tx_bandwidth_ << " is not among valid values" << std::endl;
|
||||||
freq_dds_tx_hz_,
|
std::cout << " This parameter has been set to its default value tx_bandwidth=500000" << std::endl;
|
||||||
scale_dds_dbfs_);
|
tx_bandwidth_ = 500000;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for tx_bandwidth parameter. Set to tx_bandwidth=500000";
|
||||||
|
}
|
||||||
|
if (tx_attenuation_db_ > 0.0 or tx_attenuation_db_ < -89.75)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter tx_attenuation_db should take values between 0.0 and -89.95 in 0.25 dB steps" << std::endl;
|
||||||
|
std::cout << "Error: provided value tx_attenuation_db=" << tx_attenuation_db_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value tx_attenuation_db=" << default_tx_attenuation_db << std::endl;
|
||||||
|
tx_attenuation_db_ = default_tx_attenuation_db;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for tx_attenuation_db parameter. Set to tx_attenuation_db=" << default_tx_attenuation_db;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
config_ad9361_lo_local(tx_bandwidth_,
|
||||||
|
sample_rate_,
|
||||||
|
freq_rf_tx_hz_,
|
||||||
|
tx_attenuation_db_,
|
||||||
|
freq_dds_tx_hz_,
|
||||||
|
scale_dds_dbfs_,
|
||||||
|
phase_dds_deg_);
|
||||||
|
}
|
||||||
|
catch (const std::runtime_error &e)
|
||||||
|
{
|
||||||
|
std::cout << "Exception cached when configuring the TX carrier: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (switch_position != 0 && switch_position != 2)
|
|
||||||
{
|
|
||||||
std::cout << "SignalSource.switch_position configuration parameter must be either 0: read from file(s) via DMA, or 2: read from AD9361" << std::endl;
|
|
||||||
}
|
|
||||||
if (in_stream_ > 0)
|
if (in_stream_ > 0)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "A signal source does not have an input stream";
|
LOG(ERROR) << "A signal source does not have an input stream";
|
||||||
|
@ -83,9 +83,6 @@ private:
|
|||||||
uint64_t freq_; // frequency of local oscillator
|
uint64_t freq_; // frequency of local oscillator
|
||||||
uint64_t sample_rate_;
|
uint64_t sample_rate_;
|
||||||
uint64_t bandwidth_;
|
uint64_t bandwidth_;
|
||||||
uint64_t buffer_size_; // reception buffer
|
|
||||||
bool rx1_en_;
|
|
||||||
bool rx2_en_;
|
|
||||||
bool quadrature_;
|
bool quadrature_;
|
||||||
bool rf_dc_;
|
bool rf_dc_;
|
||||||
bool bb_dc_;
|
bool bb_dc_;
|
||||||
@ -96,11 +93,16 @@ private:
|
|||||||
std::string rf_port_select_;
|
std::string rf_port_select_;
|
||||||
std::string filter_file_;
|
std::string filter_file_;
|
||||||
bool filter_auto_;
|
bool filter_auto_;
|
||||||
|
std::string filter_source_;
|
||||||
|
std::string filter_filename_;
|
||||||
|
float Fpass_;
|
||||||
|
float Fstop_;
|
||||||
|
|
||||||
// DDS configuration for LO generation for external mixer
|
// DDS configuration for LO generation for external mixer
|
||||||
bool enable_dds_lo_;
|
bool enable_dds_lo_;
|
||||||
uint64_t freq_rf_tx_hz_;
|
uint64_t freq_rf_tx_hz_;
|
||||||
uint64_t freq_dds_tx_hz_;
|
uint64_t freq_dds_tx_hz_;
|
||||||
|
uint64_t tx_bandwidth_;
|
||||||
double scale_dds_dbfs_;
|
double scale_dds_dbfs_;
|
||||||
double phase_dds_deg_;
|
double phase_dds_deg_;
|
||||||
double tx_attenuation_db_;
|
double tx_attenuation_db_;
|
||||||
@ -109,7 +111,6 @@ private:
|
|||||||
uint32_t out_stream_;
|
uint32_t out_stream_;
|
||||||
|
|
||||||
size_t item_size_;
|
size_t item_size_;
|
||||||
long samples_;
|
|
||||||
|
|
||||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue_;
|
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue_;
|
||||||
|
|
||||||
|
@ -36,17 +36,20 @@
|
|||||||
#include "configuration_interface.h"
|
#include "configuration_interface.h"
|
||||||
#include "gnss_sdr_valve.h"
|
#include "gnss_sdr_valve.h"
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
#include <algorithm> // for max
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
||||||
Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration,
|
Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface *configuration,
|
||||||
const std::string& role, unsigned int in_stream, unsigned int out_stream,
|
const std::string &role, unsigned int in_stream, unsigned int out_stream,
|
||||||
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue))
|
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(std::move(queue))
|
||||||
{
|
{
|
||||||
std::string default_item_type = "gr_complex";
|
std::string default_item_type = "gr_complex";
|
||||||
std::string default_dump_file = "./data/signal_source.dat";
|
std::string default_dump_file = "./data/signal_source.dat";
|
||||||
|
std::string default_gain_mode("slow_attack");
|
||||||
|
double default_tx_attenuation_db = -10.0;
|
||||||
uri_ = configuration->property(role + ".device_address", std::string("192.168.2.1"));
|
uri_ = configuration->property(role + ".device_address", std::string("192.168.2.1"));
|
||||||
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
|
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
|
||||||
sample_rate_ = configuration->property(role + ".sampling_frequency", 2600000);
|
sample_rate_ = configuration->property(role + ".sampling_frequency", 2600000);
|
||||||
@ -58,17 +61,25 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
|
|||||||
rf_dc_ = configuration->property(role + ".rf_dc", true);
|
rf_dc_ = configuration->property(role + ".rf_dc", true);
|
||||||
bb_dc_ = configuration->property(role + ".bb_dc", true);
|
bb_dc_ = configuration->property(role + ".bb_dc", true);
|
||||||
RF_channels_ = configuration->property(role + ".RF_channels", 1);
|
RF_channels_ = configuration->property(role + ".RF_channels", 1);
|
||||||
gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", std::string("manual"));
|
gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", default_gain_mode);
|
||||||
gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", std::string("manual"));
|
gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", default_gain_mode);
|
||||||
rf_gain_rx1_ = configuration->property(role + ".gain_rx1", 64.0);
|
rf_gain_rx1_ = configuration->property(role + ".gain_rx1", 64.0);
|
||||||
rf_gain_rx2_ = configuration->property(role + ".gain_rx2", 64.0);
|
rf_gain_rx2_ = configuration->property(role + ".gain_rx2", 64.0);
|
||||||
rf_port_select_ = configuration->property(role + ".rf_port_select", std::string("A_BALANCED"));
|
rf_port_select_ = configuration->property(role + ".rf_port_select", std::string("A_BALANCED"));
|
||||||
filter_file_ = configuration->property(role + ".filter_file", std::string(""));
|
filter_file_ = configuration->property(role + ".filter_file", std::string(""));
|
||||||
filter_source_ = configuration->property(role + ".filter_source", std::string("Off"));
|
filter_auto_ = configuration->property(role + ".filter_auto", false);
|
||||||
filter_filename_ = configuration->property(role + ".filter_filename", std::string(""));
|
if (filter_auto_)
|
||||||
|
{
|
||||||
|
filter_source_ = configuration->property(role + ".filter_source", std::string("Auto"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filter_source_ = configuration->property(role + ".filter_source", std::string("Off"));
|
||||||
|
}
|
||||||
|
filter_filename_ = configuration->property(role + ".filter_filename", filter_file_);
|
||||||
Fpass_ = configuration->property(role + ".Fpass", 0.0);
|
Fpass_ = configuration->property(role + ".Fpass", 0.0);
|
||||||
Fstop_ = configuration->property(role + ".Fstop", 0.0);
|
Fstop_ = configuration->property(role + ".Fstop", 0.0);
|
||||||
filter_auto_ = configuration->property(role + ".filter_auto", true);
|
|
||||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||||
samples_ = configuration->property(role + ".samples", 0);
|
samples_ = configuration->property(role + ".samples", 0);
|
||||||
dump_ = configuration->property(role + ".dump", false);
|
dump_ = configuration->property(role + ".dump", false);
|
||||||
@ -76,11 +87,12 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
|
|||||||
|
|
||||||
// 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);
|
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);
|
freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000);
|
||||||
|
freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - freq_dds_tx_hz_);
|
||||||
scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", 0.0);
|
scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", 0.0);
|
||||||
phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0);
|
phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0);
|
||||||
tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", 0.0);
|
tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", default_tx_attenuation_db);
|
||||||
|
tx_bandwidth_ = configuration->property(role + ".tx_bandwidth", 500000);
|
||||||
|
|
||||||
item_size_ = sizeof(gr_complex);
|
item_size_ = sizeof(gr_complex);
|
||||||
|
|
||||||
@ -92,6 +104,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
|
|||||||
std::cout << "Error: provided value rf_port_select=" << rf_port_select_ << " is not among valid values" << std::endl;
|
std::cout << "Error: provided value rf_port_select=" << rf_port_select_ << " is not among valid values" << std::endl;
|
||||||
std::cout << " This parameter has been set to its default value rf_port_select=A_BALANCED" << std::endl;
|
std::cout << " This parameter has been set to its default value rf_port_select=A_BALANCED" << std::endl;
|
||||||
rf_port_select_ = std::string("A_BALANCED");
|
rf_port_select_ = std::string("A_BALANCED");
|
||||||
|
LOG(WARNING) << "Invalid configuration value for rf_port_select parameter. Set to rf_port_select=A_BALANCED";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gain_mode_rx1_ != "manual") and (gain_mode_rx1_ != "slow_attack") and (gain_mode_rx1_ != "fast_attack") and (gain_mode_rx1_ != "hybrid"))
|
if ((gain_mode_rx1_ != "manual") and (gain_mode_rx1_ != "slow_attack") and (gain_mode_rx1_ != "fast_attack") and (gain_mode_rx1_ != "hybrid"))
|
||||||
@ -99,8 +112,9 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
|
|||||||
std::cout << "Configuration parameter gain_mode_rx1 should take one of these values:" << std::endl;
|
std::cout << "Configuration parameter gain_mode_rx1 should take one of these values:" << std::endl;
|
||||||
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
|
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
|
||||||
std::cout << "Error: provided value gain_mode_rx1=" << gain_mode_rx1_ << " is not among valid values" << std::endl;
|
std::cout << "Error: provided value gain_mode_rx1=" << gain_mode_rx1_ << " is not among valid values" << std::endl;
|
||||||
std::cout << " This parameter has been set to its default value gain_mode_rx1=manual" << std::endl;
|
std::cout << " This parameter has been set to its default value gain_mode_rx1=" << default_gain_mode << std::endl;
|
||||||
gain_mode_rx1_ = std::string("manual");
|
gain_mode_rx1_ = default_gain_mode;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for gain_mode_rx1 parameter. Set to gain_mode_rx1=" << default_gain_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gain_mode_rx2_ != "manual") and (gain_mode_rx2_ != "slow_attack") and (gain_mode_rx2_ != "fast_attack") and (gain_mode_rx2_ != "hybrid"))
|
if ((gain_mode_rx2_ != "manual") and (gain_mode_rx2_ != "slow_attack") and (gain_mode_rx2_ != "fast_attack") and (gain_mode_rx2_ != "hybrid"))
|
||||||
@ -108,8 +122,9 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
|
|||||||
std::cout << "Configuration parameter gain_mode_rx2 should take one of these values:" << std::endl;
|
std::cout << "Configuration parameter gain_mode_rx2 should take one of these values:" << std::endl;
|
||||||
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
|
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
|
||||||
std::cout << "Error: provided value gain_mode_rx2=" << gain_mode_rx2_ << " is not among valid values" << std::endl;
|
std::cout << "Error: provided value gain_mode_rx2=" << gain_mode_rx2_ << " is not among valid values" << std::endl;
|
||||||
std::cout << " This parameter has been set to its default value gain_mode_rx2=manual" << std::endl;
|
std::cout << " This parameter has been set to its default value gain_mode_rx2=" << default_gain_mode << std::endl;
|
||||||
gain_mode_rx2_ = std::string("manual");
|
gain_mode_rx2_ = default_gain_mode;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for gain_mode_rx1 parameter. Set to gain_mode_rx2=" << default_gain_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((filter_source_ != "Off") and (filter_source_ != "Auto") and (filter_source_ != "File") and (filter_source_ != "Design"))
|
if ((filter_source_ != "Off") and (filter_source_ != "Auto") and (filter_source_ != "File") and (filter_source_ != "Design"))
|
||||||
@ -118,10 +133,46 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
|
|||||||
std::cout << " Off: Disable filter" << std::endl;
|
std::cout << " Off: Disable filter" << std::endl;
|
||||||
std::cout << " Auto: Use auto-generated filters" << std::endl;
|
std::cout << " Auto: Use auto-generated filters" << std::endl;
|
||||||
std::cout << " File: User-provided filter in filter_filename parameter" << std::endl;
|
std::cout << " File: User-provided filter in filter_filename parameter" << std::endl;
|
||||||
|
#if LIBAD9361_VERSION_GREATER_THAN_01
|
||||||
std::cout << " Design: Create filter from Fpass, Fstop, sampling_frequency and bandwidth parameters" << std::endl;
|
std::cout << " Design: Create filter from Fpass, Fstop, sampling_frequency and bandwidth parameters" << std::endl;
|
||||||
|
#endif
|
||||||
std::cout << "Error: provided value filter_source=" << filter_source_ << " is not among valid values" << std::endl;
|
std::cout << "Error: provided value filter_source=" << filter_source_ << " is not among valid values" << std::endl;
|
||||||
std::cout << " This parameter has been set to its default value filter_source=Off" << std::endl;
|
std::cout << " This parameter has been set to its default value filter_source=Off" << std::endl;
|
||||||
filter_source_ = std::string("Off");
|
filter_source_ = std::string("Off");
|
||||||
|
LOG(WARNING) << "Invalid configuration value for filter_source parameter. Set to filter_source=Off";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gain_mode_rx1_ == "manual")
|
||||||
|
{
|
||||||
|
if (rf_gain_rx1_ > 73.0 or rf_gain_rx1_ < -1.0)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter rf_gain_rx1 should take values between -1.0 and 73 dB" << std::endl;
|
||||||
|
std::cout << "Error: provided value rf_gain_rx1=" << rf_gain_rx1_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value rf_gain_rx1=64.0" << std::endl;
|
||||||
|
rf_gain_rx1_ = 64.0;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for rf_gain_rx1 parameter. Set to rf_gain_rx1=64.0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gain_mode_rx2_ == "manual")
|
||||||
|
{
|
||||||
|
if (rf_gain_rx2_ > 73.0 or rf_gain_rx2_ < -1.0)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter rf_gain_rx2 should take values between -1.0 and 73 dB" << std::endl;
|
||||||
|
std::cout << "Error: provided value rf_gain_rx2=" << rf_gain_rx2_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value rf_gain_rx2=64.0" << std::endl;
|
||||||
|
rf_gain_rx2_ = 64.0;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for rf_gain_rx2 parameter. Set to rf_gain_rx2=64.0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bandwidth_ < 200000 or bandwidth_ > 56000000)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter bandwidth should take values between 200000 and 56000000 Hz" << std::endl;
|
||||||
|
std::cout << "Error: provided value bandwidth=" << bandwidth_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value bandwidth=2000000" << std::endl;
|
||||||
|
bandwidth_ = 2000000;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for bandwidth parameter. Set to bandwidth=2000000";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "device address: " << uri_ << std::endl;
|
std::cout << "device address: " << uri_ << std::endl;
|
||||||
@ -162,14 +213,38 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
|
|||||||
// configure LO
|
// configure LO
|
||||||
if (enable_dds_lo_ == true)
|
if (enable_dds_lo_ == true)
|
||||||
{
|
{
|
||||||
|
if (tx_bandwidth_ < static_cast<uint64_t>(std::floor(static_cast<float>(freq_dds_tx_hz_) * 1.1)) or (tx_bandwidth_ < 200000) or (tx_bandwidth_ > 1000000))
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter tx_bandwidth value should be between " << std::max(static_cast<float>(freq_dds_tx_hz_) * 1.1, 200000.0) << " and 1000000 Hz" << std::endl;
|
||||||
|
std::cout << "Error: provided value tx_bandwidth=" << tx_bandwidth_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value tx_bandwidth=500000" << std::endl;
|
||||||
|
tx_bandwidth_ = 500000;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for tx_bandwidth parameter. Set to tx_bandwidth=500000";
|
||||||
|
}
|
||||||
|
if (tx_attenuation_db_ > 0.0 or tx_attenuation_db_ < -89.75)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter tx_attenuation_db should take values between 0.0 and -89.95 in 0.25 dB steps" << std::endl;
|
||||||
|
std::cout << "Error: provided value tx_attenuation_db=" << tx_attenuation_db_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value tx_attenuation_db=" << default_tx_attenuation_db << std::endl;
|
||||||
|
tx_attenuation_db_ = default_tx_attenuation_db;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for tx_attenuation_db parameter. Set to tx_attenuation_db=" << default_tx_attenuation_db;
|
||||||
|
}
|
||||||
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
|
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
|
||||||
config_ad9361_lo_remote(uri_,
|
try
|
||||||
bandwidth_,
|
{
|
||||||
sample_rate_,
|
config_ad9361_lo_remote(uri_,
|
||||||
freq_rf_tx_hz_,
|
tx_bandwidth_,
|
||||||
tx_attenuation_db_,
|
sample_rate_,
|
||||||
freq_dds_tx_hz_,
|
freq_rf_tx_hz_,
|
||||||
scale_dds_dbfs_);
|
tx_attenuation_db_,
|
||||||
|
freq_dds_tx_hz_,
|
||||||
|
scale_dds_dbfs_,
|
||||||
|
phase_dds_deg_);
|
||||||
|
}
|
||||||
|
catch (const std::runtime_error &e)
|
||||||
|
{
|
||||||
|
std::cout << "Exception cached when configuring the TX carrier: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,14 +280,38 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
|
|||||||
// configure LO
|
// configure LO
|
||||||
if (enable_dds_lo_ == true)
|
if (enable_dds_lo_ == true)
|
||||||
{
|
{
|
||||||
|
if (tx_bandwidth_ < static_cast<uint64_t>(std::floor(static_cast<float>(freq_dds_tx_hz_) * 1.1)) or (tx_bandwidth_ < 200000) or (tx_bandwidth_ > 1000000))
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter tx_bandwidth value should be between " << std::max(static_cast<float>(freq_dds_tx_hz_) * 1.1, 200000.0) << " and 1000000 Hz" << std::endl;
|
||||||
|
std::cout << "Error: provided value tx_bandwidth=" << tx_bandwidth_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value tx_bandwidth=500000" << std::endl;
|
||||||
|
tx_bandwidth_ = 500000;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for tx_bandwidth parameter. Set to tx_bandwidth=500000";
|
||||||
|
}
|
||||||
|
if (tx_attenuation_db_ > 0.0 or tx_attenuation_db_ < -89.75)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter tx_attenuation_db should take values between 0.0 and -89.95 in 0.25 dB steps" << std::endl;
|
||||||
|
std::cout << "Error: provided value tx_attenuation_db=" << tx_attenuation_db_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value tx_attenuation_db=" << default_tx_attenuation_db << std::endl;
|
||||||
|
tx_attenuation_db_ = default_tx_attenuation_db;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for tx_attenuation_db parameter. Set to tx_attenuation_db=" << default_tx_attenuation_db;
|
||||||
|
}
|
||||||
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
|
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
|
||||||
config_ad9361_lo_remote(uri_,
|
try
|
||||||
bandwidth_,
|
{
|
||||||
sample_rate_,
|
config_ad9361_lo_remote(uri_,
|
||||||
freq_rf_tx_hz_,
|
tx_bandwidth_,
|
||||||
tx_attenuation_db_,
|
sample_rate_,
|
||||||
freq_dds_tx_hz_,
|
freq_rf_tx_hz_,
|
||||||
scale_dds_dbfs_);
|
tx_attenuation_db_,
|
||||||
|
freq_dds_tx_hz_,
|
||||||
|
scale_dds_dbfs_,
|
||||||
|
phase_dds_deg_);
|
||||||
|
}
|
||||||
|
catch (const std::runtime_error &e)
|
||||||
|
{
|
||||||
|
std::cout << "Exception cached when configuring the TX carrier: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,7 +349,7 @@ Fmcomms2SignalSource::~Fmcomms2SignalSource()
|
|||||||
{
|
{
|
||||||
ad9361_disable_lo_remote(uri_);
|
ad9361_disable_lo_remote(uri_);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
LOG(WARNING) << "Exception thrown in Fmcomms2SignalSource destructor: " << e.what();
|
LOG(WARNING) << "Exception thrown in Fmcomms2SignalSource destructor: " << e.what();
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "concurrent_queue.h"
|
#include "concurrent_queue.h"
|
||||||
#include <pmt/pmt.h>
|
#include <pmt/pmt.h>
|
||||||
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -84,11 +85,11 @@ private:
|
|||||||
std::string role_;
|
std::string role_;
|
||||||
|
|
||||||
// Front-end settings
|
// Front-end settings
|
||||||
std::string uri_; // device direction
|
std::string uri_; // device direction
|
||||||
unsigned long freq_; // frequency of local oscilator
|
uint64_t freq_; // frequency of local oscilator
|
||||||
unsigned long sample_rate_;
|
uint64_t sample_rate_;
|
||||||
unsigned long bandwidth_;
|
uint64_t bandwidth_;
|
||||||
unsigned long buffer_size_; // reception buffer
|
uint64_t buffer_size_; // reception buffer
|
||||||
bool rx1_en_;
|
bool rx1_en_;
|
||||||
bool rx2_en_;
|
bool rx2_en_;
|
||||||
bool quadrature_;
|
bool quadrature_;
|
||||||
@ -109,18 +110,19 @@ private:
|
|||||||
|
|
||||||
// DDS configuration for LO generation for external mixer
|
// DDS configuration for LO generation for external mixer
|
||||||
bool enable_dds_lo_;
|
bool enable_dds_lo_;
|
||||||
unsigned long freq_rf_tx_hz_;
|
uint64_t freq_rf_tx_hz_;
|
||||||
unsigned long freq_dds_tx_hz_;
|
uint64_t freq_dds_tx_hz_;
|
||||||
double scale_dds_dbfs_;
|
double scale_dds_dbfs_;
|
||||||
double phase_dds_deg_;
|
double phase_dds_deg_;
|
||||||
double tx_attenuation_db_;
|
double tx_attenuation_db_;
|
||||||
|
uint64_t tx_bandwidth_;
|
||||||
|
|
||||||
unsigned int in_stream_;
|
unsigned int in_stream_;
|
||||||
unsigned int out_stream_;
|
unsigned int out_stream_;
|
||||||
|
|
||||||
std::string item_type_;
|
std::string item_type_;
|
||||||
size_t item_size_;
|
size_t item_size_;
|
||||||
long samples_;
|
int64_t samples_;
|
||||||
bool dump_;
|
bool dump_;
|
||||||
std::string dump_filename_;
|
std::string dump_filename_;
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
|
|||||||
{
|
{
|
||||||
std::string default_item_type = "gr_complex";
|
std::string default_item_type = "gr_complex";
|
||||||
std::string default_dump_file = "./data/signal_source.dat";
|
std::string default_dump_file = "./data/signal_source.dat";
|
||||||
|
std::string default_gain_mode("slow_attack");
|
||||||
uri_ = configuration->property(role + ".device_address", std::string("192.168.2.1"));
|
uri_ = configuration->property(role + ".device_address", std::string("192.168.2.1"));
|
||||||
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
|
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
|
||||||
sample_rate_ = configuration->property(role + ".sampling_frequency", 3000000);
|
sample_rate_ = configuration->property(role + ".sampling_frequency", 3000000);
|
||||||
@ -51,12 +52,19 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
|
|||||||
quadrature_ = configuration->property(role + ".quadrature", true);
|
quadrature_ = configuration->property(role + ".quadrature", true);
|
||||||
rf_dc_ = configuration->property(role + ".rf_dc", true);
|
rf_dc_ = configuration->property(role + ".rf_dc", true);
|
||||||
bb_dc_ = configuration->property(role + ".bb_dc", true);
|
bb_dc_ = configuration->property(role + ".bb_dc", true);
|
||||||
gain_mode_ = configuration->property(role + ".gain_mode", std::string("manual"));
|
gain_mode_ = configuration->property(role + ".gain_mode", default_gain_mode);
|
||||||
rf_gain_ = configuration->property(role + ".gain", 50.0);
|
rf_gain_ = configuration->property(role + ".gain", 50.0);
|
||||||
filter_file_ = configuration->property(role + ".filter_file", std::string(""));
|
filter_file_ = configuration->property(role + ".filter_file", std::string(""));
|
||||||
filter_auto_ = configuration->property(role + ".filter_auto", true);
|
filter_auto_ = configuration->property(role + ".filter_auto", false);
|
||||||
filter_source_ = configuration->property(role + ".filter_source", std::string("Off"));
|
if (filter_auto_)
|
||||||
filter_filename_ = configuration->property(role + ".filter_filename", std::string(""));
|
{
|
||||||
|
filter_source_ = configuration->property(role + ".filter_source", std::string("Auto"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filter_source_ = configuration->property(role + ".filter_source", std::string("Off"));
|
||||||
|
}
|
||||||
|
filter_filename_ = configuration->property(role + ".filter_filename", filter_file_);
|
||||||
Fpass_ = configuration->property(role + ".Fpass", 0.0);
|
Fpass_ = configuration->property(role + ".Fpass", 0.0);
|
||||||
Fstop_ = configuration->property(role + ".Fstop", 0.0);
|
Fstop_ = configuration->property(role + ".Fstop", 0.0);
|
||||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||||
@ -73,11 +81,48 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration
|
|||||||
// basic check
|
// basic check
|
||||||
if ((gain_mode_ != "manual") and (gain_mode_ != "slow_attack") and (gain_mode_ != "fast_attack") and (gain_mode_ != "hybrid"))
|
if ((gain_mode_ != "manual") and (gain_mode_ != "slow_attack") and (gain_mode_ != "fast_attack") and (gain_mode_ != "hybrid"))
|
||||||
{
|
{
|
||||||
std::cout << "Configuration parameter gain_mode_rx1 should take one of these values:" << std::endl;
|
std::cout << "Configuration parameter gain_mode should take one of these values:" << std::endl;
|
||||||
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
|
std::cout << " manual, slow_attack, fast_attack, hybrid" << std::endl;
|
||||||
std::cout << "Error: provided value gain_mode=" << gain_mode_ << " is not among valid values" << std::endl;
|
std::cout << "Error: provided value gain_mode=" << gain_mode_ << " is not among valid values" << std::endl;
|
||||||
std::cout << " This parameter has been set to its default value gain_mode=manual" << std::endl;
|
std::cout << " This parameter has been set to its default value gain_mode=" << default_gain_mode << std::endl;
|
||||||
gain_mode_ = std::string("manual");
|
gain_mode_ = default_gain_mode;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for gain_mode parameter. Set to gain_mode=" << default_gain_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gain_mode_ == "manual")
|
||||||
|
{
|
||||||
|
if (rf_gain_ > 73.0 or rf_gain_ < -1.0)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter rf_gain should take values between -1.0 and 73 dB" << std::endl;
|
||||||
|
std::cout << "Error: provided value rf_gain=" << rf_gain_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value rf_gain=64.0" << std::endl;
|
||||||
|
rf_gain_ = 64.0;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for rf_gain parameter. Set to rf_gain=64.0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((filter_source_ != "Off") and (filter_source_ != "Auto") and (filter_source_ != "File") and (filter_source_ != "Design"))
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter filter_source should take one of these values:" << std::endl;
|
||||||
|
std::cout << " Off: Disable filter" << std::endl;
|
||||||
|
std::cout << " Auto: Use auto-generated filters" << std::endl;
|
||||||
|
std::cout << " File: User-provided filter in filter_filename parameter" << std::endl;
|
||||||
|
#if LIBAD9361_VERSION_GREATER_THAN_01
|
||||||
|
std::cout << " Design: Create filter from Fpass, Fstop, sampling_frequency and bandwidth parameters" << std::endl;
|
||||||
|
#endif
|
||||||
|
std::cout << "Error: provided value filter_source=" << filter_source_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value filter_source=Off" << std::endl;
|
||||||
|
filter_source_ = std::string("Off");
|
||||||
|
LOG(WARNING) << "Invalid configuration value for filter_source parameter. Set to filter_source=Off";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bandwidth_ < 200000 or bandwidth_ > 56000000)
|
||||||
|
{
|
||||||
|
std::cout << "Configuration parameter bandwidth should take values between 200000 and 56000000 Hz" << std::endl;
|
||||||
|
std::cout << "Error: provided value bandwidth=" << bandwidth_ << " is not among valid values" << std::endl;
|
||||||
|
std::cout << " This parameter has been set to its default value bandwidth=2000000" << std::endl;
|
||||||
|
bandwidth_ = 2000000;
|
||||||
|
LOG(WARNING) << "Invalid configuration value for bandwidth parameter. Set to bandwidth=2000000";
|
||||||
}
|
}
|
||||||
|
|
||||||
item_size_ = sizeof(gr_complex);
|
item_size_ = sizeof(gr_complex);
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "concurrent_queue.h"
|
#include "concurrent_queue.h"
|
||||||
#include <pmt/pmt.h>
|
#include <pmt/pmt.h>
|
||||||
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -85,11 +86,11 @@ private:
|
|||||||
std::string role_;
|
std::string role_;
|
||||||
|
|
||||||
// Front-end settings
|
// Front-end settings
|
||||||
std::string uri_; // device direction
|
std::string uri_; // device direction
|
||||||
unsigned long freq_; // frequency of local oscilator
|
uint64_t freq_; // frequency of local oscilator
|
||||||
unsigned long sample_rate_;
|
uint64_t sample_rate_;
|
||||||
unsigned long bandwidth_;
|
uint64_t bandwidth_;
|
||||||
unsigned long buffer_size_; // reception buffer
|
uint64_t buffer_size_; // reception buffer
|
||||||
bool quadrature_;
|
bool quadrature_;
|
||||||
bool rf_dc_;
|
bool rf_dc_;
|
||||||
bool bb_dc_;
|
bool bb_dc_;
|
||||||
@ -107,7 +108,7 @@ private:
|
|||||||
|
|
||||||
std::string item_type_;
|
std::string item_type_;
|
||||||
size_t item_size_;
|
size_t item_size_;
|
||||||
long samples_;
|
int64_t samples_;
|
||||||
bool dump_;
|
bool dump_;
|
||||||
std::string dump_filename_;
|
std::string dump_filename_;
|
||||||
|
|
||||||
|
@ -67,7 +67,16 @@ if(ENABLE_FMCOMMS2 OR ENABLE_AD9361)
|
|||||||
target_link_libraries(signal_source_libs
|
target_link_libraries(signal_source_libs
|
||||||
PUBLIC
|
PUBLIC
|
||||||
Iio::iio
|
Iio::iio
|
||||||
)
|
PRIVATE
|
||||||
|
Iio::ad9361
|
||||||
|
)
|
||||||
|
if(LIBAD9361_VERSION)
|
||||||
|
if(LIBAD9361_VERSION VERSION_GREATER 0.1)
|
||||||
|
target_compile_definitions(signal_source_libs
|
||||||
|
PRIVATE -DLIBAD9361_VERSION_GREATER_THAN_01=1
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_CLANG_TIDY)
|
if(ENABLE_CLANG_TIDY)
|
||||||
|
@ -31,10 +31,12 @@
|
|||||||
*/
|
*/
|
||||||
#include "ad9361_manager.h"
|
#include "ad9361_manager.h"
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
|
#include <ad9361.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <fstream> // for ifstream
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/* check return value of attr_write function */
|
/* check return value of attr_write function */
|
||||||
void errchk(int v, const char *what)
|
void errchk(int v, const char *what)
|
||||||
@ -186,23 +188,34 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
|
|||||||
double rf_gain_rx2_,
|
double rf_gain_rx2_,
|
||||||
bool quadrature_,
|
bool quadrature_,
|
||||||
bool rfdc_,
|
bool rfdc_,
|
||||||
bool bbdc_)
|
bool bbdc_,
|
||||||
|
std::string filter_source_,
|
||||||
|
std::string filter_filename_,
|
||||||
|
float Fpass_,
|
||||||
|
float Fstop_)
|
||||||
|
|
||||||
{
|
{
|
||||||
// RX stream config
|
// RX stream config
|
||||||
// Stream configurations
|
|
||||||
struct stream_cfg rxcfg;
|
|
||||||
rxcfg.bw_hz = bandwidth_; // 2 MHz rf bandwidth
|
|
||||||
rxcfg.fs_hz = sample_rate_; // 2.5 MS/s rx sample rate
|
|
||||||
rxcfg.lo_hz = freq_; // 2.5 GHz rf frequency
|
|
||||||
rxcfg.rfport = rf_port_select_.c_str(); // port A (select for rf freq.)
|
|
||||||
|
|
||||||
std::cout << "AD9361 Acquiring IIO LOCAL context\n";
|
std::cout << "AD9361 Acquiring IIO LOCAL context\n";
|
||||||
struct iio_context *ctx;
|
struct iio_context *ctx;
|
||||||
// Streaming devices
|
// Streaming devices
|
||||||
struct iio_device *rx;
|
struct iio_device *rx;
|
||||||
struct iio_channel *rx0_i;
|
struct iio_channel *rx_chan1;
|
||||||
struct iio_channel *rx0_q;
|
struct iio_channel *rx_chan2;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
#ifndef LIBAD9361_VERSION_GREATER_THAN_01
|
||||||
|
if (filter_source_ == "Design")
|
||||||
|
{
|
||||||
|
std::cout << "Option filter_source=Design is not available in this version. Set to filter_source=Off" << std::endl;
|
||||||
|
filter_source_ = std::string("Off");
|
||||||
|
}
|
||||||
|
if (Fpass_ != 0.0 or Fstop_ != 0.0)
|
||||||
|
{
|
||||||
|
Fpass_ = 0.0;
|
||||||
|
Fstop_ = 0.0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ctx = iio_create_default_context();
|
ctx = iio_create_default_context();
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
@ -217,41 +230,131 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
|
|||||||
throw std::runtime_error("AD9361 IIO No devices");
|
throw std::runtime_error("AD9361 IIO No devices");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "* Acquiring AD9361 streaming devices\n";
|
struct iio_device *ad9361_phy;
|
||||||
|
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
|
||||||
|
|
||||||
|
std::cout << "* Acquiring AD9361 streaming devices\n";
|
||||||
if (!get_ad9361_stream_dev(ctx, RX, &rx))
|
if (!get_ad9361_stream_dev(ctx, RX, &rx))
|
||||||
{
|
{
|
||||||
std::cout << "No rx dev found\n";
|
std::cout << "No rx dev found\n";
|
||||||
throw std::runtime_error("AD9361 IIO No rx dev found");
|
throw std::runtime_error("AD9361 IIO No rx dev found");
|
||||||
};
|
};
|
||||||
|
|
||||||
std::cout << "* Configuring AD9361 for streaming\n";
|
|
||||||
if (!cfg_ad9361_streaming_ch(ctx, &rxcfg, RX, 0))
|
|
||||||
{
|
|
||||||
std::cout << "RX port 0 not found\n";
|
|
||||||
throw std::runtime_error("AD9361 IIO RX port 0 not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "* Initializing AD9361 IIO streaming channels\n";
|
std::cout << "* Initializing AD9361 IIO streaming channels\n";
|
||||||
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx0_i))
|
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan1))
|
||||||
{
|
{
|
||||||
std::cout << "RX chan i not found\n";
|
std::cout << "RX channel 1 not found\n";
|
||||||
throw std::runtime_error("RX chan i not found");
|
throw std::runtime_error("RX channel 1 not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx0_q))
|
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx_chan2))
|
||||||
{
|
{
|
||||||
std::cout << "RX chan q not found\n";
|
std::cout << "RX channel 2 not found\n";
|
||||||
throw std::runtime_error("RX chan q not found");
|
throw std::runtime_error("RX channel 2 not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter_source_ == "Off")
|
||||||
|
{
|
||||||
|
struct stream_cfg rxcfg;
|
||||||
|
rxcfg.bw_hz = bandwidth_;
|
||||||
|
rxcfg.fs_hz = sample_rate_;
|
||||||
|
rxcfg.lo_hz = freq_;
|
||||||
|
rxcfg.rfport = rf_port_select_.c_str();
|
||||||
|
|
||||||
|
if (!cfg_ad9361_streaming_ch(ctx, &rxcfg, RX, 0))
|
||||||
|
{
|
||||||
|
std::cout << "RX port 0 not found\n";
|
||||||
|
throw std::runtime_error("AD9361 IIO RX port 0 not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (filter_source_ == "Auto")
|
||||||
|
{
|
||||||
|
ret = ad9361_set_bb_rate(ad9361_phy, sample_rate_);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to set BB rate");
|
||||||
|
// set bw
|
||||||
|
//params.push_back("in_voltage_rf_bandwidth=" + boost::to_string(bandwidth));
|
||||||
|
}
|
||||||
|
//wr_ch_str(rx_chan1, "rf_port_select", rf_port_select_.c_str());
|
||||||
|
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to set rf_port_select");
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
|
||||||
|
if (!get_lo_chan(ctx, RX, &rx_chan1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "frequency", freq_);
|
||||||
|
}
|
||||||
|
else if (filter_source_ == "File")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!load_fir_filter(filter_filename_, ad9361_phy))
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to load filter file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::runtime_error &e)
|
||||||
|
{
|
||||||
|
std::cout << "Exception cached when configuring the RX FIR filter: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to set rf_port_select");
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
|
||||||
|
if (!get_lo_chan(ctx, RX, &rx_chan1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "frequency", freq_);
|
||||||
|
}
|
||||||
|
#if LIBAD9361_VERSION_GREATER_THAN_01
|
||||||
|
else if (filter_source_ == "Design")
|
||||||
|
{
|
||||||
|
ret = ad9361_set_bb_rate_custom_filter_manual(
|
||||||
|
ad9361_phy, sample_rate_, static_cast<uint64_t>(Fpass_), static_cast<uint64_t>(Fstop_), bandwidth_, bandwidth_);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to set BB rate");
|
||||||
|
}
|
||||||
|
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to set rf_port_select");
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
|
||||||
|
if (!get_lo_chan(ctx, RX, &rx_chan1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "frequency", freq_);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unknown filter configuration");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filters can only be disabled after the sample rate has been set
|
||||||
|
if (filter_source_ == "Off")
|
||||||
|
{
|
||||||
|
ret = ad9361_set_trx_fir_enable(ad9361_phy, false);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to disable filters");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "* Enabling IIO streaming channels\n";
|
std::cout << "* Enabling IIO streaming channels\n";
|
||||||
iio_channel_enable(rx0_i);
|
iio_channel_enable(rx_chan1);
|
||||||
iio_channel_enable(rx0_q);
|
iio_channel_enable(rx_chan2);
|
||||||
|
|
||||||
struct iio_device *ad9361_phy;
|
|
||||||
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
|
|
||||||
int ret;
|
|
||||||
ret = iio_device_attr_write(ad9361_phy, "trx_rate_governor", "nominal");
|
ret = iio_device_attr_write(ad9361_phy, "trx_rate_governor", "nominal");
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -320,22 +423,32 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
|
|||||||
double rf_gain_rx2_,
|
double rf_gain_rx2_,
|
||||||
bool quadrature_,
|
bool quadrature_,
|
||||||
bool rfdc_,
|
bool rfdc_,
|
||||||
bool bbdc_)
|
bool bbdc_,
|
||||||
|
std::string filter_source_,
|
||||||
|
std::string filter_filename_,
|
||||||
|
float Fpass_,
|
||||||
|
float Fstop_)
|
||||||
{
|
{
|
||||||
// RX stream config
|
// RX stream config
|
||||||
// Stream configurations
|
|
||||||
struct stream_cfg rxcfg;
|
|
||||||
rxcfg.bw_hz = bandwidth_; // 2 MHz rf bandwidth
|
|
||||||
rxcfg.fs_hz = sample_rate_; // 2.5 MS/s rx sample rate
|
|
||||||
rxcfg.lo_hz = freq_; // 2.5 GHz rf frequency
|
|
||||||
rxcfg.rfport = rf_port_select_.c_str(); // port A (select for rf freq.)
|
|
||||||
|
|
||||||
std::cout << "AD9361 Acquiring IIO REMOTE context in host " << remote_host << std::endl;
|
std::cout << "AD9361 Acquiring IIO REMOTE context in host " << remote_host << std::endl;
|
||||||
struct iio_context *ctx;
|
struct iio_context *ctx;
|
||||||
// Streaming devices
|
// Streaming devices
|
||||||
struct iio_device *rx;
|
struct iio_device *rx;
|
||||||
struct iio_channel *rx0_i;
|
struct iio_channel *rx_chan1;
|
||||||
struct iio_channel *rx0_q;
|
struct iio_channel *rx_chan2;
|
||||||
|
|
||||||
|
#ifndef LIBAD9361_VERSION_GREATER_THAN_01
|
||||||
|
if (filter_source_ == "Design")
|
||||||
|
{
|
||||||
|
std::cout << "Option filter_source=Design is not available in this version. Set to filter_source=Off" << std::endl;
|
||||||
|
filter_source_ = std::string("Off");
|
||||||
|
}
|
||||||
|
if (Fpass_ != 0.0 or Fstop_ != 0.0)
|
||||||
|
{
|
||||||
|
Fpass_ = 0.0;
|
||||||
|
Fstop_ = 0.0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ctx = iio_create_network_context(remote_host.c_str());
|
ctx = iio_create_network_context(remote_host.c_str());
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
@ -359,32 +472,126 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::cout << "* Configuring AD9361 for streaming\n";
|
std::cout << "* Configuring AD9361 for streaming\n";
|
||||||
if (!cfg_ad9361_streaming_ch(ctx, &rxcfg, RX, 0))
|
|
||||||
{
|
|
||||||
std::cout << "RX port 0 not found\n";
|
|
||||||
throw std::runtime_error("AD9361 IIO RX port 0 not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "* Initializing AD9361 IIO streaming channels\n";
|
|
||||||
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx0_i))
|
|
||||||
{
|
|
||||||
std::cout << "RX chan i not found\n";
|
|
||||||
throw std::runtime_error("RX chan i not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx0_q))
|
|
||||||
{
|
|
||||||
std::cout << "RX chan q not found\n";
|
|
||||||
throw std::runtime_error("RX chan q not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "* Enabling IIO streaming channels\n";
|
|
||||||
iio_channel_enable(rx0_i);
|
|
||||||
iio_channel_enable(rx0_q);
|
|
||||||
|
|
||||||
struct iio_device *ad9361_phy;
|
struct iio_device *ad9361_phy;
|
||||||
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
|
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
std::cout << "* Initializing AD9361 IIO streaming channels\n";
|
||||||
|
if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx_chan1))
|
||||||
|
{
|
||||||
|
std::cout << "RX channel 1 not found\n";
|
||||||
|
throw std::runtime_error("RX channel 1 not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx_chan2))
|
||||||
|
{
|
||||||
|
std::cout << "RX channel 2 not found\n";
|
||||||
|
throw std::runtime_error("RX channel 2 not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter_source_ == "Off")
|
||||||
|
{
|
||||||
|
struct stream_cfg rxcfg;
|
||||||
|
rxcfg.bw_hz = bandwidth_;
|
||||||
|
rxcfg.fs_hz = sample_rate_;
|
||||||
|
rxcfg.lo_hz = freq_;
|
||||||
|
rxcfg.rfport = rf_port_select_.c_str();
|
||||||
|
|
||||||
|
if (!cfg_ad9361_streaming_ch(ctx, &rxcfg, RX, 0))
|
||||||
|
{
|
||||||
|
std::cout << "RX port 0 not found\n";
|
||||||
|
throw std::runtime_error("AD9361 IIO RX port 0 not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (filter_source_ == "Auto")
|
||||||
|
{
|
||||||
|
ret = ad9361_set_bb_rate(ad9361_phy, sample_rate_);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to set BB rate");
|
||||||
|
// set bw
|
||||||
|
//params.push_back("in_voltage_rf_bandwidth=" + boost::to_string(bandwidth));
|
||||||
|
}
|
||||||
|
//wr_ch_str(rx_chan1, "rf_port_select", rf_port_select_.c_str());
|
||||||
|
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to set rf_port_select");
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
|
||||||
|
if (!get_lo_chan(ctx, RX, &rx_chan1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "frequency", freq_);
|
||||||
|
}
|
||||||
|
else if (filter_source_ == "File")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!load_fir_filter(filter_filename_, ad9361_phy))
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to load filter file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::runtime_error &e)
|
||||||
|
{
|
||||||
|
std::cout << "Exception cached when configuring the RX FIR filter: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to set rf_port_select");
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
|
||||||
|
if (!get_lo_chan(ctx, RX, &rx_chan1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "frequency", freq_);
|
||||||
|
}
|
||||||
|
#if LIBAD9361_VERSION_GREATER_THAN_01
|
||||||
|
else if (filter_source_ == "Design")
|
||||||
|
{
|
||||||
|
ret = ad9361_set_bb_rate_custom_filter_manual(
|
||||||
|
ad9361_phy, sample_rate_, static_cast<uint64_t>(Fpass_), static_cast<uint64_t>(Fstop_), bandwidth_, bandwidth_);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to set BB rate");
|
||||||
|
}
|
||||||
|
ret = iio_device_attr_write(ad9361_phy, "in_voltage0_rf_port_select", rf_port_select_.c_str());
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to set rf_port_select");
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "rf_bandwidth", bandwidth_);
|
||||||
|
if (!get_lo_chan(ctx, RX, &rx_chan1))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
wr_ch_lli(rx_chan1, "frequency", freq_);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unknown filter configuration");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filters can only be disabled after the sample rate has been set
|
||||||
|
if (filter_source_ == "Off")
|
||||||
|
{
|
||||||
|
ret = ad9361_set_trx_fir_enable(ad9361_phy, false);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Unable to disable filters");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "* Enabling IIO streaming channels\n";
|
||||||
|
iio_channel_enable(rx_chan1);
|
||||||
|
iio_channel_enable(rx_chan2);
|
||||||
|
|
||||||
ret = iio_device_attr_write(ad9361_phy, "trx_rate_governor", "nominal");
|
ret = iio_device_attr_write(ad9361_phy, "trx_rate_governor", "nominal");
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -425,15 +632,21 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
|
|||||||
{
|
{
|
||||||
std::cout << "Failed to set in_voltage1_gain_control_mode: " << ret << std::endl;
|
std::cout << "Failed to set in_voltage1_gain_control_mode: " << ret << std::endl;
|
||||||
}
|
}
|
||||||
ret = iio_device_attr_write_double(ad9361_phy, "in_voltage0_hardwaregain", rf_gain_rx1_);
|
if (gain_mode_rx1_ == "manual")
|
||||||
if (ret < 0)
|
|
||||||
{
|
{
|
||||||
std::cout << "Failed to set in_voltage0_hardwaregain: " << ret << std::endl;
|
ret = iio_device_attr_write_double(ad9361_phy, "in_voltage0_hardwaregain", rf_gain_rx1_);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to set in_voltage0_hardwaregain: " << ret << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ret = iio_device_attr_write_double(ad9361_phy, "in_voltage1_hardwaregain", rf_gain_rx2_);
|
if (gain_mode_rx2_ == "manual")
|
||||||
if (ret < 0)
|
|
||||||
{
|
{
|
||||||
std::cout << "Failed to set in_voltage1_hardwaregain: " << ret << std::endl;
|
ret = iio_device_attr_write_double(ad9361_phy, "in_voltage1_hardwaregain", rf_gain_rx2_);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to set in_voltage1_hardwaregain: " << ret << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "End of AD9361 RX configuration.\n";
|
std::cout << "End of AD9361 RX configuration.\n";
|
||||||
@ -448,7 +661,8 @@ bool config_ad9361_lo_local(uint64_t bandwidth_,
|
|||||||
uint64_t freq_rf_tx_hz_,
|
uint64_t freq_rf_tx_hz_,
|
||||||
double tx_attenuation_db_,
|
double tx_attenuation_db_,
|
||||||
int64_t freq_dds_tx_hz_,
|
int64_t freq_dds_tx_hz_,
|
||||||
double scale_dds_dbfs_)
|
double scale_dds_dbfs_,
|
||||||
|
double phase_dds_deg_)
|
||||||
{
|
{
|
||||||
// TX stream config
|
// TX stream config
|
||||||
std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n";
|
std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n";
|
||||||
@ -490,10 +704,16 @@ bool config_ad9361_lo_local(uint64_t bandwidth_,
|
|||||||
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
|
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
|
||||||
int ret;
|
int ret;
|
||||||
// set output amplifier attenuation
|
// set output amplifier attenuation
|
||||||
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -tx_attenuation_db_);
|
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -std::abs(tx_attenuation_db_));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
std::cout << "Failed to set out_voltage0_hardwaregain value " << -tx_attenuation_db_ << " error " << ret << std::endl;
|
std::cout << "Failed to set out_voltage0_hardwaregain value " << -std::abs(tx_attenuation_db_) << ". Error " << ret << std::endl;
|
||||||
|
}
|
||||||
|
// shut down signal in TX2
|
||||||
|
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage1_hardwaregain", -89.75);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to set out_voltage1_hardwaregain value -89.75 dB. Error " << ret << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct iio_device *dds;
|
struct iio_device *dds;
|
||||||
@ -523,13 +743,13 @@ bool config_ad9361_lo_local(uint64_t bandwidth_,
|
|||||||
std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl;
|
std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = iio_channel_attr_write_double(dds_channel0_I, "phase", 0.0);
|
ret = iio_channel_attr_write_double(dds_channel0_I, "phase", phase_dds_deg_ * 1000.0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
std::cout << "Failed to set TX DDS phase I: " << ret << std::endl;
|
std::cout << "Failed to set TX DDS phase I: " << ret << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", 270000.0);
|
ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", phase_dds_deg_ * 1000.0 + 270000.0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
std::cout << "Failed to set TX DDS phase Q: " << ret << std::endl;
|
std::cout << "Failed to set TX DDS phase Q: " << ret << std::endl;
|
||||||
@ -583,7 +803,8 @@ bool config_ad9361_lo_remote(const std::string &remote_host,
|
|||||||
uint64_t freq_rf_tx_hz_,
|
uint64_t freq_rf_tx_hz_,
|
||||||
double tx_attenuation_db_,
|
double tx_attenuation_db_,
|
||||||
int64_t freq_dds_tx_hz_,
|
int64_t freq_dds_tx_hz_,
|
||||||
double scale_dds_dbfs_)
|
double scale_dds_dbfs_,
|
||||||
|
double phase_dds_deg_)
|
||||||
{
|
{
|
||||||
// TX stream config
|
// TX stream config
|
||||||
std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n";
|
std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n";
|
||||||
@ -625,12 +846,18 @@ bool config_ad9361_lo_remote(const std::string &remote_host,
|
|||||||
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
|
ad9361_phy = iio_context_find_device(ctx, "ad9361-phy");
|
||||||
int ret;
|
int ret;
|
||||||
// set output amplifier attenuation
|
// set output amplifier attenuation
|
||||||
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -tx_attenuation_db_);
|
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -std::abs(tx_attenuation_db_));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
std::cout << "Failed to set out_voltage0_hardwaregain value " << -tx_attenuation_db_ << " error " << ret << std::endl;
|
std::cout << "Failed to set out_voltage0_hardwaregain value " << -std::abs(tx_attenuation_db_) << ". Error " << ret << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shut down signal in TX2
|
||||||
|
ret = iio_device_attr_write_double(ad9361_phy, "out_voltage1_hardwaregain", -89.75);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
std::cout << "Failed to set out_voltage1_hardwaregain value -89.75 dB. Error " << ret << std::endl;
|
||||||
|
}
|
||||||
struct iio_device *dds;
|
struct iio_device *dds;
|
||||||
dds = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc");
|
dds = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc");
|
||||||
struct iio_channel *dds_channel0_I;
|
struct iio_channel *dds_channel0_I;
|
||||||
@ -658,13 +885,13 @@ bool config_ad9361_lo_remote(const std::string &remote_host,
|
|||||||
std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl;
|
std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = iio_channel_attr_write_double(dds_channel0_I, "phase", 0.0);
|
ret = iio_channel_attr_write_double(dds_channel0_I, "phase", phase_dds_deg_ * 1000.0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
std::cout << "Failed to set TX DDS phase I: " << ret << std::endl;
|
std::cout << "Failed to set TX DDS phase I: " << ret << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", 270000.0);
|
ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", phase_dds_deg_ * 1000.0 + 270000.0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
std::cout << "Failed to set TX DDS phase Q: " << ret << std::endl;
|
std::cout << "Failed to set TX DDS phase Q: " << ret << std::endl;
|
||||||
@ -794,3 +1021,47 @@ bool ad9361_disable_lo_local()
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool load_fir_filter(
|
||||||
|
std::string &filter, struct iio_device *phy)
|
||||||
|
{
|
||||||
|
if (filter.empty() || !iio_device_find_attr(phy, "filter_fir_config"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ifstream ifs(filter.c_str(), std::ifstream::binary);
|
||||||
|
if (!ifs)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Here, we verify that the filter file contains data for both RX+TX.
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ifs.getline(buf, sizeof(buf));
|
||||||
|
}
|
||||||
|
while (!(buf[0] == '-' || (buf[0] >= '0' && buf[0] <= '9')));
|
||||||
|
|
||||||
|
std::string line(buf);
|
||||||
|
if (line.find(',') == std::string::npos)
|
||||||
|
throw std::runtime_error("Incompatible filter file");
|
||||||
|
}
|
||||||
|
|
||||||
|
ifs.seekg(0, ifs.end);
|
||||||
|
int length = ifs.tellg();
|
||||||
|
ifs.seekg(0, ifs.beg);
|
||||||
|
|
||||||
|
std::vector<char> buffer(length);
|
||||||
|
|
||||||
|
ifs.read(buffer.data(), length);
|
||||||
|
ifs.close();
|
||||||
|
|
||||||
|
int ret = iio_device_attr_write_raw(phy,
|
||||||
|
"filter_fir_config", buffer.data(), length);
|
||||||
|
|
||||||
|
return ret > 0;
|
||||||
|
}
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#define FIR_BUF_SIZE 8192
|
||||||
|
|
||||||
/* RX is input, TX is output */
|
/* RX is input, TX is output */
|
||||||
enum iodev
|
enum iodev
|
||||||
@ -48,13 +49,12 @@ enum iodev
|
|||||||
/* common RX and TX streaming params */
|
/* common RX and TX streaming params */
|
||||||
struct stream_cfg
|
struct stream_cfg
|
||||||
{
|
{
|
||||||
int64_t bw_hz; // Analog banwidth in Hz
|
int64_t bw_hz; // Analog bandwidth in Hz
|
||||||
int64_t fs_hz; // Baseband sample rate in Hz
|
int64_t fs_hz; // Baseband sample rate in Hz
|
||||||
int64_t lo_hz; // Local oscillator frequency in Hz
|
int64_t lo_hz; // Local oscillator frequency in Hz
|
||||||
const char *rfport; // Port name
|
const char *rfport; // Port name
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* check return value of attr_write function */
|
/* check return value of attr_write function */
|
||||||
void errchk(int v, const char *what);
|
void errchk(int v, const char *what);
|
||||||
|
|
||||||
@ -64,9 +64,6 @@ void wr_ch_lli(struct iio_channel *chn, const char *what, int64_t val);
|
|||||||
/* write attribute: string */
|
/* write attribute: string */
|
||||||
void wr_ch_str(struct iio_channel *chn, const char *what, const char *str);
|
void wr_ch_str(struct iio_channel *chn, const char *what, const char *str);
|
||||||
|
|
||||||
/* helper function generating channel names */
|
|
||||||
char *get_ch_name(const char *type, int id, char *tmpstr);
|
|
||||||
|
|
||||||
/* returns ad9361 phy device */
|
/* returns ad9361 phy device */
|
||||||
struct iio_device *get_ad9361_phy(struct iio_context *ctx);
|
struct iio_device *get_ad9361_phy(struct iio_context *ctx);
|
||||||
|
|
||||||
@ -95,7 +92,11 @@ bool config_ad9361_rx_local(uint64_t bandwidth_,
|
|||||||
double rf_gain_rx2_,
|
double rf_gain_rx2_,
|
||||||
bool quadrature_,
|
bool quadrature_,
|
||||||
bool rfdc_,
|
bool rfdc_,
|
||||||
bool bbdc_);
|
bool bbdc_,
|
||||||
|
std::string filter_source_,
|
||||||
|
std::string filter_filename_,
|
||||||
|
float Fpass_,
|
||||||
|
float Fstop_);
|
||||||
|
|
||||||
bool config_ad9361_rx_remote(const std::string &remote_host,
|
bool config_ad9361_rx_remote(const std::string &remote_host,
|
||||||
uint64_t bandwidth_,
|
uint64_t bandwidth_,
|
||||||
@ -108,14 +109,19 @@ bool config_ad9361_rx_remote(const std::string &remote_host,
|
|||||||
double rf_gain_rx2_,
|
double rf_gain_rx2_,
|
||||||
bool quadrature_,
|
bool quadrature_,
|
||||||
bool rfdc_,
|
bool rfdc_,
|
||||||
bool bbdc_);
|
bool bbdc_,
|
||||||
|
std::string filter_source_,
|
||||||
|
std::string filter_filename_,
|
||||||
|
float Fpass_,
|
||||||
|
float Fstop_);
|
||||||
|
|
||||||
bool config_ad9361_lo_local(uint64_t bandwidth_,
|
bool config_ad9361_lo_local(uint64_t bandwidth_,
|
||||||
uint64_t sample_rate_,
|
uint64_t sample_rate_,
|
||||||
uint64_t freq_rf_tx_hz_,
|
uint64_t freq_rf_tx_hz_,
|
||||||
double tx_attenuation_db_,
|
double tx_attenuation_db_,
|
||||||
int64_t freq_dds_tx_hz_,
|
int64_t freq_dds_tx_hz_,
|
||||||
double scale_dds_dbfs_);
|
double scale_dds_dbfs_,
|
||||||
|
double phase_dds_deg_);
|
||||||
|
|
||||||
bool config_ad9361_lo_remote(const std::string &remote_host,
|
bool config_ad9361_lo_remote(const std::string &remote_host,
|
||||||
uint64_t bandwidth_,
|
uint64_t bandwidth_,
|
||||||
@ -123,11 +129,13 @@ bool config_ad9361_lo_remote(const std::string &remote_host,
|
|||||||
uint64_t freq_rf_tx_hz_,
|
uint64_t freq_rf_tx_hz_,
|
||||||
double tx_attenuation_db_,
|
double tx_attenuation_db_,
|
||||||
int64_t freq_dds_tx_hz_,
|
int64_t freq_dds_tx_hz_,
|
||||||
double scale_dds_dbfs_);
|
double scale_dds_dbfs_,
|
||||||
|
double phase_dds_deg_);
|
||||||
|
|
||||||
bool ad9361_disable_lo_remote(const std::string &remote_host);
|
bool ad9361_disable_lo_remote(const std::string &remote_host);
|
||||||
|
|
||||||
bool ad9361_disable_lo_local();
|
bool ad9361_disable_lo_local();
|
||||||
|
|
||||||
|
bool load_fir_filter(std::string &filter, struct iio_device *phy);
|
||||||
|
|
||||||
#endif // GNSS_SDR_AD9361_MANAGER_H_
|
#endif // GNSS_SDR_AD9361_MANAGER_H_
|
||||||
|
Loading…
Reference in New Issue
Block a user