1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-05-17 23:04:08 +00:00

Add multiple RF output capability to LabSat 3 Wideband format

This commit is contained in:
Carles Fernandez 2021-03-14 20:00:18 +01:00
parent 60a7a6d51d
commit 9e1ee33cd2
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
5 changed files with 565 additions and 420 deletions

View File

@ -63,7 +63,8 @@ SPDX-FileCopyrightText: 2011-2021 Carles Fernandez-Prades <carles.fernandez@cttc
- Fix bug that made the Monitor block to always set to 0 the - Fix bug that made the Monitor block to always set to 0 the
`carrier_phase_rads` parameter value. `carrier_phase_rads` parameter value.
- The `Labsat_Signal_Source` implementation of the `SignalSource` block now can - The `Labsat_Signal_Source` implementation of the `SignalSource` block now can
read files in the LabSat 3 Wideband format (`.LS3W`). read files in the LabSat 3 Wideband format (`.LS3W`). When using this format,
this source block can provide multiple RF chain outputs.
- Replace `Receiver.sources_count` configuration parameter name by - Replace `Receiver.sources_count` configuration parameter name by
`GNSS-SDR.num_sources`. The former parameter name is still read to ensure `GNSS-SDR.num_sources`. The former parameter name is still read to ensure
backward compatibility with configuration files using that nomenclature. backward compatibility with configuration files using that nomenclature.

View File

