aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-03-17 23:09:05 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-03-17 23:09:05 +0100
commita5e82cbf790aaa0d7f352da51398abfb8352afc6 (patch)
tree6d41cd677f85448c38dca46e147a70e210fade51 /src
parentfdb59da8301c3679c6cebf54022b24048370184b (diff)
downloaddabmod-a5e82cbf790aaa0d7f352da51398abfb8352afc6.tar.gz
dabmod-a5e82cbf790aaa0d7f352da51398abfb8352afc6.tar.bz2
dabmod-a5e82cbf790aaa0d7f352da51398abfb8352afc6.zip
Do not compare floats for equality. Use a 1PPM window instead
Diffstat (limited to 'src')
-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.");
}