mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 12:40:35 +00:00
Adding IQ Swap options to UDP source
This commit is contained in:
parent
7865387df9
commit
189cded82a
@ -57,50 +57,62 @@ UDPSignalSource::UDPSignalSource(ConfigurationInterface* configuration,
|
||||
std::string default_address = "127.0.0.1";
|
||||
int default_port = 1234;
|
||||
|
||||
RF_channels_ = configuration->property(role + ".RF_channels", 2);
|
||||
RF_channels_ = configuration->property(role + ".RF_channels", 1);
|
||||
channels_in_udp_= configuration->property(role + ".channels_in_udp", 1);
|
||||
IQ_swap_= configuration->property(role + ".IQ_swap", false);
|
||||
|
||||
std::string default_sample_type = "cbyte";
|
||||
std::string sample_type = configuration->property(role + ".sample_type", default_sample_type);
|
||||
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
address_ = configuration->property(role + ".address", default_address);
|
||||
port_ = configuration->property(role + ".port", default_port);
|
||||
std::string address = configuration->property(role + ".address", default_address);
|
||||
int port = configuration->property(role + ".port", default_port);
|
||||
int payload_bytes = configuration->property(role + ".payload_bytes", 1024);
|
||||
|
||||
if (sample_type.compare("cbyte")==0)
|
||||
{
|
||||
std::cout<<"address_ "<<address_<<" port_ "<<port_<<" payload_bytes"<<payload_bytes<<std::endl;
|
||||
udp_gnss_rx_source_ = make_udp_gnss_rx_source(sizeof(char), address_, port_, payload_bytes, true);
|
||||
udp_gnss_rx_source_ = make_udp_gnss_rx_source(sizeof(char), address, port, payload_bytes, true);
|
||||
demux_=gr::blocks::deinterleave::make(sizeof(char),1);
|
||||
}else{
|
||||
std::cout<<"WARNING: Requested UDP sample type unsuported, setting sample type to cbyte\n";
|
||||
udp_gnss_rx_source_ = make_udp_gnss_rx_source(sizeof(char), address_, port_, payload_bytes, true);
|
||||
udp_gnss_rx_source_ = make_udp_gnss_rx_source(sizeof(char), address, port, payload_bytes, true);
|
||||
demux_=gr::blocks::deinterleave::make(sizeof(char),1);
|
||||
}
|
||||
|
||||
|
||||
//create I, Q -> gr_complex type conversion blocks
|
||||
for (int n = 0; n < (RF_channels_ * 2); n++)
|
||||
for (int n = 0; n < (channels_in_udp_ * 2); n++)
|
||||
{
|
||||
char_to_float.push_back(gr::blocks::char_to_float::make());
|
||||
char_to_float_.push_back(gr::blocks::char_to_float::make());
|
||||
}
|
||||
|
||||
for (int n = 0; n < RF_channels_; n++)
|
||||
for (int n = 0; n < channels_in_udp_; n++)
|
||||
{
|
||||
float_to_complex_.push_back(gr::blocks::float_to_complex::make());
|
||||
}
|
||||
|
||||
item_size_ = sizeof(gr_complex);
|
||||
if (channels_in_udp_>=RF_channels_)
|
||||
{
|
||||
for (int n = 0; n < (channels_in_udp_-RF_channels_); n++)
|
||||
{
|
||||
null_sinks_.push_back(gr::blocks::null_sink::make(sizeof(gr_complex)));
|
||||
}
|
||||
}else
|
||||
{
|
||||
std::cout<<"Configuration error: RF_channels<channels_in_use"<<std::endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//output item size is always gr_complex
|
||||
item_size_ = sizeof(gr_complex);
|
||||
if (dump_)
|
||||
{
|
||||
file_sink_dbg_=gr::blocks::file_sink::make(sizeof(char), "debug.dat");
|
||||
|
||||
for (int n = 0; n < RF_channels_; n++)
|
||||
for (int n = 0; n < channels_in_udp_; n++)
|
||||
{
|
||||
DLOG(INFO) << "Dumping output into file " << (dump_filename_+"ch"+std::to_string(n));
|
||||
file_sink_.push_back(gr::blocks::file_sink::make(item_size_, (dump_filename_+"ch"+std::to_string(n)).c_str()));
|
||||
DLOG(INFO) << "Dumping output into file " << (dump_filename_+"c_h"+std::to_string(n)+".bin");
|
||||
file_sink_.push_back(gr::blocks::file_sink::make(item_size_, (dump_filename_+"_ch"+std::to_string(n)+".bin").c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -113,23 +125,39 @@ void UDPSignalSource::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
top_block->connect(udp_gnss_rx_source_,0, demux_,0);
|
||||
DLOG(INFO)<<"connected udp_source to demux"<<std::endl;
|
||||
for (int n = 0; n < (RF_channels_ * 2); n++)
|
||||
for (int n = 0; n < (channels_in_udp_ * 2); n++)
|
||||
{
|
||||
|
||||
top_block->connect(demux_, n, char_to_float.at(n), 0);
|
||||
top_block->connect(demux_, n, char_to_float_.at(n), 0);
|
||||
DLOG(INFO) << "connected demux to char_to_float CH" << n;
|
||||
}
|
||||
for (int n = 0; n < RF_channels_; n++)
|
||||
for (int n = 0; n < channels_in_udp_; n++)
|
||||
{
|
||||
top_block->connect(char_to_float.at(n * 2), 0, float_to_complex_.at(n), 0);
|
||||
top_block->connect(char_to_float.at(n * 2 + 1), 0, float_to_complex_.at(n), 1);
|
||||
if (!IQ_swap_)
|
||||
{
|
||||
top_block->connect(char_to_float_.at(n * 2), 0, float_to_complex_.at(n), 0);
|
||||
top_block->connect(char_to_float_.at(n * 2 + 1), 0, float_to_complex_.at(n), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->connect(char_to_float_.at(n * 2), 0, float_to_complex_.at(n), 1);
|
||||
top_block->connect(char_to_float_.at(n * 2 + 1), 0, float_to_complex_.at(n), 0);
|
||||
}
|
||||
DLOG(INFO) << "connected char_to_float to float_to_complex_ CH" << n;
|
||||
}
|
||||
|
||||
//connect null sinks to unused streams
|
||||
if (channels_in_udp_>RF_channels_)
|
||||
{
|
||||
for (int n = 0; n < (channels_in_udp_-RF_channels_); n++)
|
||||
{
|
||||
top_block->connect(float_to_complex_.at(RF_channels_+n),0,null_sinks_.at(n),0);
|
||||
}
|
||||
}
|
||||
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(udp_gnss_rx_source_,0, file_sink_dbg_,0);
|
||||
for (int n = 0; n < RF_channels_; n++)
|
||||
for (int n = 0; n < channels_in_udp_; n++)
|
||||
{
|
||||
top_block->connect(float_to_complex_.at(n), 0, file_sink_.at(n), 0);
|
||||
DLOG(INFO) << "connected source to file sink";
|
||||
@ -141,22 +169,39 @@ void UDPSignalSource::connect(gr::top_block_sptr top_block)
|
||||
void UDPSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
|
||||
for (int n = 0; n < (RF_channels_ * 2); n++)
|
||||
for (int n = 0; n < (channels_in_udp_ * 2); n++)
|
||||
{
|
||||
top_block->disconnect(demux_, n, char_to_float.at(n), 0);
|
||||
top_block->disconnect(demux_, n, char_to_float_.at(n), 0);
|
||||
DLOG(INFO) << "disconnect demux to char_to_float CH" << n;
|
||||
}
|
||||
for (int n = 0; n < RF_channels_; n++)
|
||||
for (int n = 0; n < channels_in_udp_; n++)
|
||||
{
|
||||
top_block->disconnect(char_to_float.at(n * 2), 0, float_to_complex_.at(n), 0);
|
||||
top_block->disconnect(char_to_float.at(n * 2 + 1), 0, float_to_complex_.at(n), 1);
|
||||
if (!IQ_swap_)
|
||||
{
|
||||
top_block->disconnect(char_to_float_.at(n * 2), 0, float_to_complex_.at(n), 0);
|
||||
top_block->disconnect(char_to_float_.at(n * 2 + 1), 0, float_to_complex_.at(n), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_block->disconnect(char_to_float_.at(n * 2), 0, float_to_complex_.at(n), 1);
|
||||
top_block->disconnect(char_to_float_.at(n * 2 + 1), 0, float_to_complex_.at(n), 0);
|
||||
}
|
||||
DLOG(INFO) << "disconnect char_to_float to float_to_complex_ CH" << n;
|
||||
}
|
||||
|
||||
//disconnect null sinks to unused streams
|
||||
if (channels_in_udp_>RF_channels_)
|
||||
{
|
||||
for (int n = 0; n < (channels_in_udp_-RF_channels_); n++)
|
||||
{
|
||||
top_block->disconnect(float_to_complex_.at(RF_channels_+n),0,null_sinks_.at(n),0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(udp_gnss_rx_source_,0, file_sink_dbg_,0);
|
||||
for (int n = 0; n < RF_channels_; n++)
|
||||
for (int n = 0; n < channels_in_udp_; n++)
|
||||
{
|
||||
top_block->disconnect(float_to_complex_.at(n), 0, file_sink_.at(n), 0);
|
||||
DLOG(INFO) << "disconnected source to file sink";
|
||||
|
@ -37,8 +37,8 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include <gnuradio/blocks/char_to_float.h>
|
||||
//#include <gnuradio/blocks/udp_source.h>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include <gnuradio/blocks/null_sink.h>
|
||||
#include <gnuradio/blocks/deinterleave.h>
|
||||
#include <gnuradio/blocks/float_to_complex.h>
|
||||
#include <stdexcept>
|
||||
@ -88,25 +88,22 @@ public:
|
||||
private:
|
||||
std::string role_;
|
||||
|
||||
// UDP settings
|
||||
std::string address_;
|
||||
int port_;
|
||||
bool IQ_swap_;
|
||||
int RF_channels_;
|
||||
|
||||
int channels_in_udp_;
|
||||
unsigned int in_stream_;
|
||||
unsigned int out_stream_;
|
||||
|
||||
|
||||
std::string item_type_;
|
||||
size_t item_size_;
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
std::vector<boost::shared_ptr<gr::block>> char_to_float;
|
||||
std::vector<boost::shared_ptr<gr::block>> char_to_float_;
|
||||
std::vector<boost::shared_ptr<gr::block>> float_to_complex_;
|
||||
std::vector<boost::shared_ptr<gr::block>> null_sinks_;
|
||||
|
||||
udp_gnss_rx_source_sptr udp_gnss_rx_source_;
|
||||
gr::blocks::deinterleave::sptr demux_;
|
||||
gr::blocks::file_sink::sptr file_sink_dbg_;
|
||||
std::vector<boost::shared_ptr<gr::block>> file_sink_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user