aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@gmail.com>2019-07-17 09:34:22 +0200
committerPiotr Krysik <ptrkrysik@gmail.com>2019-07-18 10:33:32 +0200
commit43dfbdf1a964ca4fd731e0fff523f286ecfff1f1 (patch)
tree9ced1524a5027666d152b3c64b662b5cd57f4648 /lib
parentc5ed04572f6cb6ced8ad80b9bdb417e855b8f363 (diff)
utils/fn_time: added clock_error to fn_time_delta
Information about clock error is needed in order to transform frame number to hardware time - which is not ideal (i.e. different than BTS time). Change-Id: Icd77b88da0490d6c9565bf3df0342574b91aae6e
Diffstat (limited to 'lib')
-rw-r--r--lib/misc_utils/fn_time.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/misc_utils/fn_time.cc b/lib/misc_utils/fn_time.cc
index 2773f33..667ee47 100644
--- a/lib/misc_utils/fn_time.cc
+++ b/lib/misc_utils/fn_time.cc
@@ -29,7 +29,7 @@
#define GSM_SYM_RATE (13.0e6 / 48.0)
#define GSM_TS_PERIOD (156.25 / GSM_SYM_RATE)
-#define GSM_FN_PERIOD (8 * GSM_TS_PERIOD)
+#define GSM_FRAME_PERIOD (8 * GSM_TS_PERIOD)
namespace gr {
namespace gsm {
@@ -62,7 +62,7 @@ namespace gr {
time_spec_t time_diff_hint)
{
int frames_diff, fn_delta;
- frames_diff = int(round(time_diff_hint.get_real_secs() / GSM_FN_PERIOD));
+ frames_diff = int(round(time_diff_hint.get_real_secs() / GSM_FRAME_PERIOD));
fn_delta = fnmod_delta(fn, fn_ref + frames_diff) + frames_diff;
return fn_delta;
@@ -80,11 +80,14 @@ namespace gr {
* @return difference between fn_ref and fn
*/
time_format fn_time_delta_cpp(uint32_t fn_ref, time_format time_ref, uint32_t fn_x,
- time_format time_hint, uint32_t ts_num, uint32_t ts_ref)
+ time_format time_hint, uint32_t ts_num, uint32_t ts_ref, double clock_error)
{
- time_spec_t time_diff_hint = time_spec_t(time_hint.first, time_hint.second) - time_spec_t(time_ref.first, time_ref.second);
+ time_spec_t time_diff_hint = time_spec_t(time_hint.first, time_hint.second)
+ - time_spec_t(time_ref.first, time_ref.second);
int fn_delta = fn_time_diff_delta(fn_x, fn_ref, time_diff_hint);
- time_spec_t time_x_precise = fn_delta * GSM_FN_PERIOD + time_spec_t(time_ref.first, time_ref.second) + (static_cast<int>(ts_num) - static_cast<int>(ts_ref)) * GSM_TS_PERIOD;
+ time_spec_t time_x_precise = (fn_delta * GSM_FRAME_PERIOD)*(1.0-clock_error)
+ + time_spec_t(time_ref.first, time_ref.second)
+ + (static_cast<int>(ts_num) - static_cast<int>(ts_ref)) * GSM_TS_PERIOD;
return time_format(time_x_precise.get_full_secs(), time_x_precise.get_frac_secs());
}