summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/OutputUHD.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp
index a57a46a..c9e630b 100644
--- a/src/OutputUHD.cpp
+++ b/src/OutputUHD.cpp
@@ -31,6 +31,7 @@
#include "Log.h"
#include "RemoteControl.h"
+#include <cmath>
#include <iostream>
#include <assert.h>
#include <stdexcept>
@@ -96,12 +97,12 @@ OutputUHD::OutputUHD(
double master_clk_rate = myUsrp->get_master_clock_rate();
MDEBUG("OutputUHD:Checking master clock rate: %f...\n", master_clk_rate);
- if (myConf.masterClockRate != master_clk_rate) {
+ if (fabs(master_clk_rate - myConf.masterClockRate) >
+ (myConf.masterClockRate * 1e-6)) {
throw std::runtime_error("Cannot set USRP master_clock_rate. Aborted.");
}
}
-
MDEBUG("OutputUHD:Setting REFCLK and PPS input...\n");
myUsrp->set_clock_source(myConf.refclk_src);
@@ -118,7 +119,8 @@ OutputUHD::OutputUHD(
myUsrp->set_tx_rate(myConf.sampleRate);
MDEBUG("OutputUHD:Actual TX Rate: %f Msps...\n", myUsrp->get_tx_rate());
- if (myConf.sampleRate != myUsrp->get_tx_rate()) {
+ if (fabs(myUsrp->get_tx_rate() / myConf.sampleRate) >
+ myConf.sampleRate * 1e-6) {
MDEBUG("OutputUHD: Cannot set sample\n");
throw std::runtime_error("Cannot set USRP sample rate. Aborted.");
}