diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-01-22 00:36:00 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-01-22 00:36:00 +0100 |
commit | 53c7e3485da3556c43eb9a76bfebe7fd159eb3e0 (patch) | |
tree | cd8411169116601309fb7b8d87ca84bd89a732cb /src | |
parent | bae4aa4a7194e29fe12cb907c3ecc5f300d174e3 (diff) | |
download | dabmod-53c7e3485da3556c43eb9a76bfebe7fd159eb3e0.tar.gz dabmod-53c7e3485da3556c43eb9a76bfebe7fd159eb3e0.tar.bz2 dabmod-53c7e3485da3556c43eb9a76bfebe7fd159eb3e0.zip |
Soapy: set hw time if device supports
Diffstat (limited to 'src')
-rw-r--r-- | src/output/SDR.cpp | 15 | ||||
-rw-r--r-- | src/output/Soapy.cpp | 7 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp index 34341bd..b5741a6 100644 --- a/src/output/SDR.cpp +++ b/src/output/SDR.cpp @@ -247,7 +247,6 @@ void SDR::handle_frame(struct FrameData& frame) return; } - double device_time = m_device->get_real_secs(); const auto& time_spec = frame.ts; if (m_config.enableSync and m_config.muteNoTimestamps and @@ -264,6 +263,8 @@ void SDR::handle_frame(struct FrameData& frame) const uint32_t tx_second = frame.ts.timestamp_sec; const uint32_t tx_pps = frame.ts.timestamp_pps; + const double device_time = m_device->get_real_secs(); + if (not frame.ts.timestamp_valid) { /* We have not received a full timestamp through * MNSC. We sleep through the frame. @@ -277,11 +278,13 @@ void SDR::handle_frame(struct FrameData& frame) if (last_tx_time_initialised) { const size_t sizeIn = frame.buf.size() / sizeof(complexf); - uint64_t increment = (uint64_t)sizeIn * 16384000ul / - (uint64_t)m_config.sampleRate; - // samps * ticks/s / (samps/s) - // (samps * ticks * s) / (s * samps) - // ticks + + // Checking units for the increment calculation: + // samps * ticks/s / (samps/s) + // (samps * ticks * s) / (s * samps) + // ticks + const uint64_t increment = (uint64_t)sizeIn * 16384000ul / + (uint64_t)m_config.sampleRate; uint32_t expected_sec = last_tx_second + increment / 16384000ul; uint32_t expected_pps = last_tx_pps + increment % 16384000ul; diff --git a/src/output/Soapy.cpp b/src/output/Soapy.cpp index 8ee420e..3093b65 100644 --- a/src/output/Soapy.cpp +++ b/src/output/Soapy.cpp @@ -97,6 +97,13 @@ Soapy::Soapy(SDRDeviceConfig& config) : etiLog.level(info) << "SoapySDR:Actual tx antenna: " << m_device->getAntenna(SOAPY_SDR_TX, 0); + if (m_device->hasHardwareTime()) { + using namespace std::chrono; + auto n = system_clock::now(); + const long long ticks = duration_cast<nanoseconds>(n.time_since_epoch()).count(); + m_device->setHardwareTime(ticks); + } + const std::vector<size_t> channels({0}); m_tx_stream = m_device->setupStream(SOAPY_SDR_TX, "CF32", channels); m_device->activateStream(m_tx_stream); |