aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@gmail.com>2016-07-17 22:48:35 +0200
committerPiotr Krysik <ptrkrysik@gmail.com>2016-07-17 22:48:35 +0200
commit83afe7390fadd13cb8636ac4da1bafb9a73a5521 (patch)
tree5ac105f23da8880f433a343fd4721844c3d0cc1c /lib
parenta94adb186438498dcc6513cc68d8f2ee4155e6f5 (diff)
Changed clock offset controller and company in order to remove from the gsm_input one of the resamplers.
Diffstat (limited to 'lib')
-rw-r--r--lib/misc_utils/controlled_rotator_cc_impl.cc32
-rw-r--r--lib/misc_utils/controlled_rotator_cc_impl.h6
-rw-r--r--lib/receiver/clock_offset_control_impl.cc33
-rw-r--r--lib/receiver/clock_offset_control_impl.h6
4 files changed, 42 insertions, 35 deletions
diff --git a/lib/misc_utils/controlled_rotator_cc_impl.cc b/lib/misc_utils/controlled_rotator_cc_impl.cc
index 68fa207..a91fd08 100644
--- a/lib/misc_utils/controlled_rotator_cc_impl.cc
+++ b/lib/misc_utils/controlled_rotator_cc_impl.cc
@@ -32,22 +32,21 @@ namespace gr {
namespace gsm {
controlled_rotator_cc::sptr
- controlled_rotator_cc::make(double phase_inc, double samp_rate)
+ controlled_rotator_cc::make(double phase_inc)
{
return gnuradio::get_initial_sptr
- (new controlled_rotator_cc_impl(phase_inc, samp_rate));
+ (new controlled_rotator_cc_impl(phase_inc));
}
/*
* The private constructor
*/
- controlled_rotator_cc_impl::controlled_rotator_cc_impl(double phase_inc, double samp_rate)
+ controlled_rotator_cc_impl::controlled_rotator_cc_impl(double phase_inc)
: gr::sync_block("controlled_rotator_cc",
gr::io_signature::make2(1, 2, sizeof(gr_complex), sizeof(float)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
{
set_phase_inc(phase_inc);
- set_samp_rate(samp_rate);
}
/*
@@ -64,11 +63,11 @@ namespace gr {
d_r.set_phase_incr( exp(gr_complex(0, (double)phase_inc)) );
}
- void
- controlled_rotator_cc_impl::set_samp_rate(double samp_rate)
- {
- d_samp_rate = samp_rate;
- }
+// void
+// controlled_rotator_cc_impl::set_samp_rate(double samp_rate)
+// {
+// d_samp_rate = samp_rate;
+// }
int
controlled_rotator_cc_impl::work(int noutput_items,
@@ -76,7 +75,7 @@ namespace gr {
gr_vector_void_star &output_items)
{
//process phase_inc input
- if(input_items.size() == 2) {
+ /*if(input_items.size() == 2) {
int ii=0;
const float *pp = (const float *)input_items[1];
@@ -99,7 +98,8 @@ namespace gr {
ii++;
}
}
-
+ */
+
//get complex input and output
const gr_complex *in = (const gr_complex *)input_items[0];
gr_complex *out = (gr_complex *)output_items[0];
@@ -121,11 +121,11 @@ namespace gr {
processed_in = processed_in + samples_to_process;
produced_out = produced_out + samples_to_process;
// std::cout << "Rotator, phase inc: " << pmt::to_double(i_tag->value) << std::endl;
-
- float freq_offset_setting = (pmt::to_double(i_tag->value) / (2*M_PI)) * d_samp_rate; //send stream tag with a new value of the frequency offset
- pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset");
- pmt::pmt_t value = pmt::from_double(freq_offset_setting);
- add_item_tag(0,i_tag->offset, key, value);
+//
+// float freq_offset_setting = (pmt::to_double(i_tag->value) / (2*M_PI)) * d_samp_rate; //send stream tag with a new value of the frequency offset
+// pmt::pmt_t key = pmt::string_to_symbol("setting_freq_offset");
+// pmt::pmt_t value = pmt::from_double(freq_offset_setting);
+// add_item_tag(0,i_tag->offset, key, value);
}
d_r.rotateN((out+produced_out), const_cast<gr_complex *>(in+processed_in), (noutput_items-produced_out)); //const_cast<gr_complex *> is workaround old implementation of rotateN that is still present in ubuntu 14.04 packages
diff --git a/lib/misc_utils/controlled_rotator_cc_impl.h b/lib/misc_utils/controlled_rotator_cc_impl.h
index 45c5af9..fb29356 100644
--- a/lib/misc_utils/controlled_rotator_cc_impl.h
+++ b/lib/misc_utils/controlled_rotator_cc_impl.h
@@ -33,15 +33,15 @@ namespace gr {
{
private:
gr_complex d_phase_inc;
- double d_samp_rate;
+// double d_samp_rate;
blocks::rotator d_r;
public:
- controlled_rotator_cc_impl(double phase_inc, double samp_rate);
+ controlled_rotator_cc_impl(double phase_inc);
~controlled_rotator_cc_impl();
virtual void set_phase_inc(double phase_inc);
- virtual void set_samp_rate(double samp_rate);
+// virtual void set_samp_rate(double samp_rate);
// Where all the action really happens
int work(int noutput_items,
diff --git a/lib/receiver/clock_offset_control_impl.cc b/lib/receiver/clock_offset_control_impl.cc
index b3a7934..7fef8fa 100644
--- a/lib/receiver/clock_offset_control_impl.cc
+++ b/lib/receiver/clock_offset_control_impl.cc
@@ -26,6 +26,7 @@
#endif
#include <sch.h>
+#include <gsm_constants.h>
#include "clock_offset_control_impl.h"
namespace gr
@@ -33,17 +34,17 @@ namespace gr
namespace gsm
{
clock_offset_control::sptr
-clock_offset_control::make(float fc, float samp_rate)
+clock_offset_control::make(float fc, float samp_rate, unsigned int osr)
{
return gnuradio::get_initial_sptr
- (new clock_offset_control_impl(fc, samp_rate));
+ (new clock_offset_control_impl(fc, samp_rate, osr));
}
/*
* The private constructor
*/
-clock_offset_control_impl::clock_offset_control_impl(float fc, float samp_rate)
+clock_offset_control_impl::clock_offset_control_impl(float fc, float samp_rate, unsigned int osr)
: gr::block("clock_offset_control",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0))
@@ -55,6 +56,7 @@ clock_offset_control_impl::clock_offset_control_impl(float fc, float samp_rate)
set_fc(fc);
set_samp_rate(samp_rate);
+ set_osr(osr);
d_alfa = 0.3;
d_ppm_estimate = -1e6;
d_last_ppm_estimate = -1e6;
@@ -73,6 +75,11 @@ clock_offset_control_impl::~clock_offset_control_impl()
{
}
+void clock_offset_control_impl::set_osr(unsigned int osr)
+{
+ d_osr = osr;
+}
+
void clock_offset_control_impl::set_fc(float fc)
{
d_fc = fc;
@@ -114,7 +121,7 @@ void clock_offset_control_impl::process_measurement(pmt::pmt_t msg)
if(state == "fcch_search")
{
- send_ctrl_messages(ppm);
+ send_ctrl_messages(freq_offset);
d_last_fcch_time = d_current_time;
}
else
@@ -138,7 +145,7 @@ void clock_offset_control_impl::process_measurement(pmt::pmt_t msg)
{
// pmt::pmt_t msg_ppm = pmt::from_double(ppm);
// message_port_pub(pmt::intern("ppm"), msg_ppm);
- send_ctrl_messages(ppm);
+ send_ctrl_messages(freq_offset);
d_last_ppm_estimate = d_ppm_estimate;
}
}
@@ -160,17 +167,15 @@ void clock_offset_control_impl::process_measurement(pmt::pmt_t msg)
}
}
-void clock_offset_control_impl::send_ctrl_messages(float ppm)
+void clock_offset_control_impl::send_ctrl_messages(float freq_offset)
{
-// pmt::pmt_t msg_ppm = pmt::from_double(ppm);
-// message_port_pub(pmt::intern("ctrl"), msg_ppm);
-// d_last_fcch_time = d_current_time;
-
- pmt::pmt_t msg_set_phase_inc = pmt::cons(pmt::intern("set_phase_inc"), pmt::from_double(2*M_PI*d_fc/d_samp_rate*ppm/1.0e6));
- message_port_pub(pmt::intern("ctrl"), msg_set_phase_inc);
+ double samp_rate_ratio = d_samp_rate / (d_osr * GSM_SYMBOL_RATE);
- pmt::pmt_t msg_set_resamp_ratio = pmt::cons(pmt::intern("set_resamp_ratio"), pmt::from_double(1+ppm/1.0e6));
- message_port_pub(pmt::intern("ctrl"), msg_set_resamp_ratio);
+ pmt::pmt_t messages = pmt::make_dict();
+ messages = dict_add(messages, pmt::string_to_symbol("set_phase_inc"), pmt::from_double(-2*M_PI*freq_offset/(d_osr * GSM_SYMBOL_RATE)));
+ messages = dict_add(messages, pmt::string_to_symbol("set_resamp_ratio"), pmt::from_double((1-(freq_offset/d_fc))*samp_rate_ratio));
+ messages = dict_add(messages, pmt::string_to_symbol("setting_freq_offset"), pmt::from_double(-freq_offset));
+ message_port_pub(pmt::intern("ctrl"), messages);
}
void clock_offset_control_impl::timed_reset()
diff --git a/lib/receiver/clock_offset_control_impl.h b/lib/receiver/clock_offset_control_impl.h
index cc0ea3d..60c3df6 100644
--- a/lib/receiver/clock_offset_control_impl.h
+++ b/lib/receiver/clock_offset_control_impl.h
@@ -33,6 +33,7 @@ namespace gr {
private:
float d_fc;
float d_samp_rate;
+ unsigned int d_osr;
float d_alfa;
float d_ppm_estimate;
float d_last_ppm_estimate;
@@ -44,15 +45,16 @@ namespace gr {
bool d_first_time;
void process_measurement(pmt::pmt_t msg);
- void send_ctrl_messages(float ppm);
+ void send_ctrl_messages(float freq_offset);
void timed_reset();
void reset();
public:
- clock_offset_control_impl(float fc, float samp_rate);
+ clock_offset_control_impl(float fc, float samp_rate, unsigned int osr);
~clock_offset_control_impl();
virtual void set_fc(float fc);
virtual void set_samp_rate(float samp_rate);
+ virtual void set_osr(unsigned int osr);
};
} // namespace gsm
} // namespace gr