Redhawk FEI 采样率公差检查失败?
Redhawk FEI sample rate tolerance check failure?
我正在构建一个 Redhawk 2.1.2 FEI 设备,当我尝试通过 IDE 进行分配时遇到容差检查失败(还没有尝试过 python 接口或任何东西) .请求是针对 8 MHz 的,我得到的 return 值为 7999999.93575246725231409 Hz,在 20% 的公差范围内,但我仍然收到此错误:
2017-12-24 11:27:10 DEBUG FrontendTunerDevice:484 - allocateCapacity - SR requested: 8000000.000000 SR got: 7999999.935752
2017-12-24 11:27:10 INFO FrontendTunerDevice:490 - allocateCapacity(0): returned sr 7999999.935752 does not meet tolerance criteria of 20.000000 percent
来自 frontendInterfaces/libsrc/cpp/fe_tuner_device.cpp
的违规代码:
// check tolerances
if( (floatingPointCompare(frontend_tuner_allocation.sample_rate,0)!=0) &&
(floatingPointCompare(frontend_tuner_status[tuner_id].sample_rate,frontend_tuner_allocation.sample_rate)<0 ||
floatingPointCompare(frontend_tuner_status[tuner_id].sample_rate,frontend_tuner_allocation.sample_rate+frontend_tuner_allocation.sample_rate * frontend_tuner_allocation.sample_rate_tolerance/100.0)>0 ))
{
std::ostringstream eout;
eout<<std::fixed<<"allocateCapacity("<<int(tuner_id)<<"): returned sr "<<frontend_tuner_status[tuner_id].sample_rate<<" does not meet tolerance criteria of "<<frontend_tuner_allocation.sample_rate_tolerance<<" percent";
LOG_INFO(FrontendTunerDevice<TunerStatusStructType>, eout.str());
throw std::logic_error(eout.str().c_str());
}
以及来自 frontendInterfaces/libsrc/cpp/fe_tuner_device.h
的函数:
inline double floatingPointCompare(double lhs, double rhs, size_t places = 1){
return round((lhs-rhs)*pow(10,places));
/*if(round((lhs-rhs)*(pow(10,places))) == 0)
return 0; // equal
if(lhs<rhs)
return -1; // lhs < rhs
return 1; // lhs > rhs*/
}
我实际上复制了一个非 Redhawk C++ 程序,我用它来测试设备接口和检查通过。我打破了一切以找出不同之处,并注意到在 Redhawk 中,从设备 returned 的采样率(或至少打印到屏幕上)与 Redhawk 之外的采样率略有不同 - 就像一小部分赫兹:
// in Redhawk using cout::precision(17)
Sample Rate: 7999999.93575246725231409
// outside Redhawk using cout::precision(17)
Sample Rate: 7999999.96948242187500000
我不知道为什么实际采样率会有所不同 returned 但在 Redhawk 版本中它足以使检查的第二部分失败:
floatingPointCompare(7999999.93575246725231409,8000000.00000000000000000)<0
1
主要是因为:
double a = 7999999.93575246725231409 - 8000000.00000000000000000; // = -0.06424753274768591
double b = pow(10,1); // = 10.00000000000000000
double c = a*b; // = -0.6424753274
double d = round(c); // = -1.00000000000000000
因此,如果 returned 采样率比请求低 0.049999 Hz 以上,那么无论容差 % 是多少,分配都会失败 ?也许我只是在这里遗漏了一些东西。
某处应该有一份文件对此进行了详细描述,但我去了 FMRdsSimulator 设备的来源。
// For FEI tolerance, it is not a +/- it's give me this or better.
float minAcceptableSampleRate = request.sample_rate;
float maxAcceptableSampleRate = (1 + request.sample_rate_tolerance/100.0) * request.sample_rate;
所以这应该可以解释分配失败的原因。
公差检查被指定为最小金额加上增量而不是请求金额的差异(正负)。
我正在构建一个 Redhawk 2.1.2 FEI 设备,当我尝试通过 IDE 进行分配时遇到容差检查失败(还没有尝试过 python 接口或任何东西) .请求是针对 8 MHz 的,我得到的 return 值为 7999999.93575246725231409 Hz,在 20% 的公差范围内,但我仍然收到此错误:
2017-12-24 11:27:10 DEBUG FrontendTunerDevice:484 - allocateCapacity - SR requested: 8000000.000000 SR got: 7999999.935752
2017-12-24 11:27:10 INFO FrontendTunerDevice:490 - allocateCapacity(0): returned sr 7999999.935752 does not meet tolerance criteria of 20.000000 percent
来自 frontendInterfaces/libsrc/cpp/fe_tuner_device.cpp
的违规代码:
// check tolerances
if( (floatingPointCompare(frontend_tuner_allocation.sample_rate,0)!=0) &&
(floatingPointCompare(frontend_tuner_status[tuner_id].sample_rate,frontend_tuner_allocation.sample_rate)<0 ||
floatingPointCompare(frontend_tuner_status[tuner_id].sample_rate,frontend_tuner_allocation.sample_rate+frontend_tuner_allocation.sample_rate * frontend_tuner_allocation.sample_rate_tolerance/100.0)>0 ))
{
std::ostringstream eout;
eout<<std::fixed<<"allocateCapacity("<<int(tuner_id)<<"): returned sr "<<frontend_tuner_status[tuner_id].sample_rate<<" does not meet tolerance criteria of "<<frontend_tuner_allocation.sample_rate_tolerance<<" percent";
LOG_INFO(FrontendTunerDevice<TunerStatusStructType>, eout.str());
throw std::logic_error(eout.str().c_str());
}
以及来自 frontendInterfaces/libsrc/cpp/fe_tuner_device.h
的函数:
inline double floatingPointCompare(double lhs, double rhs, size_t places = 1){
return round((lhs-rhs)*pow(10,places));
/*if(round((lhs-rhs)*(pow(10,places))) == 0)
return 0; // equal
if(lhs<rhs)
return -1; // lhs < rhs
return 1; // lhs > rhs*/
}
我实际上复制了一个非 Redhawk C++ 程序,我用它来测试设备接口和检查通过。我打破了一切以找出不同之处,并注意到在 Redhawk 中,从设备 returned 的采样率(或至少打印到屏幕上)与 Redhawk 之外的采样率略有不同 - 就像一小部分赫兹:
// in Redhawk using cout::precision(17)
Sample Rate: 7999999.93575246725231409
// outside Redhawk using cout::precision(17)
Sample Rate: 7999999.96948242187500000
我不知道为什么实际采样率会有所不同 returned 但在 Redhawk 版本中它足以使检查的第二部分失败:
floatingPointCompare(7999999.93575246725231409,8000000.00000000000000000)<0
1
主要是因为:
double a = 7999999.93575246725231409 - 8000000.00000000000000000; // = -0.06424753274768591
double b = pow(10,1); // = 10.00000000000000000
double c = a*b; // = -0.6424753274
double d = round(c); // = -1.00000000000000000
因此,如果 returned 采样率比请求低 0.049999 Hz 以上,那么无论容差 % 是多少,分配都会失败 ?也许我只是在这里遗漏了一些东西。
某处应该有一份文件对此进行了详细描述,但我去了 FMRdsSimulator 设备的来源。
// For FEI tolerance, it is not a +/- it's give me this or better.
float minAcceptableSampleRate = request.sample_rate;
float maxAcceptableSampleRate = (1 + request.sample_rate_tolerance/100.0) * request.sample_rate;
所以这应该可以解释分配失败的原因。
公差检查被指定为最小金额加上增量而不是请求金额的差异(正负)。