2017-10-29 05:51:22 +00:00
/*!
2018-05-19 18:34:50 +00:00
* \ file fmcomms2_signal_source . cc
* \ brief Signal source for SDR hardware from Analog Devices based on
2019-03-03 12:39:35 +00:00
* fmcomms2 evaluation board .
2020-07-03 21:55:01 +00:00
* \ author Rodrigo Muñoz , 2017 , rmunozl ( at ) inacap . cl , rodrigo . munoz ( at ) proteinlab . cl
*
2017-10-29 05:51:22 +00:00
*
2020-07-28 14:57:15 +00:00
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2017-10-29 05:51:22 +00:00
*
2020-12-30 12:35:06 +00:00
* GNSS - SDR is a Global Navigation Satellite System software - defined receiver .
2017-10-29 05:51:22 +00:00
* This file is part of GNSS - SDR .
*
2020-12-30 12:35:06 +00:00
* Copyright ( C ) 2010 - 2020 ( see AUTHORS file for a list of contributors )
2020-02-08 00:20:02 +00:00
* SPDX - License - Identifier : GPL - 3.0 - or - later
2017-10-29 05:51:22 +00:00
*
2020-07-28 14:57:15 +00:00
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2017-10-29 05:51:22 +00:00
*/
# include "fmcomms2_signal_source.h"
# include "GPS_L1_CA.h"
2018-03-27 17:35:53 +00:00
# include "GPS_L2C.h"
2019-10-10 08:40:37 +00:00
# include "ad9361_manager.h"
2018-12-09 21:00:09 +00:00
# include "configuration_interface.h"
2019-10-13 21:38:06 +00:00
# include "gnss_sdr_flags.h"
2021-02-16 13:27:46 +00:00
# include "gnss_sdr_string_literals.h"
2018-12-09 21:00:09 +00:00
# include "gnss_sdr_valve.h"
2018-02-26 02:15:53 +00:00
# include <glog/logging.h>
2019-10-08 10:57:37 +00:00
# include <algorithm> // for max
2018-05-19 18:34:50 +00:00
# include <exception>
2018-02-26 02:15:53 +00:00
# include <iostream>
2018-12-10 18:29:00 +00:00
# include <utility>
2018-02-26 02:15:53 +00:00
2021-02-09 22:47:34 +00:00
using namespace std : : string_literals ;
2017-10-29 05:51:22 +00:00
2020-06-29 07:07:41 +00:00
Fmcomms2SignalSource : : Fmcomms2SignalSource ( const ConfigurationInterface * configuration ,
2019-10-10 06:12:25 +00:00
const std : : string & role , unsigned int in_stream , unsigned int out_stream ,
2021-02-09 22:47:34 +00:00
Concurrent_Queue < pmt : : pmt_t > * queue )
2021-02-15 22:34:48 +00:00
: SignalSourceBase ( configuration , role , " Fmcomms2_Signal_Source " s ) , in_stream_ ( in_stream ) , out_stream_ ( out_stream )
2017-10-29 05:51:22 +00:00
{
2020-07-09 22:37:55 +00:00
const std : : string default_item_type ( " gr_complex " ) ;
const std : : string default_dump_file ( " ./data/signal_source.dat " ) ;
2020-07-17 07:11:42 +00:00
const std : : string default_gain_mode ( " slow_attack " ) ;
const double default_tx_attenuation_db = - 10.0 ;
2017-10-30 21:31:20 +00:00
uri_ = configuration - > property ( role + " .device_address " , std : : string ( " 192.168.2.1 " ) ) ;
2020-07-03 18:18:42 +00:00
freq_ = configuration - > property ( role + " .freq " , static_cast < uint64_t > ( GPS_L1_FREQ_HZ ) ) ;
2020-07-03 19:52:40 +00:00
sample_rate_ = configuration - > property ( role + " .sampling_frequency " , static_cast < uint64_t > ( 2600000 ) ) ;
bandwidth_ = configuration - > property ( role + " .bandwidth " , static_cast < uint64_t > ( 2000000 ) ) ;
2017-10-30 21:31:20 +00:00
rx1_en_ = configuration - > property ( role + " .rx1_enable " , true ) ;
rx2_en_ = configuration - > property ( role + " .rx2_enable " , false ) ;
buffer_size_ = configuration - > property ( role + " .buffer_size " , 0xA0000 ) ;
quadrature_ = configuration - > property ( role + " .quadrature " , true ) ;
rf_dc_ = configuration - > property ( role + " .rf_dc " , true ) ;
bb_dc_ = configuration - > property ( role + " .bb_dc " , true ) ;
2018-03-27 17:35:53 +00:00
RF_channels_ = configuration - > property ( role + " .RF_channels " , 1 ) ;
2019-10-07 20:45:09 +00:00
gain_mode_rx1_ = configuration - > property ( role + " .gain_mode_rx1 " , default_gain_mode ) ;
gain_mode_rx2_ = configuration - > property ( role + " .gain_mode_rx2 " , default_gain_mode ) ;
2017-10-30 21:31:20 +00:00
rf_gain_rx1_ = configuration - > property ( role + " .gain_rx1 " , 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 " ) ) ;
filter_file_ = configuration - > property ( role + " .filter_file " , std : : string ( " " ) ) ;
2019-10-08 14:38:30 +00:00
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 " ) ) ;
}
filter_filename_ = configuration - > property ( role + " .filter_filename " , filter_file_ ) ;
2019-10-05 19:12:54 +00:00
Fpass_ = configuration - > property ( role + " .Fpass " , 0.0 ) ;
Fstop_ = configuration - > property ( role + " .Fstop " , 0.0 ) ;
2019-10-08 14:38:30 +00:00
2017-10-30 21:31:20 +00:00
item_type_ = configuration - > property ( role + " .item_type " , default_item_type ) ;
2020-07-03 19:37:57 +00:00
samples_ = configuration - > property ( role + " .samples " , static_cast < int64_t > ( 0 ) ) ;
2017-10-30 21:31:20 +00:00
dump_ = configuration - > property ( role + " .dump " , false ) ;
dump_filename_ = configuration - > property ( role + " .dump_filename " , default_dump_file ) ;
2017-10-29 05:51:22 +00:00
2018-05-19 18:34:50 +00:00
// AD9361 Local Oscillator generation for dual band operation
2018-03-27 19:10:31 +00:00
enable_dds_lo_ = configuration - > property ( role + " .enable_dds_lo " , false ) ;
2020-07-03 19:52:40 +00:00
freq_dds_tx_hz_ = configuration - > property ( role + " .freq_dds_tx_hz " , static_cast < uint64_t > ( 10000 ) ) ;
2020-07-03 18:18:42 +00:00
freq_rf_tx_hz_ = configuration - > property ( role + " .freq_rf_tx_hz " , static_cast < uint64_t > ( GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - freq_dds_tx_hz_ ) ) ;
2018-03-27 19:10:31 +00:00
scale_dds_dbfs_ = configuration - > property ( role + " .scale_dds_dbfs " , 0.0 ) ;
phase_dds_deg_ = configuration - > property ( role + " .phase_dds_deg " , 0.0 ) ;
2019-10-07 20:45:09 +00:00
tx_attenuation_db_ = configuration - > property ( role + " .tx_attenuation_db " , default_tx_attenuation_db ) ;
2020-07-03 19:52:40 +00:00
tx_bandwidth_ = configuration - > property ( role + " .tx_bandwidth " , static_cast < uint64_t > ( 500000 ) ) ;
2018-03-27 17:35:53 +00:00
2019-10-13 21:38:06 +00:00
rf_shutdown_ = configuration - > property ( role + " .rf_shutdown " , FLAGS_rf_shutdown ) ;
2017-10-30 21:31:20 +00:00
item_size_ = sizeof ( gr_complex ) ;
2017-10-29 05:51:22 +00:00
2019-10-06 17:07:24 +00:00
// some basic checks
if ( ( rf_port_select_ ! = " A_BALANCED " ) and ( rf_port_select_ ! = " B_BALANCED " ) and ( rf_port_select_ ! = " A_N " ) and ( rf_port_select_ ! = " B_N " ) and ( rf_port_select_ ! = " B_P " ) and ( rf_port_select_ ! = " C_N " ) and ( rf_port_select_ ! = " C_P " ) and ( rf_port_select_ ! = " TX_MONITOR1 " ) and ( rf_port_select_ ! = " TX_MONITOR2 " ) and ( rf_port_select_ ! = " TX_MONITOR1_2 " ) )
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Configuration parameter rf_port_select should take one of these values: \n " ;
std : : cout < < " A_BALANCED, B_BALANCED, A_N, B_N, B_P, C_N, C_P, TX_MONITOR1, TX_MONITOR2, TX_MONITOR1_2 \n " ;
std : : cout < < " Error: provided value rf_port_select= " < < rf_port_select_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value rf_port_select=A_BALANCED \n " ;
2019-10-06 17:07:24 +00:00
rf_port_select_ = std : : string ( " A_BALANCED " ) ;
2019-10-07 20:45:09 +00:00
LOG ( WARNING ) < < " Invalid configuration value for rf_port_select parameter. Set to rf_port_select=A_BALANCED " ;
2019-10-06 17:07:24 +00:00
}
if ( ( gain_mode_rx1_ ! = " manual " ) and ( gain_mode_rx1_ ! = " slow_attack " ) and ( gain_mode_rx1_ ! = " fast_attack " ) and ( gain_mode_rx1_ ! = " hybrid " ) )
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Configuration parameter gain_mode_rx1 should take one of these values: \n " ;
std : : cout < < " manual, slow_attack, fast_attack, hybrid \n " ;
std : : cout < < " Error: provided value gain_mode_rx1= " < < gain_mode_rx1_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value gain_mode_rx1= " < < default_gain_mode < < ' \n ' ;
2019-10-07 20:45:09 +00:00
gain_mode_rx1_ = default_gain_mode ;
LOG ( WARNING ) < < " Invalid configuration value for gain_mode_rx1 parameter. Set to gain_mode_rx1= " < < default_gain_mode ;
2019-10-06 17:07:24 +00:00
}
if ( ( gain_mode_rx2_ ! = " manual " ) and ( gain_mode_rx2_ ! = " slow_attack " ) and ( gain_mode_rx2_ ! = " fast_attack " ) and ( gain_mode_rx2_ ! = " hybrid " ) )
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Configuration parameter gain_mode_rx2 should take one of these values: \n " ;
std : : cout < < " manual, slow_attack, fast_attack, hybrid \n " ;
std : : cout < < " Error: provided value gain_mode_rx2= " < < gain_mode_rx2_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value gain_mode_rx2= " < < default_gain_mode < < ' \n ' ;
2019-10-07 20:45:09 +00:00
gain_mode_rx2_ = default_gain_mode ;
LOG ( WARNING ) < < " Invalid configuration value for gain_mode_rx1 parameter. Set to gain_mode_rx2= " < < default_gain_mode ;
2019-10-06 17:07:24 +00:00
}
if ( ( filter_source_ ! = " Off " ) and ( filter_source_ ! = " Auto " ) and ( filter_source_ ! = " File " ) and ( filter_source_ ! = " Design " ) )
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Configuration parameter filter_source should take one of these values: \n " ;
std : : cout < < " Off: Disable filter \n " ;
std : : cout < < " Auto: Use auto-generated filters \n " ;
std : : cout < < " File: User-provided filter in filter_filename parameter \n " ;
2019-10-09 20:17:44 +00:00
# if LIBAD9361_VERSION_GREATER_THAN_01
2020-07-07 16:53:50 +00:00
std : : cout < < " Design: Create filter from Fpass, Fstop, sampling_frequency and bandwidth parameters \n " ;
2019-10-09 20:17:44 +00:00
# endif
2020-07-07 16:53:50 +00:00
std : : cout < < " Error: provided value filter_source= " < < filter_source_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value filter_source=Off \n " ;
2019-10-06 17:07:24 +00:00
filter_source_ = std : : string ( " Off " ) ;
2019-10-07 20:45:09 +00:00
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 )
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Configuration parameter rf_gain_rx1 should take values between -1.0 and 73 dB \n " ;
std : : cout < < " Error: provided value rf_gain_rx1= " < < rf_gain_rx1_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value rf_gain_rx1=64.0 \n " ;
2019-10-07 20:45:09 +00:00
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 )
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Configuration parameter rf_gain_rx2 should take values between -1.0 and 73 dB \n " ;
std : : cout < < " Error: provided value rf_gain_rx2= " < < rf_gain_rx2_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value rf_gain_rx2=64.0 \n " ;
2019-10-07 20:45:09 +00:00
rf_gain_rx2_ = 64.0 ;
LOG ( WARNING ) < < " Invalid configuration value for rf_gain_rx2 parameter. Set to rf_gain_rx2=64.0 " ;
}
2019-10-06 17:07:24 +00:00
}
2019-10-08 14:38:30 +00:00
if ( bandwidth_ < 200000 or bandwidth_ > 56000000 )
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Configuration parameter bandwidth should take values between 200000 and 56000000 Hz \n " ;
std : : cout < < " Error: provided value bandwidth= " < < bandwidth_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value bandwidth=2000000 \n " ;
2019-10-08 14:38:30 +00:00
bandwidth_ = 2000000 ;
LOG ( WARNING ) < < " Invalid configuration value for bandwidth parameter. Set to bandwidth=2000000 " ;
}
2020-07-07 16:53:50 +00:00
std : : cout < < " device address: " < < uri_ < < ' \n ' ;
std : : cout < < " LO frequency : " < < freq_ < < " Hz \n " ;
std : : cout < < " sample rate: " < < sample_rate_ < < " Hz \n " ;
2017-10-29 05:51:22 +00:00
2018-12-10 18:29:00 +00:00
if ( item_type_ = = " gr_complex " )
2017-10-30 21:31:20 +00:00
{
2018-03-27 19:10:31 +00:00
if ( RF_channels_ = = 1 )
2018-03-27 17:35:53 +00:00
{
2018-03-27 19:10:31 +00:00
if ( rx1_en_ and rx2_en_ )
{
LOG ( FATAL ) < < " Configuration error: both rx1 and rx2 are enabled but RF_channels=1 ! " ;
}
else
{
2019-10-05 19:12:54 +00:00
# if GNURADIO_API_IIO
fmcomms2_source_f32c_ = gr : : iio : : fmcomms2_source_f32c : : make (
uri_ . c_str ( ) , freq_ , sample_rate_ ,
bandwidth_ ,
rx1_en_ , rx2_en_ ,
buffer_size_ , quadrature_ , rf_dc_ ,
bb_dc_ , gain_mode_rx1_ . c_str ( ) , rf_gain_rx1_ ,
gain_mode_rx2_ . c_str ( ) , rf_gain_rx2_ ,
rf_port_select_ . c_str ( ) , filter_source_ . c_str ( ) ,
filter_filename_ . c_str ( ) , Fpass_ , Fstop_ ) ;
# else
2018-03-27 19:10:31 +00:00
fmcomms2_source_f32c_ = gr : : iio : : fmcomms2_source_f32c : : make (
uri_ . c_str ( ) , freq_ , sample_rate_ ,
bandwidth_ ,
rx1_en_ , rx2_en_ ,
buffer_size_ , quadrature_ , rf_dc_ ,
bb_dc_ , gain_mode_rx1_ . c_str ( ) , rf_gain_rx1_ ,
gain_mode_rx2_ . c_str ( ) , rf_gain_rx2_ ,
rf_port_select_ . c_str ( ) , filter_file_ . c_str ( ) ,
filter_auto_ ) ;
2019-10-05 19:12:54 +00:00
# endif
2018-05-19 18:34:50 +00:00
// configure LO
2018-03-27 19:10:31 +00:00
if ( enable_dds_lo_ = = true )
{
2019-10-08 10:57:37 +00:00
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 ) )
2019-10-07 20:45:09 +00:00
{
2020-07-07 16:53:50 +00:00
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 \n " ;
std : : cout < < " Error: provided value tx_bandwidth= " < < tx_bandwidth_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value tx_bandwidth=500000 \n " ;
2019-10-07 20:45:09 +00:00
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 )
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Configuration parameter tx_attenuation_db should take values between 0.0 and -89.95 in 0.25 dB steps \n " ;
std : : cout < < " Error: provided value tx_attenuation_db= " < < tx_attenuation_db_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value tx_attenuation_db= " < < default_tx_attenuation_db < < ' \n ' ;
2019-10-07 20:45:09 +00:00
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 ;
}
2018-03-27 19:10:31 +00:00
std : : cout < < " Enabling Local Oscillator generator in FMCOMMS2 \n " ;
2019-10-07 20:45:09 +00:00
try
{
config_ad9361_lo_remote ( uri_ ,
tx_bandwidth_ ,
sample_rate_ ,
freq_rf_tx_hz_ ,
tx_attenuation_db_ ,
freq_dds_tx_hz_ ,
2019-10-08 10:57:37 +00:00
scale_dds_dbfs_ ,
phase_dds_deg_ ) ;
2019-10-07 20:45:09 +00:00
}
2019-10-10 06:12:25 +00:00
catch ( const std : : runtime_error & e )
2019-10-07 20:45:09 +00:00
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Exception cached when configuring the TX carrier: " < < e . what ( ) < < ' \n ' ;
2019-10-07 20:45:09 +00:00
}
2018-03-27 19:10:31 +00:00
}
}
2018-03-27 17:35:53 +00:00
}
2018-03-27 19:10:31 +00:00
else if ( RF_channels_ = = 2 )
2018-03-27 17:35:53 +00:00
{
2018-03-27 19:10:31 +00:00
if ( ! ( rx1_en_ and rx2_en_ ) )
{
LOG ( FATAL ) < < " Configuration error: RF_channels=2 but are not enabled both receivers in FMCOMMS2 ! " ;
}
else
{
2019-10-05 19:12:54 +00:00
# if GNURADIO_API_IIO
fmcomms2_source_f32c_ = gr : : iio : : fmcomms2_source_f32c : : make (
uri_ . c_str ( ) , freq_ , sample_rate_ ,
bandwidth_ ,
rx1_en_ , rx2_en_ ,
buffer_size_ , quadrature_ , rf_dc_ ,
bb_dc_ , gain_mode_rx1_ . c_str ( ) , rf_gain_rx1_ ,
gain_mode_rx2_ . c_str ( ) , rf_gain_rx2_ ,
rf_port_select_ . c_str ( ) , filter_source_ . c_str ( ) ,
filter_filename_ . c_str ( ) , Fpass_ , Fstop_ ) ;
# else
2018-03-27 19:10:31 +00:00
fmcomms2_source_f32c_ = gr : : iio : : fmcomms2_source_f32c : : make (
uri_ . c_str ( ) , freq_ , sample_rate_ ,
bandwidth_ ,
rx1_en_ , rx2_en_ ,
buffer_size_ , quadrature_ , rf_dc_ ,
bb_dc_ , gain_mode_rx1_ . c_str ( ) , rf_gain_rx1_ ,
gain_mode_rx2_ . c_str ( ) , rf_gain_rx2_ ,
rf_port_select_ . c_str ( ) , filter_file_ . c_str ( ) ,
filter_auto_ ) ;
2019-10-05 19:12:54 +00:00
# endif
2018-05-19 18:34:50 +00:00
// configure LO
2018-03-27 19:10:31 +00:00
if ( enable_dds_lo_ = = true )
{
2019-10-08 10:57:37 +00:00
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 ) )
2019-10-07 20:45:09 +00:00
{
2020-07-07 16:53:50 +00:00
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 \n " ;
std : : cout < < " Error: provided value tx_bandwidth= " < < tx_bandwidth_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value tx_bandwidth=500000 \n " ;
2019-10-07 20:45:09 +00:00
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 )
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Configuration parameter tx_attenuation_db should take values between 0.0 and -89.95 in 0.25 dB steps \n " ;
std : : cout < < " Error: provided value tx_attenuation_db= " < < tx_attenuation_db_ < < " is not among valid values \n " ;
std : : cout < < " This parameter has been set to its default value tx_attenuation_db= " < < default_tx_attenuation_db < < ' \n ' ;
2019-10-07 20:45:09 +00:00
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 ;
}
2018-03-27 19:10:31 +00:00
std : : cout < < " Enabling Local Oscillator generator in FMCOMMS2 \n " ;
2019-10-07 20:45:09 +00:00
try
{
config_ad9361_lo_remote ( uri_ ,
tx_bandwidth_ ,
sample_rate_ ,
freq_rf_tx_hz_ ,
tx_attenuation_db_ ,
freq_dds_tx_hz_ ,
2019-10-08 10:57:37 +00:00
scale_dds_dbfs_ ,
phase_dds_deg_ ) ;
2019-10-07 20:45:09 +00:00
}
2019-10-10 06:12:25 +00:00
catch ( const std : : runtime_error & e )
2019-10-07 20:45:09 +00:00
{
2020-07-07 16:53:50 +00:00
std : : cout < < " Exception cached when configuring the TX carrier: " < < e . what ( ) < < ' \n ' ;
2019-10-07 20:45:09 +00:00
}
2018-03-27 19:10:31 +00:00
}
}
2018-03-27 17:35:53 +00:00
}
2018-03-27 19:10:31 +00:00
else
2018-03-27 17:35:53 +00:00
{
2018-03-27 19:10:31 +00:00
LOG ( FATAL ) < < " Configuration error: Unsupported number of RF_channels ! " ;
2018-03-27 17:35:53 +00:00
}
2017-10-30 21:31:20 +00:00
}
else
{
2017-11-04 09:59:51 +00:00
LOG ( FATAL ) < < " Configuration error: item type " < < item_type_ < < " not supported! " ;
2017-10-30 21:31:20 +00:00
}
if ( samples_ ! = 0 )
{
DLOG ( INFO ) < < " Send STOP signal after " < < samples_ < < " samples " ;
2020-06-18 09:49:28 +00:00
valve_ = gnss_sdr_make_valve ( item_size_ , samples_ , queue ) ;
2017-10-30 21:31:20 +00:00
DLOG ( INFO ) < < " valve( " < < valve_ - > unique_id ( ) < < " ) " ;
}
2017-10-29 05:51:22 +00:00
if ( dump_ )
2017-10-30 21:31:20 +00:00
{
DLOG ( INFO ) < < " Dumping output into file " < < dump_filename_ ;
file_sink_ = gr : : blocks : : file_sink : : make ( item_size_ , dump_filename_ . c_str ( ) ) ;
DLOG ( INFO ) < < " file_sink( " < < file_sink_ - > unique_id ( ) < < " ) " ;
}
2017-10-29 05:51:22 +00:00
}
2017-10-30 21:31:20 +00:00
2017-10-29 05:51:22 +00:00
Fmcomms2SignalSource : : ~ Fmcomms2SignalSource ( )
2018-03-03 01:03:39 +00:00
{
2019-10-13 21:38:06 +00:00
if ( rf_shutdown_ )
2018-03-27 19:10:31 +00:00
{
2019-10-13 21:38:06 +00:00
if ( ! disable_ad9361_rx_remote ( uri_ ) )
2018-05-19 18:34:50 +00:00
{
2019-10-13 21:38:06 +00:00
LOG ( WARNING ) < < " Problem shutting down the AD9361 RX channels " ;
2018-05-19 18:34:50 +00:00
}
2019-10-13 21:38:06 +00:00
if ( enable_dds_lo_ = = true )
2018-05-19 18:34:50 +00:00
{
2019-10-13 21:38:06 +00:00
try
{
ad9361_disable_lo_remote ( uri_ ) ;
}
catch ( const std : : exception & e )
{
LOG ( WARNING ) < < " Problem shutting down the AD9361 TX channel: " < < e . what ( ) ;
}
2018-05-19 18:34:50 +00:00
}
2018-03-27 19:10:31 +00:00
}
2018-03-03 01:03:39 +00:00
}
2017-10-30 21:31:20 +00:00
2017-10-29 05:51:22 +00:00
void Fmcomms2SignalSource : : connect ( gr : : top_block_sptr top_block )
{
if ( samples_ ! = 0 )
{
2017-10-30 21:31:20 +00:00
top_block - > connect ( fmcomms2_source_f32c_ , 0 , valve_ , 0 ) ;
2017-10-29 05:51:22 +00:00
DLOG ( INFO ) < < " connected fmcomms2 source to valve " ;
if ( dump_ )
{
top_block - > connect ( valve_ , 0 , file_sink_ , 0 ) ;
DLOG ( INFO ) < < " connected valve to file sink " ;
}
2017-10-30 21:31:20 +00:00
}
2017-10-29 05:51:22 +00:00
else
{
if ( dump_ )
{
2018-03-03 01:03:39 +00:00
top_block - > connect ( fmcomms2_source_f32c_ , 0 , file_sink_ , 0 ) ;
2017-10-29 05:51:22 +00:00
DLOG ( INFO ) < < " connected fmcomms2 source to file sink " ;
}
}
}
void Fmcomms2SignalSource : : disconnect ( gr : : top_block_sptr top_block )
{
if ( samples_ ! = 0 )
{
top_block - > disconnect ( fmcomms2_source_f32c_ , 0 , valve_ , 0 ) ;
if ( dump_ )
{
top_block - > disconnect ( valve_ , 0 , file_sink_ , 0 ) ;
}
}
else
{
if ( dump_ )
{
2017-11-04 09:59:51 +00:00
top_block - > disconnect ( fmcomms2_source_f32c_ , 0 , file_sink_ , 0 ) ;
2017-10-29 05:51:22 +00:00
}
}
}
gr : : basic_block_sptr Fmcomms2SignalSource : : get_left_block ( )
{
LOG ( WARNING ) < < " Trying to get signal source left block. " ;
return gr : : basic_block_sptr ( ) ;
}
gr : : basic_block_sptr Fmcomms2SignalSource : : get_right_block ( )
{
if ( samples_ ! = 0 )
{
return valve_ ;
}
else
{
return ( fmcomms2_source_f32c_ ) ;
}
}