Adding SPIR file data source, by Fran Fabra

This commit is contained in:
Carles Fernandez 2015-01-14 17:26:41 +01:00
parent dcb6ed7c50
commit 056158e198
8 changed files with 958 additions and 0 deletions

View File

@ -47,6 +47,7 @@ Damian Miralles dmiralles2009@gmail.com Developer
Andres Cecilia Luque a.cecilia.luque@gmail.com Developer
Leonardo Tonetto tonetto.dev@gmail.com Contributor
Anthony Arnold anthony.arnold@uqconnect.edu.au Contributor
Fran Fabra fabra@ice.csic.es Contributor
Ignacio Paniego ignacio.paniego@gmail.com Web design
Eva Puchol eva.puchol@gmail.com Web developer
Carlos Paniego carpanie@hotmail.com Artwork

View File

@ -0,0 +1,343 @@
; Default configuration file
; You can define your own receiver and invoke it by doing
; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf
;
[GNSS-SDR]
;######### GLOBAL OPTIONS ##################
;internal_fs_hz: Internal signal sampling frequency after the signal conditioning stage [Hz].
GNSS-SDR.internal_fs_hz=4000000
;######### CONTROL_THREAD CONFIG ############
ControlThread.wait_for_flowgraph=false
;######### SIGNAL_SOURCE CONFIG ############
;#implementation: Use [File_Signal_Source] or [UHD_Signal_Source] or [GN3S_Signal_Source] (experimental)
SignalSource.implementation=Spir_File_Signal_Source
;#filename: path to file with the captured GNSS signal samples to be processed
SignalSource.filename=/media/fabra/dd44068b-f808-4164-834c-35b550037514/CTTC/spir_file_20secs.dat
;SignalSource.filename=/Users/carlesfernandez/Documents/workspace/code2/trunk/data/20Secs/20Secs_L1.dat
;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
SignalSource.item_type=int
;#sampling_frequency: Original Signal sampling frequency in [Hz]
SignalSource.sampling_frequency=80000000
;#freq: RF front-end center frequency in [Hz]
SignalSource.freq=1575420000
;#gain: Front-end Gain in [dB]
SignalSource.gain=60
;#subdevice: UHD subdevice specification (for USRP1 use A:0 or B:0)
SignalSource.subdevice=B:0
;#samples: Number of samples to be processed. Notice that 0 indicates the entire file.
SignalSource.samples=0
;#repeat: Repeat the processing file. Disable this option in this version
SignalSource.repeat=false
;#dump: Dump the Signal source data to a file. Disable this option in this version
SignalSource.dump=false
SignalSource.dump_filename=../data/signal_source.dat
;#enable_throttle_control: Enabling this option tells the signal source to keep the delay between samples in post processing.
; it helps to not overload the CPU, but the processing time will be longer.
SignalSource.enable_throttle_control=false
;######### SIGNAL_CONDITIONER CONFIG ############
;## It holds blocks to change data type, filter and resample input data.
;#implementation: Use [Pass_Through] or [Signal_Conditioner]
;#[Pass_Through] disables this block and the [DataTypeAdapter], [InputFilter] and [Resampler] blocks
;#[Signal_Conditioner] enables this block. Then you have to configure [DataTypeAdapter], [InputFilter] and [Resampler] blocks
SignalConditioner.implementation=Signal_Conditioner
;######### DATA_TYPE_ADAPTER CONFIG ############
;## Changes the type of input data. Please disable it in this version.
;#implementation: [Pass_Through] disables this block
DataTypeAdapter.implementation=Pass_Through
DataTypeAdapter.item_type=float
;######### INPUT_FILTER CONFIG ############
;## Filter the input data. Can be combined with frequency translation for IF signals
;#implementation: Use [Pass_Through] or [Fir_Filter] or [Freq_Xlating_Fir_Filter]
;#[Pass_Through] disables this block
;#[Fir_Filter] enables a FIR Filter
;#[Freq_Xlating_Fir_Filter] enables FIR filter and a composite frequency translation that shifts IF down to zero Hz.
;InputFilter.implementation=Fir_Filter
InputFilter.implementation=Freq_Xlating_Fir_Filter
;InputFilter.implementation=Pass_Through
;#dump: Dump the filtered data to a file.
InputFilter.dump=false
;#dump_filename: Log path and filename.
InputFilter.dump_filename=../data/input_filter.dat
;#The following options are used in the filter design of Fir_Filter and Freq_Xlating_Fir_Filter implementation.
;#These options are based on parameters of gnuradio's function: gr_remez.
;#These function calculates the optimal (in the Chebyshev/minimax sense) FIR filter inpulse reponse given a set of band edges, the desired reponse on those bands, and the weight given to the error in those bands.
;#input_item_type: Type and resolution for input signal samples. Use only gr_complex in this version.
InputFilter.input_item_type=float
;#outut_item_type: Type and resolution for output filtered signal samples. Use only gr_complex in this version.
InputFilter.output_item_type=gr_complex
;#taps_item_type: Type and resolution for the taps of the filter. Use only float in this version.
InputFilter.taps_item_type=float
;#number_of_taps: Number of taps in the filter. Increasing this parameter increases the processing time
InputFilter.number_of_taps=5
;#number_of _bands: Number of frequency bands in the filter.
InputFilter.number_of_bands=2
;#bands: frequency at the band edges [ b1 e1 b2 e2 b3 e3 ...].
;#Frequency is in the range [0, 1], with 1 being the Nyquist frequency (Fs/2)
;#The number of band_begin and band_end elements must match the number of bands
InputFilter.band1_begin=0.0
InputFilter.band1_end=0.45
InputFilter.band2_begin=0.55
InputFilter.band2_end=1.0
;#ampl: desired amplitude at the band edges [ a(b1) a(e1) a(b2) a(e2) ...].
;#The number of ampl_begin and ampl_end elements must match the number of bands
InputFilter.ampl1_begin=1.0
InputFilter.ampl1_end=1.0
InputFilter.ampl2_begin=0.0
InputFilter.ampl2_end=0.0
;#band_error: weighting applied to each band (usually 1).
;#The number of band_error elements must match the number of bands
InputFilter.band1_error=1.0
InputFilter.band2_error=1.0
;#filter_type: one of "bandpass", "hilbert" or "differentiator"
InputFilter.filter_type=bandpass
;#grid_density: determines how accurately the filter will be constructed.
;The minimum value is 16; higher values are slower to compute the filter.
InputFilter.grid_density=16
;#The following options are used only in Freq_Xlating_Fir_Filter implementation.
;#InputFilter.IF is the intermediate frequency (in Hz) shifted down to zero Hz
InputFilter.sampling_frequency=80000000
InputFilter.IF=10164
InputFilter.decimation_factor=20
;######### RESAMPLER CONFIG ############
;## Resamples the input data.
;#implementation: Use [Pass_Through] or [Direct_Resampler]
;#[Pass_Through] disables this block
;#[Direct_Resampler] enables a resampler that implements a nearest neigbourhood interpolation
;Resampler.implementation=Direct_Resampler
Resampler.implementation=Pass_Through
;#dump: Dump the resamplered data to a file.
Resampler.dump=false
;#dump_filename: Log path and filename.
Resampler.dump_filename=../data/resampler.dat
;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
Resampler.item_type=gr_complex
;#sample_freq_in: the sample frequency of the input signal
Resampler.sample_freq_in=80000000
;#sample_freq_out: the desired sample frequency of the output signal
Resampler.sample_freq_out=4000000
;######### CHANNELS GLOBAL CONFIG ############
;#count: Number of available GPS satellite channels.
Channels_GPS.count=10
;#count: Number of available Galileo satellite channels.
Channels_Galileo.count=0
;#in_acquisition: Number of channels simultaneously acquiring
Channels.in_acquisition=1
;#system: GPS, GLONASS, GALILEO, SBAS or COMPASS
;#if the option is disabled by default is assigned GPS
Channel.system=GPS
;#signal:
;# "1C" GPS L1 C/A
;#if the option is disabled by default is assigned "1C" GPS L1 C/A
Channel.signal=1C
;Galileo FM3 -> PRN 19
;Galileo FM4 -> PRN 20
;######### CHANNEL 0 CONFIG ############
;Channel0.system=Galileo
;Channel0.signal=1B
;#satellite: Satellite PRN ID for this channel. Disable this option to random search
;Channel0.satellite=20
;######### CHANNEL 1 CONFIG ############
;Channel1.system=Galileo
;Channel1.signal=1B
;Channel1.satellite=12
;######### CHANNEL 2 CONFIG ############
;Channel2.system=Galileo
;Channel2.signal=1B
;#satellite: Satellite PRN ID for this channel. Disable this option to random search
;Channel2.satellite=11
;######### CHANNEL 3 CONFIG ############
;Channel3.system=Galileo
;Channel3.signal=1B
;Channel3.satellite=19
;######### ACQUISITION GLOBAL CONFIG ############
;#dump: Enable or disable the acquisition internal data file logging [true] or [false]
Acquisition_GPS.dump=false
;#filename: Log path and filename
Acquisition_GPS.dump_filename=./acq_dump.dat
;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
Acquisition_GPS.item_type=gr_complex
;#if: Signal intermediate frequency in [Hz]
Acquisition_GPS.if=0
;#sampled_ms: Signal block duration for the acquisition signal detection [ms]
Acquisition_GPS.sampled_ms=1
;#implementation: Acquisition algorithm selection for this channel: [GPS_L1_CA_PCPS_Acquisition] or [Galileo_E1_PCPS_Ambiguous_Acquisition]
Acquisition_GPS.implementation=GPS_L1_CA_PCPS_Acquisition_Fine_Doppler
;#threshold: Acquisition threshold
Acquisition_GPS.threshold=0.005
;#pfa: Acquisition false alarm probability. This option overrides the threshold option. Only use with implementations: [GPS_L1_CA_PCPS_Acquisition] or [Galileo_E1_PCPS_Ambiguous_Acquisition]
;Acquisition_GPS.pfa=0.0001
;#doppler_max: Maximum expected Doppler shift [Hz]
Acquisition_GPS.doppler_max=10000
;#doppler_max: Maximum expected Doppler shift [Hz]
Acquisition_GPS.doppler_min=-10000
;#doppler_step Doppler step in the grid search [Hz]
Acquisition_GPS.doppler_step=500
;#maximum dwells
Acquisition_GPS.max_dwells=5
;######### ACQUISITION CHANNELS CONFIG ######
;######### ACQUISITION CH 0 CONFIG ############
;#repeat_satellite: Use only jointly with the satellite PRN ID option. The default value is false
;Acquisition0.repeat_satellite = true
;Acquisition1.repeat_satellite = true
;Acquisition2.repeat_satellite = true
;Acquisition3.repeat_satellite = true
;#cboc: Only for [Galileo_E1_PCPS_Ambiguous_Acquisition]. This option allows you to choose between acquiring with CBOC signal [true] or sinboc(1,1) signal [false].
;#Use only if GNSS-SDR.internal_fs_hz is greater than or equal to 6138000
Acquisition0.cboc=false
;######### ACQUISITION CH 1 CONFIG ############
Acquisition1.cboc=false
;######### TRACKING GLOBAL CONFIG ############
;#implementation: Selected tracking algorithm: [GPS_L1_CA_DLL_PLL_Tracking] or [GPS_L1_CA_DLL_FLL_PLL_Tracking] or [GPS_L1_CA_TCP_CONNECTOR_Tracking] or [Galileo_E1_DLL_PLL_VEML_Tracking]
Tracking_GPS.implementation=GPS_L1_CA_DLL_PLL_Tracking
;#item_type: Type and resolution for each of the signal samples. Use only [gr_complex] in this version.
Tracking_GPS.item_type=gr_complex
;#sampling_frequency: Signal Intermediate Frequency in [Hz]
Tracking_GPS.if=0
;#dump: Enable or disable the Tracking internal binary data file logging [true] or [false]
Tracking_GPS.dump=false
;#dump_filename: Log path and filename. Notice that the tracking channel will add "x.dat" where x is the channel number.
Tracking_GPS.dump_filename=../data/epl_tracking_ch_
;#pll_bw_hz: PLL loop filter bandwidth [Hz]
Tracking_GPS.pll_bw_hz=20.0;
;#dll_bw_hz: DLL loop filter bandwidth [Hz]
Tracking_GPS.dll_bw_hz=2.0;
;#fll_bw_hz: FLL loop filter bandwidth [Hz]
Tracking_GPS.fll_bw_hz=10.0;
;#order: PLL/DLL loop filter order [2] or [3]
Tracking_GPS.order=3;
;######### TELEMETRY DECODER GPS CONFIG ############
;#implementation: Use [GPS_L1_CA_Telemetry_Decoder] for GPS L1 C/A
TelemetryDecoder_GPS.implementation=GPS_L1_CA_Telemetry_Decoder
TelemetryDecoder_GPS.dump=false
;#decimation factor
TelemetryDecoder_GPS.decimation_factor=1;
;######### OBSERVABLES CONFIG ############
;#implementation: Use [GPS_L1_CA_Observables] for GPS L1 C/A.
Observables.implementation=GPS_L1_CA_Observables
;#dump: Enable or disable the Observables internal binary data file logging [true] or [false]
Observables.dump=false
;#dump_filename: Log path and filename.
Observables.dump_filename=./observables.dat
;######### PVT CONFIG ############
;#implementation: Position Velocity and Time (PVT) implementation algorithm: Use [GPS_L1_CA_PVT] in this version.
PVT.implementation=GPS_L1_CA_PVT
;#averaging_depth: Number of PVT observations in the moving average algorithm
PVT.averaging_depth=100
;#flag_average: Enables the PVT averaging between output intervals (arithmetic mean) [true] or [false]
PVT.flag_averaging=true
;#output_rate_ms: Period between two PVT outputs. Notice that the minimum period is equal to the tracking integration time (for GPS CA L1 is 1ms) [ms]
PVT.output_rate_ms=500
;#display_rate_ms: Position console print (std::out) interval [ms]. Notice that output_rate_ms<=display_rate_ms.
PVT.display_rate_ms=500
;# RINEX, KML, and NMEA output configuration
;#dump_filename: Log path and filename without extension. Notice that PVT will add ".dat" to the binary dump and ".kml" to GoogleEarth dump.
PVT.dump_filename=./PVT
;#nmea_dump_filename: NMEA log path and filename
PVT.nmea_dump_filename=./gnss_sdr_pvt.nmea;
;#flag_nmea_tty_port: Enable or disable the NMEA log to a serial TTY port (Can be used with real hardware or virtual one)
PVT.flag_nmea_tty_port=true;
;#nmea_dump_devname: serial device descriptor for NMEA logging
PVT.nmea_dump_devname=/dev/pts/4
;#dump: Enable or disable the PVT internal binary data file logging [true] or [false]
PVT.dump=false
;######### OUTPUT_FILTER CONFIG ############
;# Receiver output filter: Leave this block disabled in this version
OutputFilter.implementation=Null_Sink_Output_Filter
OutputFilter.filename=data/gnss-sdr.dat
OutputFilter.item_type=gr_complex

