From fb8e5e5c47c9f203e4fa6d42c0015b03115a853a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 3 Jul 2020 20:18:42 +0200 Subject: [PATCH] Fix a bug in signal sources that made the number of samples parameter ignored when too large (Fixes: #396) --- docs/changelog.md | 2 ++ .../adapters/ad9361_fpga_signal_source.cc | 10 +++++----- .../signal_source/adapters/file_signal_source.cc | 4 ++-- .../adapters/fmcomms2_signal_source.cc | 14 +++++++------- .../adapters/multichannel_file_signal_source.cc | 4 ++-- .../adapters/nsr_file_signal_source.cc | 4 ++-- .../adapters/osmosdr_signal_source.cc | 2 +- .../adapters/plutosdr_signal_source.cc | 8 ++++---- .../adapters/rtl_tcp_signal_source.cc | 2 +- .../adapters/spir_file_signal_source.cc | 4 ++-- .../adapters/spir_gss6450_file_signal_source.cc | 6 +++--- .../adapters/two_bit_cpx_file_signal_source.cc | 4 ++-- .../adapters/two_bit_packed_file_signal_source.cc | 4 ++-- 13 files changed, 35 insertions(+), 33 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index e92633413..a17d6e479 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -79,6 +79,8 @@ SPDX-FileCopyrightText: 2011-2020 Carles Fernandez-Prades property(role + ".freq", GPS_L1_FREQ_HZ); - sample_rate_ = configuration->property(role + ".sampling_frequency", 12500000); + freq_ = configuration->property(role + ".freq", static_cast(GPS_L1_FREQ_HZ)); + sample_rate_ = configuration->property(role + ".sampling_frequency", 12500000ULL); bandwidth_ = configuration->property(role + ".bandwidth", default_bandwidth); quadrature_ = configuration->property(role + ".quadrature", true); rf_dc_ = configuration->property(role + ".rf_dc", true); @@ -78,11 +78,11 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *con Fpass_ = configuration->property(role + ".Fpass", 0.0); Fstop_ = configuration->property(role + ".Fstop", 0.0); enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false); - freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 10000); - freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L5_FREQ_HZ - freq_dds_tx_hz_); + freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 10000ULL); + freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", static_cast(GPS_L1_FREQ_HZ - GPS_L5_FREQ_HZ - freq_dds_tx_hz_)); 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); + tx_bandwidth_ = configuration->property(role + ".tx_bandwidth", 500000ULL); phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0); rf_shutdown_ = configuration->property(role + ".rf_shutdown", FLAGS_rf_shutdown); diff --git a/src/algorithms/signal_source/adapters/file_signal_source.cc b/src/algorithms/signal_source/adapters/file_signal_source.cc index c6b2c2853..e7cc94f73 100644 --- a/src/algorithms/signal_source/adapters/file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/file_signal_source.cc @@ -41,8 +41,8 @@ FileSignalSource::FileSignalSource(const ConfigurationInterface* configuration, double default_seconds_to_skip = 0.0; size_t header_size = 0; - samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); + samples_ = configuration->property(role + ".samples", 0ULL); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0LL); filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc index 985264875..6af4d92b1 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc @@ -41,9 +41,9 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(const ConfigurationInterface *configu 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")); - freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ); - sample_rate_ = configuration->property(role + ".sampling_frequency", 2600000); - bandwidth_ = configuration->property(role + ".bandwidth", 2000000); + freq_ = configuration->property(role + ".freq", static_cast(GPS_L1_FREQ_HZ)); + sample_rate_ = configuration->property(role + ".sampling_frequency", 2600000ULL); + bandwidth_ = configuration->property(role + ".bandwidth", 2000000ULL); rx1_en_ = configuration->property(role + ".rx1_enable", true); rx2_en_ = configuration->property(role + ".rx2_enable", false); buffer_size_ = configuration->property(role + ".buffer_size", 0xA0000); @@ -71,18 +71,18 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(const ConfigurationInterface *configu Fstop_ = configuration->property(role + ".Fstop", 0.0); item_type_ = configuration->property(role + ".item_type", default_item_type); - samples_ = configuration->property(role + ".samples", 0); + samples_ = configuration->property(role + ".samples", 0LL); dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); // AD9361 Local Oscillator generation for dual band operation enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false); - freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 10000); - freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - freq_dds_tx_hz_); + freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 10000ULL); + freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", static_cast(GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - freq_dds_tx_hz_)); scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", 0.0); phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0); tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", default_tx_attenuation_db); - tx_bandwidth_ = configuration->property(role + ".tx_bandwidth", 500000); + tx_bandwidth_ = configuration->property(role + ".tx_bandwidth", 500000ULL); rf_shutdown_ = configuration->property(role + ".rf_shutdown", FLAGS_rf_shutdown); diff --git a/src/algorithms/signal_source/adapters/multichannel_file_signal_source.cc b/src/algorithms/signal_source/adapters/multichannel_file_signal_source.cc index 153f0e752..117a69809 100644 --- a/src/algorithms/signal_source/adapters/multichannel_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/multichannel_file_signal_source.cc @@ -40,8 +40,8 @@ MultichannelFileSignalSource::MultichannelFileSignalSource(const ConfigurationIn double default_seconds_to_skip = 0.0; size_t header_size = 0; - samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); + samples_ = configuration->property(role + ".samples", 0ULL); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0LL); n_channels_ = configuration->property(role + ".total_channels", 1); for (unsigned int n = 0; n < n_channels_; n++) diff --git a/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc b/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc index b73dd3685..6d6709f8e 100644 --- a/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc @@ -39,8 +39,8 @@ NsrFileSignalSource::NsrFileSignalSource(const ConfigurationInterface* configura std::string default_item_type = "byte"; std::string default_dump_filename = "../data/my_capture_dump.dat"; - samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); + samples_ = configuration->property(role + ".samples", 0ULL); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0LL); filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present diff --git a/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc b/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc index 75ac8504a..2d30830b8 100644 --- a/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc +++ b/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc @@ -37,7 +37,7 @@ OsmosdrSignalSource::OsmosdrSignalSource(const ConfigurationInterface* configura std::string empty = ""; std::string default_dump_file = "./data/signal_source.dat"; std::string default_item_type = "gr_complex"; - samples_ = configuration->property(role + ".samples", 0); + samples_ = configuration->property(role + ".samples", 0LL); dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); diff --git a/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc b/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc index 51cfe53e7..77426a972 100644 --- a/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc +++ b/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc @@ -34,9 +34,9 @@ PlutosdrSignalSource::PlutosdrSignalSource(const ConfigurationInterface* configu 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")); - freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ); - sample_rate_ = configuration->property(role + ".sampling_frequency", 3000000); - bandwidth_ = configuration->property(role + ".bandwidth", 2000000); + freq_ = configuration->property(role + ".freq", static_cast(GPS_L1_FREQ_HZ)); + sample_rate_ = configuration->property(role + ".sampling_frequency", 3000000ULL); + bandwidth_ = configuration->property(role + ".bandwidth", 2000000ULL); buffer_size_ = configuration->property(role + ".buffer_size", 0xA0000); quadrature_ = configuration->property(role + ".quadrature", true); rf_dc_ = configuration->property(role + ".rf_dc", true); @@ -57,7 +57,7 @@ PlutosdrSignalSource::PlutosdrSignalSource(const ConfigurationInterface* configu Fpass_ = configuration->property(role + ".Fpass", 0.0); Fstop_ = configuration->property(role + ".Fstop", 0.0); item_type_ = configuration->property(role + ".item_type", default_item_type); - samples_ = configuration->property(role + ".samples", 0); + samples_ = configuration->property(role + ".samples", 0LL); dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); diff --git a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc index a4e0f90b8..876dd85f3 100644 --- a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc +++ b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc @@ -42,7 +42,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(const ConfigurationInterface* configurati std::string empty = ""; std::string default_dump_file = "./data/signal_source.dat"; std::string default_item_type = "gr_complex"; - samples_ = configuration->property(role + ".samples", 0); + samples_ = configuration->property(role + ".samples", 0ULL); dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); diff --git a/src/algorithms/signal_source/adapters/spir_file_signal_source.cc b/src/algorithms/signal_source/adapters/spir_file_signal_source.cc index f27e2c476..e877ac63b 100644 --- a/src/algorithms/signal_source/adapters/spir_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/spir_file_signal_source.cc @@ -38,8 +38,8 @@ SpirFileSignalSource::SpirFileSignalSource(const ConfigurationInterface* configu std::string default_item_type = "int"; std::string default_dump_filename = "../data/my_capture_dump.dat"; - samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); + samples_ = configuration->property(role + ".samples", 0ULL); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0LL); filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present diff --git a/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc b/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc index ea0fc86a3..d692cd00f 100644 --- a/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc @@ -35,8 +35,8 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(const ConfigurationInte std::string default_dump_filename = "../data/my_capture_dump.dat"; item_type_ = "int"; - samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); + samples_ = configuration->property(role + ".samples", 0ULL); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0LL); filename_ = configuration->property(role + ".filename", default_filename); repeat_ = configuration->property(role + ".repeat", false); dump_ = configuration->property(role + ".dump", false); @@ -47,7 +47,7 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(const ConfigurationInte n_channels_ = configuration->property(role + ".total_channels", 1); sel_ch_ = configuration->property(role + ".sel_ch", 1); item_size_ = sizeof(int32_t); - int64_t bytes_seek = configuration->property(role + ".bytes_to_skip", 65536); + int64_t bytes_seek = configuration->property(role + ".bytes_to_skip", 65536LL); double sample_size_byte = static_cast(adc_bits_) / 4.0; if (sel_ch_ > n_channels_) diff --git a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc index baf07c578..75ec3f2e7 100644 --- a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc @@ -43,8 +43,8 @@ TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource( std::string default_item_type = "byte"; std::string default_dump_filename = "../data/my_capture_dump.dat"; - samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); + samples_ = configuration->property(role + ".samples", 0ULL); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0LL); filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present diff --git a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc index bf2d9cb09..9a3e3468c 100644 --- a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc @@ -47,8 +47,8 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource( std::string default_sample_type = "real"; double default_seconds_to_skip = 0.0; - samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); + samples_ = configuration->property(role + ".samples", 0ULL); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0LL); filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present