From 9b9c5bfcf48eb44bd38888fb62aa7bd4067cc82f Mon Sep 17 00:00:00 2001 From: Dimitri Stolnikov Date: Mon, 7 May 2012 23:02:36 +0200 Subject: [PATCH] rtl_tcp: implement frequency correction control --- lib/rtl_tcp/rtl_tcp_source_c.cc | 7 ++++++- lib/rtl_tcp/rtl_tcp_source_c.h | 2 +- lib/rtl_tcp/rtl_tcp_source_f.cc | 6 ++++++ lib/rtl_tcp/rtl_tcp_source_f.h | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/rtl_tcp/rtl_tcp_source_c.cc b/lib/rtl_tcp/rtl_tcp_source_c.cc index c1f2869..059e99f 100644 --- a/lib/rtl_tcp/rtl_tcp_source_c.cc +++ b/lib/rtl_tcp/rtl_tcp_source_c.cc @@ -51,6 +51,7 @@ rtl_tcp_source_c::rtl_tcp_source_c(const std::string &args) : _freq = 0; _rate = 0; _gain = 0; + _corr = 0; _auto_gain = false; dict_t dict = params_to_dict(args); @@ -162,12 +163,16 @@ double rtl_tcp_source_c::get_center_freq( size_t chan ) double rtl_tcp_source_c::set_freq_corr( double ppm, size_t chan ) { + _src->set_freq_corr( int(ppm) ); + + _corr = ppm; + return get_freq_corr( chan ); } double rtl_tcp_source_c::get_freq_corr( size_t chan ) { - return 0; + return _corr; } std::vector rtl_tcp_source_c::get_gain_names( size_t chan ) diff --git a/lib/rtl_tcp/rtl_tcp_source_c.h b/lib/rtl_tcp/rtl_tcp_source_c.h index f5431c7..bb67027 100644 --- a/lib/rtl_tcp/rtl_tcp_source_c.h +++ b/lib/rtl_tcp/rtl_tcp_source_c.h @@ -75,7 +75,7 @@ public: std::string get_antenna( size_t chan = 0 ); private: - double _freq, _rate, _gain; + double _freq, _rate, _gain, _corr; bool _auto_gain; rtl_tcp_source_f_sptr _src; }; diff --git a/lib/rtl_tcp/rtl_tcp_source_f.cc b/lib/rtl_tcp/rtl_tcp_source_f.cc index 4d962a9..6dfa6ab 100644 --- a/lib/rtl_tcp/rtl_tcp_source_f.cc +++ b/lib/rtl_tcp/rtl_tcp_source_f.cc @@ -267,3 +267,9 @@ void rtl_tcp_source_f::set_gain(int gain) struct command cmd = { 0x04, gain }; send(d_socket, (const char*)&cmd, sizeof(cmd), 0); } + +void rtl_tcp_source_f::set_freq_corr(int ppm) +{ + struct command cmd = { 0x05, ppm }; + send(d_socket, (const char*)&cmd, sizeof(cmd), 0); +} diff --git a/lib/rtl_tcp/rtl_tcp_source_f.h b/lib/rtl_tcp/rtl_tcp_source_f.h index 1c2d265..dd994cb 100644 --- a/lib/rtl_tcp/rtl_tcp_source_f.h +++ b/lib/rtl_tcp/rtl_tcp_source_f.h @@ -94,6 +94,7 @@ private: void set_sample_rate(int sample_rate); void set_gain_mode(int manual); void set_gain(int gain); + void set_freq_corr(int ppm); };