mirror of
https://github.com/gqrx-sdr/gqrx.git
synced 2024-09-21 10:47:10 +00:00
Issue #32: Created base class for input sources. Changed FCD source to use new API.
This commit is contained in:
parent
8249ba5502
commit
f4566f8d87
42
dsp/rx_source_base.cc
Normal file
42
dsp/rx_source_base.cc
Normal file
@ -0,0 +1,42 @@
|
||||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2011 Alexandru Csete OZ9AEC.
|
||||
*
|
||||
* Gqrx 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* Gqrx 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 Gqrx; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <gr_io_signature.h>
|
||||
#include <dsp/rx_source_base.h>
|
||||
|
||||
|
||||
static const int MIN_IN = 0; /* Mininum number of input streams. */
|
||||
static const int MAX_IN = 0; /* Maximum number of input streams. */
|
||||
static const int MIN_OUT = 1; /* Minimum number of output streams. */
|
||||
static const int MAX_OUT = 1; /* Maximum number of output streams. */
|
||||
|
||||
rx_source_base::rx_source_base(std::string src_name)
|
||||
: gr_hier_block2 (src_name,
|
||||
gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)),
|
||||
gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (gr_complex)))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
rx_source_base::~rx_source_base()
|
||||
{
|
||||
|
||||
}
|
||||
|
81
dsp/rx_source_base.h
Normal file
81
dsp/rx_source_base.h
Normal file
@ -0,0 +1,81 @@
|
||||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2011 Alexandru Csete OZ9AEC.
|
||||
*
|
||||
* Gqrx 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* Gqrx 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 Gqrx; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef RX_SOURCE_BASE_H
|
||||
#define RX_SOURCE_BASE_H
|
||||
|
||||
#include <gr_hier_block2.h>
|
||||
|
||||
|
||||
class rx_source_base;
|
||||
|
||||
typedef boost::shared_ptr<rx_source_base> rx_source_base_sptr;
|
||||
|
||||
|
||||
/*! \brief Base class for all types of input source.
|
||||
* \ingroup DSP
|
||||
*
|
||||
* This block provides a base class for signal sources. All sources
|
||||
* should be derived from this class to ensure uniform API.
|
||||
*
|
||||
*/
|
||||
class rx_source_base : public gr_hier_block2
|
||||
{
|
||||
|
||||
public:
|
||||
/*! \brief Public contructor.
|
||||
* \param src_name Descriptive name used in the contructor of gr_hier_block2
|
||||
*/
|
||||
rx_source_base(const std::string src_name);
|
||||
~rx_source_base();
|
||||
|
||||
/*! \brief Select a new device.
|
||||
* \param device The new device (format depends on source type).
|
||||
*
|
||||
* This method can be used to select a new input device. For the FCD source
|
||||
* this is the audio input device, for UHD it is the sub-device specification.
|
||||
*/
|
||||
virtual void select_device(const std::string device) = 0;
|
||||
|
||||
/*! \brief Set center frequency.
|
||||
* \param freq The new center frequency in Hz.
|
||||
*/
|
||||
virtual void set_freq(double freq) = 0;
|
||||
|
||||
/*! \brief Get center frequency.
|
||||
* \returns The current center frequency.
|
||||
*/
|
||||
virtual double get_freq() = 0;
|
||||
virtual double get_freq_min() = 0;
|
||||
virtual double get_freq_max() = 0;
|
||||
|
||||
virtual void set_gain(double gain) = 0;
|
||||
virtual double get_gain() = 0;
|
||||
virtual double get_gain_min() = 0;
|
||||
virtual double get_gain_max() = 0;
|
||||
|
||||
virtual void set_sample_rate(double sps) = 0;
|
||||
virtual double get_sample_rate() = 0;
|
||||
virtual std::vector<double> get_sample_rates() = 0;
|
||||
|
||||
virtual void set_dc_corr(double dci, double dcq) = 0;
|
||||
virtual void set_iq_corr(double gain, double phase) = 0;
|
||||
};
|
||||
|
||||
#endif // RX_SOURCE_BASE_H
|
129
dsp/rx_source_fcd.cc
Normal file
129
dsp/rx_source_fcd.cc
Normal file
@ -0,0 +1,129 @@
|
||||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2011 Alexandru Csete OZ9AEC.
|
||||
*
|
||||
* Gqrx 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* Gqrx 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 Gqrx; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
//#include <gr_io_signature.h>
|
||||
#include <dsp/rx_source_fcd.h>
|
||||
|
||||
|
||||
rx_source_fcd_sptr make_rx_source_fcd(const std::string device_name)
|
||||
{
|
||||
return gnuradio::get_initial_sptr(new rx_source_fcd(device_name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
rx_source_fcd::rx_source_fcd(const std::string device_name)
|
||||
: rx_source_base("rx_source_fcd"),
|
||||
d_freq(144.5e6),
|
||||
d_gain(20.0)
|
||||
{
|
||||
d_fcd_src = fcd_make_source_c(device_name);
|
||||
d_fcd_src->set_freq(144.5e6f);
|
||||
d_fcd_src->set_lna_gain(20.0f);
|
||||
|
||||
/** TODO: check error */
|
||||
|
||||
// populate supported sample rates
|
||||
d_sample_rates.push_back(96000.0);
|
||||
|
||||
connect(d_fcd_src, 0, self(), 0);
|
||||
}
|
||||
|
||||
|
||||
rx_source_fcd::~rx_source_fcd()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void rx_source_fcd::select_device(const std::string device_name)
|
||||
{
|
||||
// FIXME
|
||||
}
|
||||
|
||||
void rx_source_fcd::set_freq(double freq)
|
||||
{
|
||||
if ((freq >= get_freq_min()) && (freq <= get_freq_max())) {
|
||||
d_freq = freq;
|
||||
d_fcd_src->set_freq((float) d_freq);
|
||||
}
|
||||
}
|
||||
|
||||
double rx_source_fcd::get_freq()
|
||||
{
|
||||
return d_freq;
|
||||
}
|
||||
|
||||
double rx_source_fcd::get_freq_min()
|
||||
{
|
||||
return 50.0e6;
|
||||
}
|
||||
|
||||
double rx_source_fcd::get_freq_max()
|
||||
{
|
||||
return 2.0e9;
|
||||
}
|
||||
|
||||
void rx_source_fcd::set_gain(double gain)
|
||||
{
|
||||
if ((gain >= get_gain_min()) && (gain <= get_gain_max())) {
|
||||
d_gain = gain;
|
||||
d_fcd_src->set_lna_gain((float)gain);
|
||||
}
|
||||
}
|
||||
|
||||
double rx_source_fcd::get_gain()
|
||||
{
|
||||
return d_gain;
|
||||
}
|
||||
|
||||
double rx_source_fcd::get_gain_min()
|
||||
{
|
||||
return -5.0;
|
||||
}
|
||||
|
||||
double rx_source_fcd::get_gain_max()
|
||||
{
|
||||
return 30.0;
|
||||
}
|
||||
|
||||
void rx_source_fcd::set_sample_rate(double sps)
|
||||
{
|
||||
// nothing to do;
|
||||
}
|
||||
|
||||
double rx_source_fcd::get_sample_rate()
|
||||
{
|
||||
return 96000.0;
|
||||
}
|
||||
|
||||
std::vector<double> rx_source_fcd::get_sample_rates()
|
||||
{
|
||||
return d_sample_rates;
|
||||
}
|
||||
|
||||
void rx_source_fcd::set_dc_corr(double dci, double dcq)
|
||||
{
|
||||
d_fcd_src->set_dc_corr(dci, dcq);
|
||||
}
|
||||
|
||||
void rx_source_fcd::set_iq_corr(double gain, double phase)
|
||||
{
|
||||
d_fcd_src->set_iq_corr(gain, phase);
|
||||
}
|
78
dsp/rx_source_fcd.h
Normal file
78
dsp/rx_source_fcd.h
Normal file
@ -0,0 +1,78 @@
|
||||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2011 Alexandru Csete OZ9AEC.
|
||||
*
|
||||
* Gqrx 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* Gqrx 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 Gqrx; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef RX_SOURCE_FCD_H
|
||||
#define RX_SOURCE_FCD_H
|
||||
|
||||
#include <gr_hier_block2.h>
|
||||
#include <fcd/fcd_source_c.h>
|
||||
#include <dsp/rx_source_base.h>
|
||||
|
||||
|
||||
class rx_source_fcd;
|
||||
|
||||
/*! \brief Boost shared pointer to rx_source_fcd. */
|
||||
typedef boost::shared_ptr<rx_source_fcd> rx_source_fcd_sptr;
|
||||
|
||||
/*! \brief Public constructor of rx_source_fcd. */
|
||||
rx_source_fcd_sptr make_rx_source_fcd(const std::string device_name = "hw:1");
|
||||
|
||||
|
||||
/*! \brief Wrapper block for Funcube Dongle source.
|
||||
* \ingroup DSP
|
||||
*
|
||||
* This block provides a wrapper for the FCD source using the
|
||||
* rx_source_base API.
|
||||
*
|
||||
*/
|
||||
class rx_source_fcd : public rx_source_base
|
||||
{
|
||||
|
||||
public:
|
||||
rx_source_fcd(const std::string device_name);
|
||||
~rx_source_fcd();
|
||||
|
||||
void select_device(const std::string device_name);
|
||||
|
||||
void set_freq(double freq);
|
||||
double get_freq();
|
||||
double get_freq_min();
|
||||
double get_freq_max();
|
||||
|
||||
void set_gain(double gain);
|
||||
double get_gain();
|
||||
double get_gain_min();
|
||||
double get_gain_max();
|
||||
|
||||
void set_sample_rate(double sps);
|
||||
double get_sample_rate();
|
||||
std::vector<double> get_sample_rates();
|
||||
|
||||
void set_dc_corr(double dci, double dcq);
|
||||
void set_iq_corr(double gain, double phase);
|
||||
|
||||
private:
|
||||
fcd_source_c_sptr d_fcd_src; /*! Funcube Dongle source. */
|
||||
|
||||
std::vector<double> d_sample_rates;
|
||||
double d_freq;
|
||||
double d_gain;
|
||||
};
|
||||
|
||||
#endif // RX_SOURCE_FCD_H
|
8
gqrx.pro
8
gqrx.pro
@ -56,7 +56,9 @@ SOURCES +=\
|
||||
qtgui/arissattlm.cc \
|
||||
tlm/arissat/scale_therm.c \
|
||||
tlm/arissat/scale_psu.c \
|
||||
tlm/arissat/scale_ppt.c
|
||||
tlm/arissat/scale_ppt.c \
|
||||
dsp/rx_source_base.cc \
|
||||
dsp/rx_source_fcd.cc
|
||||
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
@ -87,7 +89,9 @@ HEADERS += mainwindow.h \
|
||||
qtgui/arissattlm.h \
|
||||
tlm/arissat/scale_therm.h \
|
||||
tlm/arissat/scale_psu.h \
|
||||
tlm/arissat/scale_ppt.h
|
||||
tlm/arissat/scale_ppt.h \
|
||||
dsp/rx_source_base.h \
|
||||
dsp/rx_source_fcd.h
|
||||
|
||||
FORMS += \
|
||||
qtgui/dockrxopt.ui \
|
||||
|
55
receiver.cc
55
receiver.cc
@ -28,7 +28,8 @@
|
||||
#include <gr_simple_squelch_cc.h>
|
||||
|
||||
#include <receiver.h>
|
||||
#include <fcd/fcd_source_c.h>
|
||||
//#include <fcd/fcd_source_c.h>
|
||||
#include <dsp/rx_source_fcd.h>
|
||||
#include <dsp/rx_filter.h>
|
||||
#include <dsp/rx_meter.h>
|
||||
#include <dsp/rx_demod_fm.h>
|
||||
@ -54,8 +55,8 @@ receiver::receiver(const std::string input_device, const std::string audio_devic
|
||||
{
|
||||
tb = gr_make_top_block("gqrx");
|
||||
|
||||
fcd_src = fcd_make_source_c(input_device);
|
||||
fcd_src->set_freq(d_rf_freq);
|
||||
src = make_rx_source_fcd(input_device);
|
||||
src->set_freq(d_rf_freq);
|
||||
|
||||
fft = make_rx_fft_c(4096, 0, false);
|
||||
|
||||
@ -79,9 +80,10 @@ receiver::receiver(const std::string input_device, const std::string audio_devic
|
||||
sniffer = make_sniffer_f();
|
||||
/* sniffer_rr is created at each activation. */
|
||||
|
||||
tb->connect(fcd_src, 0, fft, 0);
|
||||
tb->connect(fcd_src, 0, iq_sink, 0);
|
||||
tb->connect(fcd_src, 0, filter, 0);
|
||||
tb->connect(src, 0, fft, 0);
|
||||
tb->connect(src, 0, iq_sink, 0);
|
||||
tb->connect(src, 0, filter, 0);
|
||||
|
||||
tb->connect(filter, 0, meter, 0);
|
||||
tb->connect(filter, 0, sql, 0);
|
||||
tb->connect(sql, 0, bb_gain, 0);
|
||||
@ -132,15 +134,18 @@ void receiver::set_input_device(const std::string device)
|
||||
{
|
||||
tb->lock();
|
||||
|
||||
tb->disconnect(fcd_src, 0, fft, 0);
|
||||
tb->disconnect(fcd_src, 0, filter, 0);
|
||||
tb->disconnect(src, 0, fft, 0);
|
||||
tb->disconnect(src, 0, filter, 0);
|
||||
tb->disconnect(src, 0, iq_sink, 0);
|
||||
|
||||
fcd_src.reset();
|
||||
fcd_src = fcd_make_source_c(device);
|
||||
fcd_src->set_freq(d_rf_freq);
|
||||
// FIXME: ought to use src->select_device() when implemented
|
||||
src.reset();
|
||||
src = make_rx_source_fcd(device);
|
||||
src->set_freq(d_rf_freq);
|
||||
|
||||
tb->connect(fcd_src, 0, fft, 0);
|
||||
tb->connect(fcd_src, 0, filter, 0);
|
||||
tb->connect(src, 0, fft, 0);
|
||||
tb->connect(src, 0, filter, 0);
|
||||
tb->connect(src, 0, iq_sink, 0);
|
||||
|
||||
tb->unlock();
|
||||
}
|
||||
@ -169,8 +174,9 @@ void receiver::set_output_device(const std::string device)
|
||||
receiver::status receiver::set_rf_freq(float freq_hz)
|
||||
{
|
||||
d_rf_freq = freq_hz;
|
||||
/* FIXME: check frequency? */
|
||||
fcd_src->set_freq(d_rf_freq);
|
||||
|
||||
src->set_freq(d_rf_freq);
|
||||
// FIXME: read back frequency?
|
||||
|
||||
return STATUS_OK;
|
||||
}
|
||||
@ -181,6 +187,7 @@ receiver::status receiver::set_rf_freq(float freq_hz)
|
||||
*/
|
||||
float receiver::get_rf_freq()
|
||||
{
|
||||
d_rf_freq = src->get_freq();
|
||||
return d_rf_freq;
|
||||
}
|
||||
|
||||
@ -190,7 +197,7 @@ float receiver::get_rf_freq()
|
||||
*/
|
||||
receiver::status receiver::set_rf_gain(float gain_db)
|
||||
{
|
||||
fcd_src->set_lna_gain(gain_db);
|
||||
src->set_gain(gain_db);
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
||||
@ -275,14 +282,14 @@ receiver::status receiver::set_filter_shape(filter_shape shape)
|
||||
|
||||
receiver::status receiver::set_dc_corr(double dci, double dcq)
|
||||
{
|
||||
fcd_src->set_dc_corr(dci, dcq);
|
||||
src->set_dc_corr(dci, dcq);
|
||||
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
||||
receiver::status receiver::set_iq_corr(double gain, double phase)
|
||||
{
|
||||
fcd_src->set_iq_corr(gain, phase);
|
||||
src->set_iq_corr(gain, phase);
|
||||
|
||||
return STATUS_OK;
|
||||
}
|
||||
@ -623,9 +630,9 @@ receiver::status receiver::start_iq_playback(const std::string filename, float s
|
||||
tb->lock();
|
||||
|
||||
/* disconenct hardware source */
|
||||
tb->disconnect(fcd_src, 0, fft, 0);
|
||||
tb->disconnect(fcd_src, 0, iq_sink, 0);
|
||||
tb->disconnect(fcd_src, 0, filter, 0);
|
||||
tb->disconnect(src, 0, fft, 0);
|
||||
tb->disconnect(src, 0, iq_sink, 0);
|
||||
tb->disconnect(src, 0, filter, 0);
|
||||
|
||||
/* connect I/Q source via throttle block */
|
||||
//tb->connect(iq_src, 0, iq_throttle, 0);
|
||||
@ -657,9 +664,9 @@ receiver::status receiver::stop_iq_playback()
|
||||
tb->disconnect(iq_src, 0, filter, 0);
|
||||
|
||||
/* reconenct hardware source */
|
||||
tb->connect(fcd_src, 0, fft, 0);
|
||||
tb->connect(fcd_src, 0, iq_sink, 0);
|
||||
tb->connect(fcd_src, 0, filter, 0);
|
||||
tb->connect(src, 0, fft, 0);
|
||||
tb->connect(src, 0, iq_sink, 0);
|
||||
tb->connect(src, 0, filter, 0);
|
||||
|
||||
tb->unlock();
|
||||
|
||||
|
@ -33,7 +33,8 @@
|
||||
#include <gr_wavfile_sink.h>
|
||||
#include <gr_wavfile_source.h>
|
||||
#include <gr_null_sink.h>
|
||||
#include <fcd/fcd_source_c.h>
|
||||
//#include <fcd/fcd_source_c.h>
|
||||
#include <dsp/rx_source_fcd.h>
|
||||
#include <dsp/rx_filter.h>
|
||||
#include <dsp/rx_meter.h>
|
||||
#include <dsp/rx_demod_fm.h>
|
||||
@ -158,7 +159,11 @@ private:
|
||||
demod d_demod; /*! Current demodulator. */
|
||||
|
||||
gr_top_block_sptr tb; /*! The GNU Radio top block. */
|
||||
fcd_source_c_sptr fcd_src; /*! Funcube Dongle source. */
|
||||
|
||||
//fcd_source_c_sptr fcd_src; /*! Funcube Dongle source. */
|
||||
//rx_source_base *src;
|
||||
rx_source_base_sptr src;
|
||||
|
||||
rx_fft_c_sptr fft; /*! Receiver FFT block. */
|
||||
rx_filter_sptr filter;
|
||||
rx_meter_c_sptr meter; /*! Signal strength. */
|
||||
|
Loading…
Reference in New Issue
Block a user