mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-27 09:24:52 +00:00
Adding short int data type (IF)
This commit is contained in:
parent
59bfa75e01
commit
52f7fcee4c
@ -19,7 +19,8 @@
|
||||
|
||||
set(DATATYPE_ADAPTER_SOURCES
|
||||
ishort_to_complex.cc
|
||||
ibyte_to_complex.cc )
|
||||
ibyte_to_complex.cc
|
||||
byte_to_short.cc )
|
||||
|
||||
include_directories(
|
||||
$(CMAKE_CURRENT_SOURCE_DIR)
|
||||
|
109
src/algorithms/data_type_adapter/adapters/byte_to_short.cc
Normal file
109
src/algorithms/data_type_adapter/adapters/byte_to_short.cc
Normal file
@ -0,0 +1,109 @@
|
||||
/*!
|
||||
* \file byte_to_short.cc
|
||||
* \brief Adapts an 8-bits sample stream (IF) to a short int stream (IF)
|
||||
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2014 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "byte_to_short.h"
|
||||
#include <glog/logging.h>
|
||||
#include "configuration_interface.h"
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
ByteToShort::ByteToShort(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
config_(configuration), role_(role), in_streams_(in_streams),
|
||||
out_streams_(out_streams), queue_(queue)
|
||||
{
|
||||
|
||||
std::string default_input_item_type = "byte";
|
||||
std::string default_output_item_type = "short";
|
||||
std::string default_dump_filename = "../data/input_filter.dat";
|
||||
|
||||
DLOG(INFO) << "role " << role_;
|
||||
|
||||
input_item_type_ = config_->property(role_ + ".input_item_type",
|
||||
default_input_item_type);
|
||||
|
||||
dump_ = config_->property(role_ + ".dump", false);
|
||||
dump_filename_ = config_->property(role_ + ".dump_filename",
|
||||
default_dump_filename);
|
||||
|
||||
size_t item_size = sizeof(short);
|
||||
|
||||
gr_char_to_short_ = gr::blocks::char_to_short::make();
|
||||
|
||||
DLOG(INFO) << "data_type_adapter_(" << gr_char_to_short_->unique_id() << ")";
|
||||
|
||||
if (dump_)
|
||||
{
|
||||
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ByteToShort::~ByteToShort()
|
||||
{}
|
||||
|
||||
|
||||
void ByteToShort::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(gr_char_to_short_, 0, file_sink_, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DLOG(INFO) << "Nothing to connect internally";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ByteToShort::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(gr_char_to_short_, 0, file_sink_, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr ByteToShort::get_left_block()
|
||||
{
|
||||
return gr_char_to_short_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gr::basic_block_sptr ByteToShort::get_right_block()
|
||||
{
|
||||
return gr_char_to_short_;
|
||||
}
|
90
src/algorithms/data_type_adapter/adapters/byte_to_short.h
Normal file
90
src/algorithms/data_type_adapter/adapters/byte_to_short.h
Normal file
@ -0,0 +1,90 @@
|
||||
/*!
|
||||
* \file byte_to_short.h
|
||||
* \brief Adapts an 8-bits sample stream (IF) to a short int stream (IF)
|
||||
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2014 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef GNSS_SDR_BYTE_TO_SHORT_H_
|
||||
#define GNSS_SDR_BYTE_TO_SHORT_H_
|
||||
|
||||
#include <string>
|
||||
#include <gnuradio/blocks/char_to_short.h>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include "gnss_synchro.h"
|
||||
#include "gnss_block_interface.h"
|
||||
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
/*!
|
||||
* \brief Adapts an 8-bits sample stream (IF) to a short int stream (IF)
|
||||
*
|
||||
*/
|
||||
class ByteToShort: public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
ByteToShort(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams,
|
||||
unsigned int out_streams, boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~ByteToShort();
|
||||
|
||||
std::string role()
|
||||
{
|
||||
return role_;
|
||||
}
|
||||
//! Returns "ByteToShort"
|
||||
std::string implementation()
|
||||
{
|
||||
return "ByteToShort";
|
||||
}
|
||||
size_t item_size()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void connect(gr::top_block_sptr top_block);
|
||||
void disconnect(gr::top_block_sptr top_block);
|
||||
gr::basic_block_sptr get_left_block();
|
||||
gr::basic_block_sptr get_right_block();
|
||||
|
||||
private:
|
||||
gr::blocks::char_to_short::sptr gr_char_to_short_;
|
||||
ConfigurationInterface* config_;
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
std::string input_item_type_;
|
||||
std::string output_item_type_;
|
||||
std::string role_;
|
||||
unsigned int in_streams_;
|
||||
unsigned int out_streams_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
gr::blocks::file_sink::sptr file_sink_;
|
||||
};
|
||||
|
||||
#endif
|
@ -15,7 +15,7 @@
|
||||
* 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.
|
||||
* (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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* \file byte_to_complex.h
|
||||
* \file ibyte_to_complex.h
|
||||
* \brief Adapts an I/Q interleaved byte integer sample stream to a gr_complex (float) stream
|
||||
* \author Javier Arribas, jarribas(at)cttc.es
|
||||
*
|
||||
@ -15,7 +15,7 @@
|
||||
* 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.
|
||||
* (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
|
||||
@ -28,8 +28,8 @@
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef GNSS_SDR_BYTE_TO_COMPLEX_H_
|
||||
#define GNSS_SDR_BYTE_TO_COMPLEX_H_
|
||||
#ifndef GNSS_SDR_IBYTE_TO_COMPLEX_H_
|
||||
#define GNSS_SDR_IBYTE_TO_COMPLEX_H_
|
||||
|
||||
#include <string>
|
||||
#include <gnuradio/blocks/interleaved_short_to_complex.h>
|
||||
|
@ -65,6 +65,14 @@ FreqXlatingFirFilter::FreqXlatingFirFilter(ConfigurationInterface* configuration
|
||||
freq_xlating_fir_filter_fcf_ = gr::filter::freq_xlating_fir_filter_fcf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_);
|
||||
DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_fcf_->unique_id() << ")";
|
||||
}
|
||||
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0)
|
||||
&& (output_item_type_.compare("gr_complex") == 0))
|
||||
{
|
||||
item_size = sizeof(gr_complex);
|
||||
input_size_ = sizeof(short); //input
|
||||
freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_);
|
||||
DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_scf_->unique_id() << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(ERROR) << taps_item_type_ << " unknown input filter item type";
|
||||
@ -94,6 +102,10 @@ void FreqXlatingFirFilter::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
top_block->connect(freq_xlating_fir_filter_fcf_, 0, file_sink_, 0);
|
||||
}
|
||||
else if (input_size_ == sizeof(short))
|
||||
{
|
||||
top_block->connect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->connect(freq_xlating_fir_filter_ccf_, 0, file_sink_, 0);
|
||||
@ -115,6 +127,10 @@ void FreqXlatingFirFilter::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
top_block->disconnect(freq_xlating_fir_filter_fcf_, 0, file_sink_, 0);
|
||||
}
|
||||
else if (input_size_ == sizeof(short))
|
||||
{
|
||||
top_block->disconnect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->disconnect(freq_xlating_fir_filter_ccf_, 0, file_sink_, 0);
|
||||
@ -130,6 +146,10 @@ gr::basic_block_sptr FreqXlatingFirFilter::get_left_block()
|
||||
{
|
||||
return freq_xlating_fir_filter_fcf_;
|
||||
}
|
||||
else if (input_size_ == sizeof(short))
|
||||
{
|
||||
return freq_xlating_fir_filter_scf_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return freq_xlating_fir_filter_ccf_;
|
||||
@ -144,6 +164,10 @@ gr::basic_block_sptr FreqXlatingFirFilter::get_right_block()
|
||||
{
|
||||
return freq_xlating_fir_filter_fcf_;
|
||||
}
|
||||
else if (input_size_ == sizeof(short))
|
||||
{
|
||||
return freq_xlating_fir_filter_scf_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return freq_xlating_fir_filter_ccf_;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <vector>
|
||||
#include <gnuradio/filter/freq_xlating_fir_filter_ccf.h>
|
||||
#include <gnuradio/filter/freq_xlating_fir_filter_fcf.h>
|
||||
#include <gnuradio/filter/freq_xlating_fir_filter_scf.h>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include "gnss_synchro.h"
|
||||
@ -87,6 +88,7 @@ public:
|
||||
private:
|
||||
gr::filter::freq_xlating_fir_filter_ccf::sptr freq_xlating_fir_filter_ccf_;
|
||||
gr::filter::freq_xlating_fir_filter_fcf::sptr freq_xlating_fir_filter_fcf_;
|
||||
gr::filter::freq_xlating_fir_filter_scf::sptr freq_xlating_fir_filter_scf_;
|
||||
ConfigurationInterface* config_;
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
|
Loading…
Reference in New Issue
Block a user