View File

@ -112,6 +112,7 @@ endif(ENABLE_UHD)
set(SIGNAL_SOURCE_ADAPTER_SOURCES file_signal_source.cc
gen_signal_source.cc
nsr_file_signal_source.cc
spir_file_signal_source.cc
${OPT_DRIVER_SOURCES}
)

View File

@ -0,0 +1,331 @@
/*!
* \file spir_file_signal_source.cc
* \brief Implementation of a class that reads signals samples from a SPIR file
* and adapts it to a SignalSourceInterface.
* \author Fran Fabra, 2014 fabra(at)ice.csic.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is not 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 "spir_file_signal_source.h"
#include <cstdlib>
#include <exception>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include "gnss_sdr_valve.h"
#include "configuration_interface.h"
using google::LogMessage;
DEFINE_string(spir_signal_source, "-",
"If defined, path to the file containing the NSR (byte to 2-bit packed) signal samples (overrides the configuration file)");
SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration,
std::string role, unsigned int in_streams, unsigned int out_streams,
boost::shared_ptr<gr::msg_queue> queue) :
role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue)
{
std::string default_filename = "../data/my_capture.dat";
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);
filename_ = configuration->property(role + ".filename", default_filename);
// override value with commandline flag, if present
if (FLAGS_spir_signal_source.compare("-") != 0) filename_= FLAGS_spir_signal_source;
item_type_ = configuration->property(role + ".item_type", default_item_type);
repeat_ = configuration->property(role + ".repeat", false);
dump_ = configuration->property(role + ".dump", false);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false);
if (item_type_.compare("int") == 0)
{
item_size_ = sizeof(int);
}
else
{
LOG(WARNING) << item_type_ << " unrecognized item type. Using int.";
item_size_ = sizeof(int);
}
try
{
file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_);
unpack_intspir_ = make_unpack_intspir_1bit_samples();
}
catch (const std::exception &e)
{
std::cerr
<< "The receiver was configured to work with a file signal source "
<< std::endl
<< "but the specified file is unreachable by GNSS-SDR."
<< std::endl
<< "Please modify your configuration file"
<< std::endl
<< "and point SignalSource.filename to a valid raw data file. Then:"
<< std::endl
<< "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf"
<< std::endl
<< "Examples of configuration files available at:"
<< std::endl
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/"
<< std::endl;
LOG(WARNING) << "file_signal_source: Unable to open the samples file "
<< filename_.c_str() << ", exiting the program.";
throw(e);
}
DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")";
if (samples_ == 0) // read all file
{
/*!
* BUG workaround: The GNU Radio file source does not stop the receiver after reaching the End of File.
* A possible solution is to compute the file length in samples using file size, excluding the last 100 milliseconds, and enable always the
* valve block
*/
std::ifstream file (filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
std::ifstream::pos_type size;
if (file.is_open())
{
size = file.tellg();
LOG(INFO) << "Total samples in the file= " << floor((double)size / (double)item_size());
}
else
{
std::cout << "file_signal_source: Unable to open the samples file " << filename_.c_str() << std::endl;
LOG(ERROR) << "file_signal_source: Unable to open the samples file " << filename_.c_str();
}
std::cout << std::setprecision(16);
std::cout << "Processing file " << filename_ << ", which contains " << (double)size << " [bytes]" << std::endl;
if (size > 0)
{
int sample_packet_factor = 1; // 1 int -> 1 complex sample (I&Q from 1 channel)
samples_ = floor((double)size / (double)item_size())*sample_packet_factor;
samples_ = samples_- ceil(0.002 * (double)sampling_frequency_); //process all the samples available in the file excluding the last 2 ms
}
}
CHECK(samples_ > 0) << "File does not contain enough samples to process.";
double signal_duration_s;
signal_duration_s = (double)samples_ * ( 1 /(double)sampling_frequency_);
LOG(INFO) << "Total number samples to be processed= " << samples_ << " GNSS signal duration= " << signal_duration_s << " [s]";
std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl;
valve_ = gnss_sdr_make_valve(sizeof(float), samples_, queue_);
DLOG(INFO) << "valve(" << valve_->unique_id() << ")";
if (dump_)
{
//sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str());
sink_ = gr::blocks::file_sink::make(sizeof(float), dump_filename_.c_str());
DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")";
}
if (enable_throttle_control_)
{
throttle_ = gr::blocks::throttle::make(sizeof(float), sampling_frequency_);
}
DLOG(INFO) << "File source filename " << filename_;
DLOG(INFO) << "Samples " << samples_;
DLOG(INFO) << "Sampling frequency " << sampling_frequency_;
DLOG(INFO) << "Item type " << item_type_;
DLOG(INFO) << "Item size " << item_size_;
DLOG(INFO) << "Repeat " << repeat_;
DLOG(INFO) << "Dump " << dump_;
DLOG(INFO) << "Dump filename " << dump_filename_;
}
SpirFileSignalSource::~SpirFileSignalSource()
{}
void SpirFileSignalSource::connect(gr::top_block_sptr top_block)
{
if (samples_ > 0)
{
if (enable_throttle_control_ == true)
{
top_block->connect(file_source_, 0, unpack_intspir_, 0);
top_block->connect(unpack_intspir_, 0,throttle_,0);
DLOG(INFO) << "connected file source to throttle";
top_block->connect(throttle_, 0, valve_, 0);
DLOG(INFO) << "connected throttle to valve";
if (dump_)
{
top_block->connect(valve_, 0, sink_, 0);
DLOG(INFO) << "connected valve to file sink";
}
}
else
{
top_block->connect(file_source_, 0, unpack_intspir_, 0);
top_block->connect(unpack_intspir_, 0,valve_,0);
DLOG(INFO) << "connected file source to valve";
if (dump_)
{
top_block->connect(valve_, 0, sink_, 0);
DLOG(INFO) << "connected valve to file sink";
}
}
}
else
{
if (enable_throttle_control_ == true)
{
top_block->connect(file_source_, 0, unpack_intspir_, 0);
top_block->connect(unpack_intspir_, 0,throttle_,0);
DLOG(INFO) << "connected file source to throttle";
if (dump_)
{
top_block->connect(throttle_, 0, sink_, 0);
DLOG(INFO) << "connected file source to sink";
}
}
else
{
if (dump_)
{
top_block->connect(file_source_, 0, unpack_intspir_, 0);
top_block->connect(unpack_intspir_, 0, sink_, 0);
DLOG(INFO) << "connected file source to sink";
}
}
}
}
void SpirFileSignalSource::disconnect(gr::top_block_sptr top_block)
{
if (samples_ > 0)
{
if (enable_throttle_control_ == true)
{
top_block->disconnect(file_source_, 0, unpack_intspir_, 0);
DLOG(INFO) << "disconnected file source to unpack_intspir_";
top_block->connect(unpack_intspir_, 0,throttle_,0);
DLOG(INFO) << "disconnected unpack_intspir_ to throttle_";
top_block->disconnect(throttle_, 0, valve_, 0);
DLOG(INFO) << "disconnected throttle to valve";
if (dump_)
{
top_block->disconnect(valve_, 0, sink_, 0);
DLOG(INFO) << "disconnected valve to file sink";
}
}
else
{
top_block->disconnect(file_source_, 0, unpack_intspir_, 0);
DLOG(INFO) << "disconnected file source to unpack_intspir_";
top_block->disconnect(unpack_intspir_, 0, valve_, 0);
DLOG(INFO) << "disconnected unpack_intspir_ to valve";
if (dump_)
{
top_block->disconnect(valve_, 0, sink_, 0);
DLOG(INFO) << "disconnected valve to file sink";
}
}
}
else
{
if (enable_throttle_control_ == true)
{
top_block->disconnect(file_source_, 0, unpack_intspir_, 0);
DLOG(INFO) << "disconnected file source to unpack_intspir_";
top_block->disconnect(unpack_intspir_, 0, throttle_, 0);
DLOG(INFO) << "disconnected unpack_intspir_ to throttle";
if (dump_)
{
top_block->disconnect(unpack_intspir_, 0, sink_, 0);
DLOG(INFO) << "disconnected funpack_intspir_ to sink";
}
}
else
{
if (dump_)
{
top_block->disconnect(file_source_, 0, unpack_intspir_, 0);
DLOG(INFO) << "disconnected file source to unpack_intspir_";
top_block->disconnect(unpack_intspir_, 0, sink_, 0);
DLOG(INFO) << "disconnected unpack_intspir_ to sink";
}
}
}
}
gr::basic_block_sptr SpirFileSignalSource::get_left_block()
{
LOG(WARNING) << "Left block of a signal source should not be retrieved";
//return gr_block_sptr();
return gr::blocks::file_source::sptr();
}
gr::basic_block_sptr SpirFileSignalSource::get_right_block()
{
if (samples_ > 0)
{
return valve_;
}
else
{
if (enable_throttle_control_ == true)
{
return throttle_;
}
else
{
return unpack_intspir_;
}
}
}

