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_ */ diff --git a/swagger/sdrangel/examples/start_stop.py b/swagger/sdrangel/examples/start_stop.py index 8a09baa0c..ac2be1c07 100644 --- a/swagger/sdrangel/examples/start_stop.py +++ b/swagger/sdrangel/examples/start_stop.py @@ -21,7 +21,7 @@ def getInputOptions(): options.address = "127.0.0.1:8888" if options.device_index < 0: - otions.device_index = 0 + options.device_index = 0 if options.start and options.stop: print("Cannot start and stop at the same time")