From 5ad63b737617558af77628e5cac979898dd2d920 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 20 Jan 2019 00:52:57 +0100 Subject: [PATCH] XTRX: refactored GPS lock test using workaround using change in 1PPS iterval clock counts. Fixes hanging for 1PPS signal --- devices/xtrx/devicextrxshared.cpp | 35 ++++++++++++++++++++++++++----- devices/xtrx/devicextrxshared.h | 5 +++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/devices/xtrx/devicextrxshared.cpp b/devices/xtrx/devicextrxshared.cpp index e9c5f1e98..d33354e33 100644 --- a/devices/xtrx/devicextrxshared.cpp +++ b/devices/xtrx/devicextrxshared.cpp @@ -31,9 +31,11 @@ DeviceXTRXShared::DeviceXTRXShared() : m_channel(-1), m_source(0), m_sink(0), - m_thread(0), - m_threadWasRunning(false) + m_threadWasRunning(false), + m_first_1pps_count(true), + m_last_1pps_count(0), + m_no_1pps_count_change_counter(0) {} DeviceXTRXShared::~DeviceXTRXShared() @@ -56,11 +58,34 @@ bool DeviceXTRXShared::get_gps_status() { uint64_t val = 0; - int res = xtrx_val_get(m_dev->getDevice(), XTRX_TRX, XTRX_CH_AB, XTRX_WAIT_1PPS, &val); + int res = xtrx_val_get(m_dev->getDevice(), (xtrx_direction_t) 0, XTRX_CH_AB, XTRX_OSC_LATCH_1PPS, &val); - if (res) { + if (res) + { return false; } + else + { + if (m_first_1pps_count) + { + m_last_1pps_count = val; + m_first_1pps_count = false; + } + else + { + if (m_last_1pps_count != val) + { + m_no_1pps_count_change_counter = 7; + m_last_1pps_count = val; + } + else if (m_no_1pps_count_change_counter != 0) + { + m_no_1pps_count_change_counter--; + } - return val != 0; + } + + //qDebug("DeviceXTRXShared::get_gps_status: XTRX_OSC_LATCH_1PPS: %lu %u", val, m_no_1pps_count_change_counter); + return m_no_1pps_count_change_counter != 0; + } } diff --git a/devices/xtrx/devicextrxshared.h b/devices/xtrx/devicextrxshared.h index 63c01b01c..580090381 100644 --- a/devices/xtrx/devicextrxshared.h +++ b/devices/xtrx/devicextrxshared.h @@ -148,6 +148,11 @@ public: double get_board_temperature(); bool get_gps_status(); + +private: + bool m_first_1pps_count; + uint64_t m_last_1pps_count; + uint32_t m_no_1pps_count_change_counter; }; #endif /* DEVICES_LIMESDR_DEVICELIMESDRSHARED_H_ */