View File

@ -0,0 +1,122 @@
/*!
* \file spir_file_signal_source.h
* \brief Implementation of a class that reads signals samples from a SPIR file
* and adapts it to a SignalSourceInterface.
* \author Fran Fabra, 2014 fabra(at)ice.csic.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is not 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_SPIR_FILE_SIGNAL_SOURCE_H_
#define GNSS_SDR_SPIR_FILE_SIGNAL_SOURCE_H_
#include <string>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/blocks/file_sink.h>
#include <gnuradio/blocks/throttle.h>
#include <gnuradio/hier_block2.h>
#include <gnuradio/msg_queue.h>
#include "gnss_block_interface.h"
#include "unpack_intspir_1bit_samples.h"
class ConfigurationInterface;
/*!
* \brief Class that reads signals samples from a file
* and adapts it to a SignalSourceInterface
*/
class SpirFileSignalSource: public GNSSBlockInterface
{
public:
SpirFileSignalSource(ConfigurationInterface* configuration, std::string role,
unsigned int in_streams, unsigned int out_streams,
boost::shared_ptr<gr::msg_queue> queue);
virtual ~SpirFileSignalSource();
std::string role()
{
return role_;
}
/*!
* \brief Returns "Spir_File_Signal_Source".
*/
std::string implementation()
{
return "Spir_File_Signal_Source";
}
size_t item_size()
{
return item_size_;
}
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();
std::string filename()
{
return filename_;
}
std::string item_type()
{
return item_type_;
}
bool repeat()
{
return repeat_;
}
long sampling_frequency()
{
return sampling_frequency_;
}
long samples()
{
return samples_;
}
private:
unsigned long long samples_;
long sampling_frequency_;
std::string filename_;
std::string item_type_;
bool repeat_;
bool dump_;
std::string dump_filename_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_source::sptr file_source_;
unpack_intspir_1bit_samples_sptr unpack_intspir_;
boost::shared_ptr<gr::block> valve_;
gr::blocks::file_sink::sptr sink_;
gr::blocks::throttle::sptr throttle_;
boost::shared_ptr<gr::msg_queue> queue_;
size_t item_size_;
// Throttle control
bool enable_throttle_control_;
};
#endif /*GNSS_SDR_SPIR_FILE_SIGNAL_SOURCE_H_*/