@ -1,6 +1,6 @@
/*! /*!
* \file labsat_signal_source.cc * \file labsat_signal_source.cc
* \brief Labsat 2 and 3 front-end signal sampler driver * \brief LabSat version 2, 3, and 3 Wideband format reader
* \author Javier Arribas, jarribas(at)cttc.es * \author Javier Arribas, jarribas(at)cttc.es
* *
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
@ -8,7 +8,7 @@
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR. * This file is part of GNSS-SDR.
* *
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* *
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
@ -19,6 +19,8 @@
#include "gnss_sdr_string_literals.h" #include "gnss_sdr_string_literals.h"
#include "labsat23_source.h" #include "labsat23_source.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <iostream>
#include <sstream>
using namespace std::string_literals; using namespace std::string_literals;
@ -37,7 +39,25 @@ LabsatSignalSource::LabsatSignalSource(const ConfigurationInterface* configurati
const int64_t sampling_frequency_deprecated = configuration->property(role + ".sampling_frequency", static_cast<int64_t>(16368000)); const int64_t sampling_frequency_deprecated = configuration->property(role + ".sampling_frequency", static_cast<int64_t>(16368000));
const int64_t throttle_frequency_sps = configuration->property(role + ".throttle_frequency_sps", static_cast<int64_t>(sampling_frequency_deprecated)); const int64_t throttle_frequency_sps = configuration->property(role + ".throttle_frequency_sps", static_cast<int64_t>(sampling_frequency_deprecated));
const int channel_selector = configuration->property(role + ".selected_channel", 1); std::string channels_to_read = configuration->property(role + ".selected_channel", default_item_type);
std::stringstream ss(channels_to_read);
int found;
while (ss.good())
{
std::string substr;
getline(ss, substr, ',');
if (std::stringstream(substr) >> found)
{
if (found >= 1 && found <= 3)
{
channels_selector_vec_.push_back(found);
}
}
}
if (channels_selector_vec_.empty())
{
channels_selector_vec_.push_back(1);
}
const std::string default_filename("./example_capture.LS3"); const std::string default_filename("./example_capture.LS3");
filename_ = configuration->property(role + ".filename", default_filename); filename_ = configuration->property(role + ".filename", default_filename);
@ -47,7 +67,7 @@ LabsatSignalSource::LabsatSignalSource(const ConfigurationInterface* configurati
if (item_type_ == "gr_complex") if (item_type_ == "gr_complex")
{ {
item_size_ = sizeof(gr_complex); item_size_ = sizeof(gr_complex);
labsat23_source_ = labsat23_make_source_sptr(filename_.c_str(), channel_selector, queue, digital_io_enabled); labsat23_source_ = labsat23_make_source_sptr(filename_.c_str(), channels_selector_vec_, queue, digital_io_enabled);
DLOG(INFO) << "Item size " << item_size_; DLOG(INFO) << "Item size " << item_size_;
DLOG(INFO) << "labsat23_source_(" << labsat23_source_->unique_id() << ")"; DLOG(INFO) << "labsat23_source_(" << labsat23_source_->unique_id() << ")";
} }
@ -58,49 +78,95 @@ LabsatSignalSource::LabsatSignalSource(const ConfigurationInterface* configurati
} }
if (dump_) if (dump_)
{ {
DLOG(INFO) << "Dumping output into file " << dump_filename_; std::vector<std::string> dump_filename;
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; file_sink_.reserve(channels_selector_vec_.size());
file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str()); for (int i : channels_selector_vec_)
{
if (channels_selector_vec_.size() == 1)
{
dump_filename.push_back(dump_filename_);
}
else
{
std::string aux(dump_filename_.substr(0, dump_filename_.length() - 4));
std::string extension(dump_filename_.substr(dump_filename_.length() - 3, dump_filename_.length()));
if (i == 1)
{
aux += "_chA."s;
}
if (i == 2)
{
aux += "_chB."s;
}
if (i == 3)
{
aux += "_chC."s;
}
dump_filename.push_back(aux + extension);
}
std::cout << "Dumping output into file " << dump_filename.back() << '\n';
file_sink_.push_back(gr::blocks::file_sink::make(item_size_, dump_filename.back().c_str()));
DLOG(INFO) << "file_sink(" << file_sink_.back()->unique_id() << ")";
}
} }
if (enable_throttle_control_) if (enable_throttle_control_)
{ {
throttle_ = gr::blocks::throttle::make(item_size_, throttle_frequency_sps); for (auto it = channels_selector_vec_.begin(); it != channels_selector_vec_.end(); ++it)
{
throttle_.push_back(gr::blocks::throttle::make(item_size_, throttle_frequency_sps));
}
} }
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";
} }
if (out_stream_ > 1) if (out_stream_ > 3)
{ {
LOG(ERROR) << "This implementation only supports one output stream"; LOG(ERROR) << "This implementation supports up to 3 output streams";
} }
} }
size_t LabsatSignalSource::getRfChannels() const
{
return channels_selector_vec_.size();
}
void LabsatSignalSource::connect(gr::top_block_sptr top_block) void LabsatSignalSource::connect(gr::top_block_sptr top_block)
{ {
if (enable_throttle_control_ == true) if (enable_throttle_control_ == true)
{ {
top_block->connect(labsat23_source_, 0, throttle_, 0); int rf_chan = 0;
DLOG(INFO) << "connected labsat23_source_ to throttle"; for (const auto& th : throttle_)
if (dump_)
{ {
top_block->connect(labsat23_source_, 0, file_sink_, 0); top_block->connect(labsat23_source_, rf_chan, th, 0);
DLOG(INFO) << "connected labsat23_source_to sink"; DLOG(INFO) << "connected labsat23_source_ to throttle";
if (dump_)
{
top_block->connect(labsat23_source_, rf_chan, file_sink_[rf_chan], 0);
DLOG(INFO) << "connected labsat23_source_to sink";
}
rf_chan++;
} }
} }
else else
{ {
if (dump_) int rf_chan = 0;
for (auto it = channels_selector_vec_.begin(); it != channels_selector_vec_.end(); ++it)
{ {
top_block->connect(labsat23_source_, 0, file_sink_, 0); if (dump_)
DLOG(INFO) << "connected labsat23_source_ to sink"; {
} top_block->connect(labsat23_source_, 0, file_sink_[rf_chan], 0);
else DLOG(INFO) << "connected labsat23_source_ to sink";
{ }
DLOG(INFO) << "nothing to connect internally"; else
{
DLOG(INFO) << "nothing to connect internally";
}
rf_chan++;
} }
} }
} }
@ -110,20 +176,30 @@ void LabsatSignalSource::disconnect(gr::top_block_sptr top_block)
{ {
if (enable_throttle_control_ == true) if (enable_throttle_control_ == true)
{ {
top_block->disconnect(labsat23_source_, 0, throttle_, 0); int rf_chan = 0;
DLOG(INFO) << "disconnected labsat23_source_ to throttle"; for (const auto& th : throttle_)
if (dump_)
{ {
top_block->disconnect(labsat23_source_, 0, file_sink_, 0); top_block->disconnect(labsat23_source_, rf_chan, th, 0);
DLOG(INFO) << "disconnected labsat23_source_ to sink"; DLOG(INFO) << "disconnected labsat23_source_ to throttle";
if (dump_)
{
top_block->disconnect(labsat23_source_, rf_chan, file_sink_[rf_chan], 0);
DLOG(INFO) << "disconnected labsat23_source_ to sink";
}
rf_chan++;
} }
} }
else else
{ {
if (dump_) int rf_chan = 0;
for (auto it = channels_selector_vec_.begin(); it != channels_selector_vec_.end(); ++it)
{ {
top_block->disconnect(labsat23_source_, 0, file_sink_, 0); if (dump_)
DLOG(INFO) << "disconnected labsat23_source_ to sink"; {
top_block->disconnect(labsat23_source_, rf_chan, file_sink_[rf_chan], 0);
DLOG(INFO) << "disconnected labsat23_source_ to sink";
}
rf_chan++;
} }
} }
} }
@ -140,7 +216,17 @@ gr::basic_block_sptr LabsatSignalSource::get_right_block()
{ {
if (enable_throttle_control_ == true) if (enable_throttle_control_ == true)
{ {
return throttle_; return throttle_[0];
}
return labsat23_source_;
}
gr::basic_block_sptr LabsatSignalSource::get_right_block(int i)
{
if (enable_throttle_control_ == true)
{
return throttle_[i];
} }
return labsat23_source_; return labsat23_source_;
} }

View File

@ -1,6 +1,6 @@
/*! /*!
* \file labsat_signal_source.h * \file labsat_signal_source.h
* \brief Labsat 2 and 3 front-end signal sampler driver * \brief LabSat version 2, 3, and 3 Wideband format reader
* \author Javier Arribas, jarribas(at)cttc.es * \author Javier Arribas, jarribas(at)cttc.es
* *
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
@ -8,7 +8,7 @@
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR. * This file is part of GNSS-SDR.
* *
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* *
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
@ -27,6 +27,7 @@
#include <pmt/pmt.h> #include <pmt/pmt.h>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector>
/** \addtogroup Signal_Source /** \addtogroup Signal_Source
* \{ */ * \{ */
@ -37,7 +38,8 @@
class ConfigurationInterface; class ConfigurationInterface;
/*! /*!
* \brief This class reads samples stored by a LabSat 2 or LabSat 3 device * \brief This class reads samples stored in LabSat version 2, 3, and 3 Wideband
* format.
*/ */
class LabsatSignalSource : public SignalSourceBase class LabsatSignalSource : public SignalSourceBase
{ {
@ -53,15 +55,18 @@ public:
return item_size_; return item_size_;
} }
size_t getRfChannels() const override;
void connect(gr::top_block_sptr top_block) override; void connect(gr::top_block_sptr top_block) override;
void disconnect(gr::top_block_sptr top_block) override; void disconnect(gr::top_block_sptr top_block) override;
gr::basic_block_sptr get_left_block() override; gr::basic_block_sptr get_left_block() override;
gr::basic_block_sptr get_right_block() override; gr::basic_block_sptr get_right_block() override;
gr::basic_block_sptr get_right_block(int i) override;
private: private:
gr::block_sptr labsat23_source_; gr::block_sptr labsat23_source_;
gr::blocks::file_sink::sptr file_sink_; std::vector<gr::blocks::file_sink::sptr> file_sink_;
gr::blocks::throttle::sptr throttle_; std::vector<gr::blocks::throttle::sptr> throttle_;
std::vector<int> channels_selector_vec_;
std::string item_type_; std::string item_type_;
std::string filename_; std::string filename_;

View File

@ -1,7 +1,7 @@
/*! /*!
* \file labsat23_source.h * \file labsat23_source.h
* *
* \brief Unpacks capture files in the Labsat 2 (ls2), Labsat 3 (ls3), or Labsat * \brief Unpacks capture files in the LabSat 2 (ls2), LabSat 3 (ls3), or LabSat
* 3 Wideband (LS3W) formats. * 3 Wideband (LS3W) formats.
* \author Javier Arribas jarribas (at) cttc.es * \author Javier Arribas jarribas (at) cttc.es
* *
@ -23,9 +23,11 @@
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
#include <gnuradio/block.h> #include <gnuradio/block.h>
#include <pmt/pmt.h> #include <pmt/pmt.h>
#include <cstddef>
#include <cstdint> #include <cstdint>
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <vector>
/** \addtogroup Signal_Source /** \addtogroup Signal_Source
* \{ */ * \{ */
@ -39,12 +41,13 @@ using labsat23_source_sptr = gnss_shared_ptr<labsat23_source>;
labsat23_source_sptr labsat23_make_source_sptr( labsat23_source_sptr labsat23_make_source_sptr(
const char *signal_file_basename, const char *signal_file_basename,
int channel_selector, const std::vector<int> &channel_selector,
Concurrent_Queue<pmt::pmt_t> *queue, Concurrent_Queue<pmt::pmt_t> *queue,
bool digital_io_enabled); bool digital_io_enabled);
/*! /*!
* \brief This class implements conversion between Labsat2 and 3 format byte packet samples to gr_complex * \brief This class implements conversion between Labsat 2, 3 and 3 Wideband
* formats to gr_complex
*/ */
class labsat23_source : public gr::block class labsat23_source : public gr::block
{ {
@ -59,28 +62,29 @@ public:
private: private:
friend labsat23_source_sptr labsat23_make_source_sptr( friend labsat23_source_sptr labsat23_make_source_sptr(
const char *signal_file_basename, const char *signal_file_basename,
int channel_selector, const std::vector<int> &channel_selector,
Concurrent_Queue<pmt::pmt_t> *queue, Concurrent_Queue<pmt::pmt_t> *queue,
bool digital_io_enabled); bool digital_io_enabled);
labsat23_source(const char *signal_file_basename, labsat23_source(const char *signal_file_basename,
int channel_selector, const std::vector<int> &channel_selector,
Concurrent_Queue<pmt::pmt_t> *queue, Concurrent_Queue<pmt::pmt_t> *queue,
bool digital_io_enabled); bool digital_io_enabled);
std::string generate_filename(); std::string generate_filename();
int parse_header();
int getBit(uint8_t byte, int position); int getBit(uint8_t byte, int position);
int read_ls3w_ini(const std::string &filename); int read_ls3w_ini(const std::string &filename);
int number_of_samples_per_ls3w_register() const; int number_of_samples_per_ls3w_register() const;
void decode_samples_one_channel(int16_t input_short, gr_complex *out, int type); void decode_samples_one_channel(int16_t input_short, gr_complex *out, int type);
void decode_ls3w_register_one_channel(uint64_t input, gr_complex *out) const; void decode_ls3w_register(uint64_t input, std::vector<gr_complex *> &out, std::size_t output_pointer) const;
std::ifstream binary_input_file; std::ifstream binary_input_file;
std::string d_signal_file_basename; std::string d_signal_file_basename;
Concurrent_Queue<pmt::pmt_t> *d_queue; Concurrent_Queue<pmt::pmt_t> *d_queue;
int d_channel_selector_config; std::vector<int> d_channel_selector_config;
int d_current_file_number; int d_current_file_number;
uint8_t d_labsat_version; uint8_t d_labsat_version;
uint8_t d_channel_selector; uint8_t d_channel_selector;
@ -90,6 +94,7 @@ private:
// Data members for Labsat 3 Wideband // Data members for Labsat 3 Wideband
std::string d_ls3w_OSC; std::string d_ls3w_OSC;
std::vector<int> d_ls3w_selected_channel_offset;
int64_t d_ls3w_SMP{}; int64_t d_ls3w_SMP{};
int32_t d_ls3w_QUA{}; int32_t d_ls3w_QUA{};
int32_t d_ls3w_CHN{}; int32_t d_ls3w_CHN{};
@ -101,7 +106,6 @@ private:
int32_t d_ls3w_BWB{}; int32_t d_ls3w_BWB{};
int32_t d_ls3w_BWC{}; int32_t d_ls3w_BWC{};
int d_ls3w_spare_bits{}; int d_ls3w_spare_bits{};
int d_ls3w_selected_channel_offset{};
int d_ls3w_samples_per_register{}; int d_ls3w_samples_per_register{};
bool d_is_ls3w = false; bool d_is_ls3w = false;
bool d_ls3w_digital_io_enabled = false; bool d_ls3w_digital_io_enabled = false;