mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-04 23:40:04 +00:00
Add Cshort_To_Gr_Complex Data Type Adapter implementation
This commit is contained in:
parent
cdcbc4d03d
commit
98ee81f3ac
@ -50,6 +50,9 @@ All notable changes to GNSS-SDR will be documented in this file.
|
|||||||
- Add experimental decoding of Galileo's I/NAV ARAIM Integrity Support Message
|
- Add experimental decoding of Galileo's I/NAV ARAIM Integrity Support Message
|
||||||
(ISM) as defined in the OS SIS ICD v2.1. Values, if received, are only logged
|
(ISM) as defined in the OS SIS ICD v2.1. Values, if received, are only logged
|
||||||
but not used.
|
but not used.
|
||||||
|
- Added new
|
||||||
|
[`Cshort_To_Gr_Complex`](https://gnss-sdr.org/docs/sp-blocks/data-type-adapter/#implementation-cshort_to_gr_complex)
|
||||||
|
Data Type Adapter implementation.
|
||||||
|
|
||||||
### Improvements in Portability:
|
### Improvements in Portability:
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
set(DATATYPE_ADAPTER_SOURCES
|
set(DATATYPE_ADAPTER_SOURCES
|
||||||
byte_to_short.cc
|
byte_to_short.cc
|
||||||
|
cshort_to_grcomplex.cc
|
||||||
ibyte_to_cbyte.cc
|
ibyte_to_cbyte.cc
|
||||||
ibyte_to_complex.cc
|
ibyte_to_complex.cc
|
||||||
ibyte_to_cshort.cc
|
ibyte_to_cshort.cc
|
||||||
@ -16,6 +17,7 @@ set(DATATYPE_ADAPTER_SOURCES
|
|||||||
|
|
||||||
set(DATATYPE_ADAPTER_HEADERS
|
set(DATATYPE_ADAPTER_HEADERS
|
||||||
byte_to_short.h
|
byte_to_short.h
|
||||||
|
cshort_to_grcomplex.h
|
||||||
ibyte_to_cbyte.h
|
ibyte_to_cbyte.h
|
||||||
ibyte_to_complex.h
|
ibyte_to_complex.h
|
||||||
ibyte_to_cshort.h
|
ibyte_to_cshort.h
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
/*!
|
||||||
|
* \file cshort_to_grcomplex.cc
|
||||||
|
* \brief Adapts an 16-bits complex sample stream to a float complex stream
|
||||||
|
* \author Carles Fernandez Prades, 2014 cfernandez(at)cttc.es
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cshort_to_grcomplex.h"
|
||||||
|
#include "configuration_interface.h"
|
||||||
|
#include <utility>
|
||||||
|
#if USE_GLOG_AND_GFLAGS
|
||||||
|
#include <glog/logging.h>
|
||||||
|
#else
|
||||||
|
#include <absl/log/log.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
CshortToGrComplex::CshortToGrComplex(const ConfigurationInterface* configuration,
|
||||||
|
std::string role,
|
||||||
|
unsigned int in_streams,
|
||||||
|
unsigned int out_streams) : role_(std::move(role)),
|
||||||
|
in_streams_(in_streams),
|
||||||
|
out_streams_(out_streams),
|
||||||
|
dump_(configuration->property(role_ + ".dump", false))
|
||||||
|
{
|
||||||
|
const std::string default_dump_filename("../data/data_type_adapter.dat");
|
||||||
|
|
||||||
|
DLOG(INFO) << "role " << role_;
|
||||||
|
|
||||||
|
dump_filename_ = configuration->property(role_ + ".dump_filename", default_dump_filename);
|
||||||
|
cshort_to_gr_complex_ = make_cshort_to_gr_complex();
|
||||||
|
|
||||||
|
DLOG(INFO) << "data_type_adapter_(" << cshort_to_gr_complex_->unique_id() << ")";
|
||||||
|
|
||||||
|
if (dump_)
|
||||||
|
{
|
||||||
|
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||||
|
const size_t item_size = sizeof(gr_complex);
|
||||||
|
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
|
||||||
|
}
|
||||||
|
if (in_streams_ > 1)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "This implementation only supports one input stream";
|
||||||
|
}
|
||||||
|
if (out_streams_ > 1)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "This implementation only supports one output stream";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CshortToGrComplex::connect(gr::top_block_sptr top_block)
|
||||||
|
{
|
||||||
|
if (dump_)
|
||||||
|
{
|
||||||
|
top_block->connect(cshort_to_gr_complex_, 0, file_sink_, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DLOG(INFO) << "Nothing to connect internally";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CshortToGrComplex::disconnect(gr::top_block_sptr top_block)
|
||||||
|
{
|
||||||
|
if (dump_)
|
||||||
|
{
|
||||||
|
top_block->disconnect(cshort_to_gr_complex_, 0, file_sink_, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gr::basic_block_sptr CshortToGrComplex::get_left_block()
|
||||||
|
{
|
||||||
|
return cshort_to_gr_complex_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gr::basic_block_sptr CshortToGrComplex::get_right_block()
|
||||||
|
{
|
||||||
|
return cshort_to_gr_complex_;
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
/*!
|
||||||
|
* \file cshort_to_grcomplex.h
|
||||||
|
* \brief Adapts an 16-bits complex sample stream to a float complex stream
|
||||||
|
* \author Carles Fernandez Prades, 2014 cfernandez(at)cttc.es
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GNSS_SDR_CSHORT_TO_GRCOMPLEX_H
|
||||||
|
#define GNSS_SDR_CSHORT_TO_GRCOMPLEX_H
|
||||||
|
|
||||||
|
#include "cshort_to_gr_complex.h"
|
||||||
|
#include "gnss_block_interface.h"
|
||||||
|
#include <gnuradio/blocks/file_sink.h>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
/** \addtogroup Data_Type Data Type Adapters
|
||||||
|
* Classes for data type conversion
|
||||||
|
* \{ */
|
||||||
|
/** \addtogroup Data_type_adapters data_type_adapters
|
||||||
|
* Wrap GNU Radio data tyope adapter blocks with a GNSSBlockInterface
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigurationInterface;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Adapts an 16-bits complex sample stream to a float complex stream
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class CshortToGrComplex : public GNSSBlockInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CshortToGrComplex(const ConfigurationInterface* configuration,
|
||||||
|
std::string role, unsigned int in_streams,
|
||||||
|
unsigned int out_streams);
|
||||||
|
|
||||||
|
~CshortToGrComplex() = default;
|
||||||
|
|
||||||
|
inline std::string role() override
|
||||||
|
{
|
||||||
|
return role_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Returns "Cshort_To_Gr_Complex"
|
||||||
|
inline std::string implementation() override
|
||||||
|
{
|
||||||
|
return "Cshort_To_Gr_Complex";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t item_size() override
|
||||||
|
{
|
||||||
|
return 2 * sizeof(float);
|
||||||
|
}
|
||||||
|
|
||||||
|
void connect(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_right_block() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
cshort_to_gr_complex_sptr cshort_to_gr_complex_;
|
||||||
|
gr::blocks::file_sink::sptr file_sink_;
|
||||||
|
std::string dump_filename_;
|
||||||
|
std::string role_;
|
||||||
|
unsigned int in_streams_;
|
||||||
|
unsigned int out_streams_;
|
||||||
|
bool dump_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
/** \} */
|
||||||
|
#endif // GNSS_SDR_CSHORT_TO_GRCOMPLEX_H
|
@ -6,12 +6,14 @@
|
|||||||
|
|
||||||
|
|
||||||
set(DATA_TYPE_GR_BLOCKS_SOURCES
|
set(DATA_TYPE_GR_BLOCKS_SOURCES
|
||||||
|
cshort_to_gr_complex.cc
|
||||||
interleaved_byte_to_complex_byte.cc
|
interleaved_byte_to_complex_byte.cc
|
||||||
interleaved_short_to_complex_short.cc
|
interleaved_short_to_complex_short.cc
|
||||||
interleaved_byte_to_complex_short.cc
|
interleaved_byte_to_complex_short.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
set(DATA_TYPE_GR_BLOCKS_HEADERS
|
set(DATA_TYPE_GR_BLOCKS_HEADERS
|
||||||
|
cshort_to_gr_complex.h
|
||||||
interleaved_byte_to_complex_byte.h
|
interleaved_byte_to_complex_byte.h
|
||||||
interleaved_short_to_complex_short.h
|
interleaved_short_to_complex_short.h
|
||||||
interleaved_byte_to_complex_short.h
|
interleaved_byte_to_complex_short.h
|
||||||
@ -42,6 +44,7 @@ target_link_libraries(data_type_gr_blocks
|
|||||||
Boost::headers
|
Boost::headers
|
||||||
PRIVATE
|
PRIVATE
|
||||||
Volk::volk
|
Volk::volk
|
||||||
|
Volkgnsssdr::volkgnsssdr
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(data_type_gr_blocks
|
target_include_directories(data_type_gr_blocks
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
/*!
|
||||||
|
* \file cshort_to_gr_complex.cc
|
||||||
|
* \brief Adapts a complex short (16 + 16 bits) sample stream into a
|
||||||
|
* std::complex<float> stream (32 + 32 bits)
|
||||||
|
* \author Carles Fernandez Prades, 2014 cfernandez(at)cttc.es
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "cshort_to_gr_complex.h"
|
||||||
|
#include <gnuradio/io_signature.h>
|
||||||
|
#include <volk/volk.h>
|
||||||
|
#include <volk_gnsssdr/volk_gnsssdr.h>
|
||||||
|
#include <algorithm> // for max
|
||||||
|
|
||||||
|
|
||||||
|
cshort_to_gr_complex_sptr make_cshort_to_gr_complex()
|
||||||
|
{
|
||||||
|
return cshort_to_gr_complex_sptr(new cshort_to_gr_complex());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cshort_to_gr_complex::cshort_to_gr_complex()
|
||||||
|
: sync_block("cshort_to_gr_complex",
|
||||||
|
gr::io_signature::make(1, 1, sizeof(lv_16sc_t)),
|
||||||
|
gr::io_signature::make(1, 1, sizeof(gr_complex)))
|
||||||
|
{
|
||||||
|
const auto alignment_multiple = static_cast<int>(volk_get_alignment() / sizeof(lv_16sc_t));
|
||||||
|
set_alignment(std::max(1, alignment_multiple));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int cshort_to_gr_complex::work(int noutput_items,
|
||||||
|
gr_vector_const_void_star &input_items,
|
||||||
|
gr_vector_void_star &output_items)
|
||||||
|
{
|
||||||
|
const auto *in = reinterpret_cast<const lv_16sc_t *>(input_items[0]);
|
||||||
|
auto *out = reinterpret_cast<gr_complex *>(output_items[0]);
|
||||||
|
volk_gnsssdr_16ic_convert_32fc(out, in, noutput_items);
|
||||||
|
return noutput_items;
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*!
|
||||||
|
* \file cshort_to_gr_complex.h
|
||||||
|
* \brief Adapts a complex short (16 + 16 bits) sample stream into a
|
||||||
|
* std::complex<float> stream (32 + 32 bits)
|
||||||
|
* \author Carles Fernandez Prades, 2014 cfernandez(at)cttc.es
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GNSS_SDR_CSHORT_TO_GR_COMPLEX_H
|
||||||
|
#define GNSS_SDR_CSHORT_TO_GR_COMPLEX_H
|
||||||
|
|
||||||
|
#include "gnss_block_interface.h"
|
||||||
|
#include <gnuradio/sync_block.h>
|
||||||
|
|
||||||
|
/** \addtogroup Data_Type
|
||||||
|
* \{ */
|
||||||
|
/** \addtogroup data_type_gnuradio_blocks
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
|
||||||
|
class cshort_to_gr_complex;
|
||||||
|
|
||||||
|
using cshort_to_gr_complex_sptr = gnss_shared_ptr<cshort_to_gr_complex>;
|
||||||
|
|
||||||
|
cshort_to_gr_complex_sptr make_cshort_to_gr_complex();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief This class adapts a short (16-bits) interleaved sample stream
|
||||||
|
* into a std::complex<float> stream
|
||||||
|
*/
|
||||||
|
class cshort_to_gr_complex : public gr::sync_block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int work(int noutput_items,
|
||||||
|
gr_vector_const_void_star &input_items,
|
||||||
|
gr_vector_void_star &output_items);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend cshort_to_gr_complex_sptr make_cshort_to_gr_complex();
|
||||||
|
cshort_to_gr_complex();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
/** \} */
|
||||||
|
#endif // GNSS_SDR_CSHORT_TO_GR_COMPLEX_H
|
@ -36,6 +36,7 @@
|
|||||||
#include "byte_to_short.h"
|
#include "byte_to_short.h"
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
#include "configuration_interface.h"
|
#include "configuration_interface.h"
|
||||||
|
#include "cshort_to_grcomplex.h"
|
||||||
#include "direct_resampler_conditioner.h"
|
#include "direct_resampler_conditioner.h"
|
||||||
#include "fifo_signal_source.h"
|
#include "fifo_signal_source.h"
|
||||||
#include "file_signal_source.h"
|
#include "file_signal_source.h"
|
||||||
@ -919,6 +920,12 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock(
|
|||||||
out_streams);
|
out_streams);
|
||||||
block = std::move(block_);
|
block = std::move(block_);
|
||||||
}
|
}
|
||||||
|
else if (implementation == "Cshort_To_Gr_Complex")
|
||||||
|
{
|
||||||
|
std::unique_ptr<GNSSBlockInterface> block_ = std::make_unique<CshortToGrComplex>(configuration, role, in_streams,
|
||||||
|
out_streams);
|
||||||
|
block = std::move(block_);
|
||||||
|
}
|
||||||
|
|
||||||
// INPUT FILTER ------------------------------------------------------------
|
// INPUT FILTER ------------------------------------------------------------
|
||||||
else if (implementation == "Fir_Filter")
|
else if (implementation == "Fir_Filter")
|
||||||
|
Loading…
Reference in New Issue
Block a user