View File

@ -0,0 +1,84 @@
/*!
* \file unpack_intspir_1bit_samples.cc
*
* \brief Unpacks SPIR int samples to NSR 1 bit samples
* \author Fran Fabra fabra (at) ice.csic.es
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is not 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 "unpack_intspir_1bit_samples.h"
#include <iostream>
#include <gnuradio/io_signature.h>
unpack_intspir_1bit_samples_sptr make_unpack_intspir_1bit_samples()
{
return unpack_intspir_1bit_samples_sptr(new unpack_intspir_1bit_samples());
}
unpack_intspir_1bit_samples::unpack_intspir_1bit_samples() : sync_interpolator("unpack_intspir_1bit_samples",
gr::io_signature::make(1, 1, sizeof(int)),
gr::io_signature::make(1, 1, sizeof(float)),
2)
{}
unpack_intspir_1bit_samples::~unpack_intspir_1bit_samples()
{}
int unpack_intspir_1bit_samples::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const signed int *in = (const signed int *)input_items[0];
float *out = (float*)output_items[0];
int n = 0;
int channel = 1;
for(int i = 0; i < noutput_items/2; i++)
{
// Read packed input sample (1 byte = 1 complex sample)
// For historical reasons, values are float versions of short int limits (32767)
signed int val = in[i];
if(((val >> ((channel - 1)*2)) & 1) == 1)
{
out[n++] = static_cast<float>(32767.0);
}
else
{
out[n++] = static_cast<float>(-32767.0);
}
if(((val >> (2*channel - 1)) & 1) == 1)
{
out[n++] = static_cast<float>(32767.0);
}
else
{
out[n++] = static_cast<float>(-32767.0);
}
}
return noutput_items;
}

View File

@ -0,0 +1,60 @@
/*!
* \file unpack_intspir_1bit_samples.h
*
* \brief Unpacks SPIR int samples to NSR 1 bit samples
* \author Fran Fabra fabra (at) ice.csic.es
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is not 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_UNPACK_INTSPIR_1BIT_SAMPLES_H
#define GNSS_SDR_UNPACK_INTSPIR_1BIT_SAMPLES_H
#include <gnuradio/sync_interpolator.h>
class unpack_intspir_1bit_samples;
typedef boost::shared_ptr<unpack_intspir_1bit_samples> unpack_intspir_1bit_samples_sptr;
unpack_intspir_1bit_samples_sptr make_unpack_intspir_1bit_samples();
/*!
* \brief This class implements conversion between byte packet samples to 2bit samples
* 1 byte = 4 2bit samples
*/
class unpack_intspir_1bit_samples: public gr::sync_interpolator
{
private:
friend unpack_intspir_1bit_samples_sptr
make_unpack_intspir_1bit_samples_sptr();
public:
unpack_intspir_1bit_samples();
~unpack_intspir_1bit_samples();
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif

View File

@ -45,6 +45,7 @@
#include "pass_through.h"
#include "file_signal_source.h"
#include "nsr_file_signal_source.h"
#include "spir_file_signal_source.h"
#include "null_sink_output_filter.h"
#include "file_output_filter.h"
#include "channel.h"
@ -384,6 +385,21 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock(
out_streams, queue));
block = std::move(block_);
}
catch (const std::exception &e)
{
std::cout << "GNSS-SDR program ended." << std::endl;
exit(1);
}
}
else if (implementation.compare("Spir_File_Signal_Source") == 0)
{
try
{
std::unique_ptr<GNSSBlockInterface> block_(new SpirFileSignalSource(configuration.get(), role, in_streams,
out_streams, queue));
block = std::move(block_);
}
catch (const std::exception &e)
{