From: Clayton Smith <argilo(a)gmail.com>
This patch was originally written by Alexandru Csete and posted at
https://github.com/csete/gr-osmosdr-gqrx/commit/d66df300. The only
change I made was to rename the _freq_corr_ppm variable to
_freq_corr, since many other devices use that name.
This patch used to be included in Gqrx releases, so it should work
correctly.
---
lib/rfspace/rfspace_source_c.cc | 17 +++++++++++++----
lib/rfspace/rfspace_source_c.h | 2 ++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/lib/rfspace/rfspace_source_c.cc b/lib/rfspace/rfspace_source_c.cc
index 314dfc732d..113588a5d4 100644
--- a/lib/rfspace/rfspace_source_c.cc
+++ b/lib/rfspace/rfspace_source_c.cc
@@ -103,6 +103,7 @@ rfspace_source_c::rfspace_source_c (const std::string &args)
_nchan(1),
_sample_rate(NAN),
_bandwidth(0.0f),
+ _freq_corr(0.0),
_fifo(NULL)
{
std::string host = "";
@@ -446,6 +447,8 @@ rfspace_source_c::rfspace_source_c (const std::string &args)
_thread = gr::thread::thread( boost::bind(&rfspace_source_c::tcp_keepalive_task,
this) );
}
+ _center_freq = get_center_freq();
+
#if 0
std::cerr << "sample_rates: " <<
get_sample_rates().to_pp_string() << std::endl;
std::cerr << "sample rate: " << (uint32_t)get_sample_rate()
<< std::endl;
@@ -600,7 +603,7 @@ static size_t read_bytes( int fd, char *data, size_t size, bool
&run )
int nread = read( fd, &data[nbytes], 1 );
if ( nread == 0 )
- continue;
+ continue;
if ( nread < 0 )
break;
@@ -1378,7 +1381,10 @@ osmosdr::freq_range_t rfspace_source_c::get_freq_range( size_t chan
)
double rfspace_source_c::set_center_freq( double freq, size_t chan )
{
- uint32_t u32_freq = freq;
+ uint32_t u32_freq;
+
+ u32_freq = freq * (1.0 + _freq_corr * 0.000001);
+ _center_freq = freq;
/* SDR-IQ 5.2.2 Receiver Frequency */
/* SDR-IP 4.2.2 Receiver Frequency */
@@ -1395,7 +1401,7 @@ double rfspace_source_c::set_center_freq( double freq, size_t chan
)
transaction( tune, sizeof(tune) );
- return get_center_freq( chan );
+ return _center_freq;
}
double rfspace_source_c::get_center_freq( size_t chan )
@@ -1423,12 +1429,15 @@ double rfspace_source_c::get_center_freq( size_t chan )
double rfspace_source_c::set_freq_corr( double ppm, size_t chan )
{
+ _freq_corr = ppm;
+ set_center_freq( _center_freq, chan );
+
return get_freq_corr( chan );
}
double rfspace_source_c::get_freq_corr( size_t chan )
{
- return 0;
+ return _freq_corr;
}
std::vector<std::string> rfspace_source_c::get_gain_names( size_t chan )
diff --git a/lib/rfspace/rfspace_source_c.h b/lib/rfspace/rfspace_source_c.h
index 996f47b392..42bb6de6ac 100644
--- a/lib/rfspace/rfspace_source_c.h
+++ b/lib/rfspace/rfspace_source_c.h
@@ -145,6 +145,8 @@ private: /* members */
size_t _nchan;
double _sample_rate;
double _bandwidth;
+ double _center_freq;
+ double _freq_corr;
gr::thread::thread _thread;
bool _run_usb_read_task;
--
2.25.1