diff --git a/conf/gnss-sdr_GPS_L1_two_bits_cpx.conf b/conf/gnss-sdr_GPS_L1_two_bits_cpx.conf new file mode 100644 index 000000000..bcb835f7c --- /dev/null +++ b/conf/gnss-sdr_GPS_L1_two_bits_cpx.conf @@ -0,0 +1,307 @@ +; Sample configuration file for IFEN SX-NSR software receiver front-end +; http://www.ifen.com/products/sx-scientific-gnss-solutions/nsr-software-receiver.html +; This sample configuration is able to process directly .sream binary files +; 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=3200000 + +;######### CONTROL_THREAD CONFIG ############ +ControlThread.wait_for_flowgraph=false + +;######### SUPL RRLP GPS assistance configuration ##### +GNSS-SDR.SUPL_gps_enabled=false +GNSS-SDR.SUPL_read_gps_assistance_xml=false +GNSS-SDR.SUPL_gps_ephemeris_server=supl.nokia.com +GNSS-SDR.SUPL_gps_ephemeris_port=7275 +GNSS-SDR.SUPL_gps_acquisition_server=supl.google.com +GNSS-SDR.SUPL_gps_acquisition_port=7275 +GNSS-SDR.SUPL_MCC=244 +GNSS-SDR.SUPL_MNS=5 +GNSS-SDR.SUPL_LAC=0x59e2 +GNSS-SDR.SUPL_CI=0x31b0 + +;######### SIGNAL_SOURCE CONFIG ############ +;#implementation: Use [File_Signal_Source] [Nsr_File_Signal_Source] or [UHD_Signal_Source] or [GN3S_Signal_Source] (experimental) +SignalSource.implementation=Two_Bit_Cpx_File_Signal_Source + +;#filename: path to file with the captured GNSS signal samples to be processed +SignalSource.filename=/datalogger/captures/ajith/test1_two_cpx_sig2_60.dat + +;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version. +SignalSource.item_type=byte + +;#sampling_frequency: Original Signal sampling frequency in [Hz] +SignalSource.sampling_frequency=19200000 + +;#freq: RF front-end center frequency in [Hz] +SignalSource.freq=1575420000 + +;#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=true + +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. +;#implementation: [Pass_Through] disables this block +DataTypeAdapter.implementation=Pass_Through +DataTypeAdapter.item_type=gr_complex + +;######### 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] +;#[Freq_Xlating_Fir_Filter] enables FIR filter and a composite frequency translation +;# that shifts IF down to zero Hz. + +InputFilter.implementation=Freq_Xlating_Fir_Filter + +;#dump: Dump the filtered data to a file. +InputFilter.dump=true + +;#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=gr_complex + +;#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 + +;# Original sampling frequency stored in the signal file +InputFilter.sampling_frequency=19200000 + +;#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.IF=-4024000 + +;# Decimation factor after the frequency tranaslating block +InputFilter.decimation_factor=6 + + +;######### 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=8000000 + +;#sample_freq_out: the desired sample frequency of the output signal +Resampler.sample_freq_out=2048000 + + +;######### CHANNELS GLOBAL CONFIG ############ +;#count: Number of available GPS satellite channels. +Channels_GPS.count=8 +;#count: Number of available Galileo satellite channels. +Channels_Galileo.count=0 +;#in_acquisition: Number of channels simultaneously acquiring for the whole receiver +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: +;#if the option is disabled by default is assigned "1C" GPS L1 C/A +Channel.signal=1C + + +;######### GPS ACQUISITION 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 +;#threshold: Acquisition threshold +Acquisition_GPS.threshold=0.0075 +;#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.01 +;#doppler_max: Maximum expected Doppler shift [Hz] +Acquisition_GPS.doppler_max=10000 +;#doppler_max: Doppler step in the grid search [Hz] +Acquisition_GPS.doppler_step=500 + +;######### ACQUISITION CHANNELS CONFIG ###### +;#The following options are specific to each channel and overwrite the generic options + + +;######### TRACKING GPS 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=45.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=false + +;#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=10 + +;#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=false; + +;#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 diff --git a/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_realtime_III_1b.conf b/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_realtime_III_1b.conf index ebaa60f0f..0177fef62 100644 --- a/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_realtime_III_1b.conf +++ b/conf/gnss-sdr_multichannel_GPS_L1_L2_Galileo_E1B_Flexiband_realtime_III_1b.conf @@ -271,7 +271,7 @@ Resampler2.implementation=Pass_Through ;######### CHANNELS GLOBAL CONFIG ############ ;#count: Number of available GPS satellite channels. Channels_1C.count=8 -Channels_1B.count=2 +Channels_1B.count=1 Channels_2S.count=8 ;#count: Number of available Galileo satellite channels. ;Channels_Galileo.count=0 @@ -314,8 +314,8 @@ Channel7.signal=1C Channel8.RF_channel_ID=0 Channel8.signal=1B -Channel9.RF_channel_ID=0 -Channel9.signal=1B +Channel9.RF_channel_ID=1 +Channel9.signal=2S Channel10.RF_channel_ID=1 Channel10.signal=2S @@ -338,9 +338,6 @@ Channel15.signal=2S Channel16.RF_channel_ID=1 Channel16.signal=2S -Channel17.RF_channel_ID=1 -Channel17.signal=2S - ;######### SPECIFIC CHANNELS CONFIG ###### ;#The following options are specific to each channel and overwrite the generic options ;######### ACQUISITION GLOBAL CONFIG ############ @@ -450,10 +447,10 @@ Tracking_1B.item_type=gr_complex Tracking_1B.if=0 ;#dump: Enable or disable the Tracking internal binary data file logging [true] or [false] -Tracking_1B.dump=false +Tracking_1B.dump=true ;#dump_filename: Log path and filename. Notice that the tracking channel will add "x.dat" where x is the channel number. -Tracking_1B.dump_filename=../data/veml_tracking_ch_ +Tracking_1B.dump_filename=./veml_tracking_ch_ ;#pll_bw_hz: PLL loop filter bandwidth [Hz] Tracking_1B.pll_bw_hz=15.0; @@ -496,11 +493,11 @@ TelemetryDecoder_1B.decimation_factor=5; ;######### OBSERVABLES CONFIG ############ -;#implementation: Use [GPS_L1_CA_Observables] for GPS L1 C/A.Mixed_Observables -Observables.implementation=GPS_L1_CA_Observables +;#implementation: Use [GPS_L1_CA_Observables] for GPS L1 C/A. +Observables.implementation=Mixed_Observables ;#dump: Enable or disable the Observables internal binary data file logging [true] or [false] -Observables.dump=false +Observables.dump=true ;#dump_filename: Log path and filename. Observables.dump_filename=./observables.dat diff --git a/src/algorithms/observables/gnuradio_blocks/mixed_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/mixed_observables_cc.cc index 1fb8dff50..96b3203d0 100644 --- a/src/algorithms/observables/gnuradio_blocks/mixed_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/mixed_observables_cc.cc @@ -137,38 +137,38 @@ int mixed_observables_cc::general_work (int noutput_items, gr_vector_int &ninput /* * 2. Compute RAW pseudoranges using COMMON RECEPTION TIME algorithm. Use only the valid channels (channels that are tracking a satellite) */ - if(current_gnss_synchro_map.size() > 0) - { - /* - * 2.1 Use CURRENT set of measurements and find the nearest satellite - * common RX time algorithm - */ - // what is the most recent symbol TOW in the current set? -> this will be the reference symbol - gnss_synchro_iter = max_element(current_gnss_synchro_map.begin(), current_gnss_synchro_map.end(), MixedPairCompare_gnss_synchro_d_TOW_at_current_symbol); - double d_TOW_reference = gnss_synchro_iter->second.d_TOW_at_current_symbol; - double d_ref_PRN_rx_time_ms = gnss_synchro_iter->second.Prn_timestamp_ms; - //int reference_channel= gnss_synchro_iter->second.Channel_ID; - - // Now compute RX time differences due to the PRN alignment in the correlators - double traveltime_ms; - double pseudorange_m; - double delta_rx_time_ms; - for(gnss_synchro_iter = current_gnss_synchro_map.begin(); gnss_synchro_iter != current_gnss_synchro_map.end(); gnss_synchro_iter++) - { - // compute the required symbol history shift in order to match the reference symbol - delta_rx_time_ms = gnss_synchro_iter->second.Prn_timestamp_ms - d_ref_PRN_rx_time_ms; - //compute the pseudorange - traveltime_ms = (d_TOW_reference-gnss_synchro_iter->second.d_TOW_at_current_symbol)*1000.0 + delta_rx_time_ms + GPS_STARTOFFSET_ms; - pseudorange_m = traveltime_ms * GPS_C_m_ms; // [m] - // update the pseudorange object - current_gnss_synchro[gnss_synchro_iter->second.Channel_ID] = gnss_synchro_iter->second; - current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Pseudorange_m = pseudorange_m; - current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Flag_valid_pseudorange = true; - current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].d_TOW_at_current_symbol = round(d_TOW_reference*1000)/1000 + GPS_STARTOFFSET_ms/1000.0; - std::cout<<"Pseudorange_m="<second.Channel_ID].Pseudorange_m< +#include +#include +#include +#include +#include +#include +#include "gnss_sdr_valve.h" +#include "configuration_interface.h" + + +using google::LogMessage; + +//DEFINE_string(two_bit_cpx_signal_source, "-", +// "If defined, path to the file containing the NSR (byte to 2-bit packed) signal samples (overrides the configuration file)"); + + +TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* configuration, + std::string role, unsigned int in_streams, unsigned int out_streams, + boost::shared_ptr 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 = "byte"; + 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_nsr_signal_source.compare("-") != 0) filename_= FLAGS_nsr_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("byte") == 0) + { + item_size_ = sizeof(char); + } + else + { + LOG(WARNING) << item_type_ << " unrecognized item type. Using byte."; + item_size_ = sizeof(char); + } + try + { + file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_); + unpack_byte_ = make_unpack_byte_2bit_cpx_samples(); + inter_shorts_to_cpx_ = gr::blocks::interleaved_short_to_complex::make(false,true); //I/Q swap enabled + + } + 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 2 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 = 2; // 1 byte -> 2 samples + 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(gr_complex), 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(gr_complex), dump_filename_.c_str()); + DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")"; + } + + if (enable_throttle_control_) + { + throttle_ = gr::blocks::throttle::make(sizeof(gr_complex), 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_; +} + + + + +TwoBitCpxFileSignalSource::~TwoBitCpxFileSignalSource() +{} + + + + +void TwoBitCpxFileSignalSource::connect(gr::top_block_sptr top_block) +{ + if (samples_ > 0) + { + if (enable_throttle_control_ == true) + { + top_block->connect(file_source_, 0, unpack_byte_, 0); + top_block->connect(unpack_byte_, 0,inter_shorts_to_cpx_,0); + top_block->connect(inter_shorts_to_cpx_, 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_byte_, 0); + top_block->connect(unpack_byte_, 0,inter_shorts_to_cpx_,0); + top_block->connect(inter_shorts_to_cpx_, 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_byte_, 0); + top_block->connect(unpack_byte_, 0,inter_shorts_to_cpx_,0); + top_block->connect(inter_shorts_to_cpx_, 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_byte_, 0); + top_block->connect(unpack_byte_, 0,inter_shorts_to_cpx_,0); + top_block->connect(inter_shorts_to_cpx_, 0, sink_, 0); + DLOG(INFO) << "connected file source to sink"; + } + } + } +} + + + + + + +void TwoBitCpxFileSignalSource::disconnect(gr::top_block_sptr top_block) +{ + if (samples_ > 0) + { + if (enable_throttle_control_ == true) + { + top_block->disconnect(file_source_, 0, unpack_byte_, 0); + DLOG(INFO) << "disconnected file source to unpack_byte_"; + top_block->connect(unpack_byte_, 0,throttle_,0); + DLOG(INFO) << "disconnected unpack_byte_ 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_byte_, 0); + DLOG(INFO) << "disconnected file source to unpack_byte_"; + top_block->disconnect(unpack_byte_, 0, valve_, 0); + DLOG(INFO) << "disconnected unpack_byte_ 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_byte_, 0); + DLOG(INFO) << "disconnected file source to unpack_byte_"; + top_block->disconnect(unpack_byte_, 0, throttle_, 0); + DLOG(INFO) << "disconnected unpack_byte_ to throttle"; + if (dump_) + { + top_block->disconnect(unpack_byte_, 0, sink_, 0); + DLOG(INFO) << "disconnected funpack_byte_ to sink"; + } + } + else + { + if (dump_) + { + top_block->disconnect(file_source_, 0, unpack_byte_, 0); + DLOG(INFO) << "disconnected file source to unpack_byte_"; + top_block->disconnect(unpack_byte_, 0, sink_, 0); + DLOG(INFO) << "disconnected unpack_byte_ to sink"; + } + } + } +} + + + + + +gr::basic_block_sptr TwoBitCpxFileSignalSource::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 TwoBitCpxFileSignalSource::get_right_block() +{ + if (samples_ > 0) + { + return valve_; + } + else + { + if (enable_throttle_control_ == true) + { + return throttle_; + } + else + { + return unpack_byte_; + } + } +} diff --git a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h new file mode 100644 index 000000000..65c74f4ba --- /dev/null +++ b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h @@ -0,0 +1,128 @@ +/*! + * \file nsr_file_signal_source.h + * \brief Implementation of a class that reads signals samples from a NSR 2 bits sampler front-end file + * and adapts it to a SignalSourceInterface. More information about the front-end here + * http://www.ifen.com/products/sx-scientific-gnss-solutions/nsr-software-receiver.html + * \author Javier Arribas, 2013 jarribas(at)cttc.es + * + * This class represents a file signal source. + * + * ------------------------------------------------------------------------- + * + * 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 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 . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_TWO_BIT_CPX_FILE_SIGNAL_SOURCE_H_ +#define GNSS_SDR_TWO_BIT_CPX_FILE_SIGNAL_SOURCE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "gnss_block_interface.h" +#include "unpack_byte_2bit_cpx_samples.h" + + + +class ConfigurationInterface; + +/*! + * \brief Class that reads signals samples from a file + * and adapts it to a SignalSourceInterface + */ +class TwoBitCpxFileSignalSource: public GNSSBlockInterface +{ +public: + TwoBitCpxFileSignalSource(ConfigurationInterface* configuration, std::string role, + unsigned int in_streams, unsigned int out_streams, + boost::shared_ptr queue); + + virtual ~TwoBitCpxFileSignalSource(); + std::string role() + { + return role_; + } + + /*! + * \brief Returns "Two_Bit_Cpx_File_Signal_Source". + */ + std::string implementation() + { + return "Two_Bit_Cpx_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_byte_2bit_cpx_samples_sptr unpack_byte_; + gr::blocks::interleaved_short_to_complex::sptr inter_shorts_to_cpx_; + boost::shared_ptr valve_; + gr::blocks::file_sink::sptr sink_; + gr::blocks::throttle::sptr throttle_; + boost::shared_ptr queue_; + size_t item_size_; + // Throttle control + bool enable_throttle_control_; +}; + +#endif /*GNSS_SDR_TWO_BIT_CPX_FILE_SIGNAL_SOURCE_H_*/ diff --git a/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt b/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt index 2798f5b25..7b99f481c 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt @@ -19,6 +19,7 @@ set(SIGNAL_SOURCE_GR_BLOCKS_SOURCES unpack_byte_2bit_samples.cc + unpack_byte_2bit_cpx_samples.cc unpack_intspir_1bit_samples.cc rtl_tcp_signal_source_c.cc ) diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc new file mode 100644 index 000000000..542357ea3 --- /dev/null +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc @@ -0,0 +1,88 @@ +/*! + * \file unpack_byte_2bit_cpx_samples.cc + * + * \brief Unpacks byte samples to NSR 2 bits samples + * \author Javier Arribas jarribas (at) cttc.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 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 . + * + * ------------------------------------------------------------------------- + */ + + +#include "unpack_byte_2bit_cpx_samples.h" +#include +#include + +struct byte_2bit_struct +{ + signed two_bit_sample:2; // <- 2 bits wide only +}; + + +unpack_byte_2bit_cpx_samples_sptr make_unpack_byte_2bit_cpx_samples() +{ + return unpack_byte_2bit_cpx_samples_sptr(new unpack_byte_2bit_cpx_samples()); +} + +unpack_byte_2bit_cpx_samples::unpack_byte_2bit_cpx_samples() : sync_interpolator("unpack_byte_2bit_cpx_samples", + gr::io_signature::make(1, 1, sizeof(signed char)), + gr::io_signature::make(1, 1, sizeof(short)), + 4) +{} + +unpack_byte_2bit_cpx_samples::~unpack_byte_2bit_cpx_samples() +{} + +int unpack_byte_2bit_cpx_samples::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const signed char *in = (const signed char *)input_items[0]; + short *out = (short*)output_items[0]; + + byte_2bit_struct sample; + int n = 0; + for(int i = 0; i < noutput_items/4; i++) + { + // Read packed input sample (1 byte = 2 complex samples) + //* Packing Order + //* Most Significant Nibble - Sample n + //* Least Significant Nibble - Sample n+1 + //* Packing order in Nibble Q1 Q0 I1 I0 + signed char c = in[i]; + //Q[n] + sample.two_bit_sample = (c>>6) & 3; + out[n++] = (short)sample.two_bit_sample; + //I[n] + sample.two_bit_sample = (c>>4) & 3; + out[n++] = (short)sample.two_bit_sample; + //Q[n+1] + sample.two_bit_sample = (c>>2) & 3; + out[n++] = (short)sample.two_bit_sample; + //I[n+1] + sample.two_bit_sample = c & 3; + out[n++] = (short)sample.two_bit_sample; + + } + return noutput_items; +} diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.h b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.h new file mode 100644 index 000000000..d7513aa52 --- /dev/null +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.h @@ -0,0 +1,64 @@ +/*! + * \file unpack_byte_2bit_cpx_samples.h + * + * \brief Unpacks byte samples to 2 bits complex samples. + * Packing Order + * Most Significant Nibble - Sample n + * Least Significant Nibble - Sample n+1 + * Packing order in Nibble Q1 Q0 I1 I0 + * \author Javier Arribas jarribas (at) cttc.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 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 . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_UNPACK_BYTE_2BIT_CPX_SAMPLES_H +#define GNSS_SDR_UNPACK_BYTE_2BIT_CPX_SAMPLES_H + +#include + +class unpack_byte_2bit_cpx_samples; + +typedef boost::shared_ptr unpack_byte_2bit_cpx_samples_sptr; + +unpack_byte_2bit_cpx_samples_sptr make_unpack_byte_2bit_cpx_samples(); + +/*! + * \brief This class implements conversion between byte packet samples to 2bit_cpx samples + * 1 byte = 2 x complex 2bit I, + 2bit Q samples + */ +class unpack_byte_2bit_cpx_samples: public gr::sync_interpolator +{ +private: + friend unpack_byte_2bit_cpx_samples_sptr + make_unpack_byte_2bit_cpx_samples_sptr(); + +public: + unpack_byte_2bit_cpx_samples(); + ~unpack_byte_2bit_cpx_samples(); + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 2c449d1ce..770c1a6d3 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -45,6 +45,7 @@ #include "pass_through.h" #include "file_signal_source.h" #include "nsr_file_signal_source.h" +#include "two_bit_cpx_file_signal_source.h" #include "spir_file_signal_source.h" #include "rtl_tcp_signal_source.h" #include "null_sink_output_filter.h" @@ -1037,6 +1038,21 @@ std::unique_ptr 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("Two_Bit_Cpx_File_Signal_Source") == 0) + { + try + { + std::unique_ptr block_(new TwoBitCpxFileSignalSource(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } catch (const std::exception &e) {