Fixed calibration: use the same sampling rate and filter bw when calibrating. Renamed device check to loopback check. Improved debug.
git-svn-id: http://yate.null.ro/svn/yate/trunk@6197 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
5ba976cbe1
commit
86899f4b31
|
@ -1322,7 +1322,7 @@ public:
|
|||
res.test /= samples();
|
||||
res.total /= samples();
|
||||
#endif
|
||||
return res.testOk && res.calOk;
|
||||
return res.testOk;
|
||||
}
|
||||
inline String& dump(String& s, bool full) {
|
||||
float delta = 0;
|
||||
|
@ -2408,7 +2408,7 @@ private:
|
|||
unsigned int findPhaseExpParams(const ComplexVector& swee, float startSweep, float stepSweepp);
|
||||
unsigned int calculateAmpTable();
|
||||
//
|
||||
unsigned int deviceCheck(String* error);
|
||||
unsigned int loopbackCheck(String* error);
|
||||
unsigned int testVga(const char* loc, bool tx, bool preMixer, float omega = 0,
|
||||
String* error = 0);
|
||||
inline unsigned int testVgaCheck(const NamedList& p, const char* loc,
|
||||
|
@ -4571,8 +4571,8 @@ unsigned int BrfLibUsbDevice::calibrate(bool sync, const NamedList& params,
|
|||
txSerialize.drop();
|
||||
rxSerialize.drop();
|
||||
// Check
|
||||
if (params.getBoolValue("device_check",true))
|
||||
BRF_FUNC_CALL_BREAK(deviceCheck(&e));
|
||||
if (params.getBoolValue("loopback_check",true))
|
||||
BRF_FUNC_CALL_BREAK(loopbackCheck(&e));
|
||||
// LMS autocalibration
|
||||
// Pause I/O threads, lock external I/O while calibrating
|
||||
BRF_FUNC_CALL_BREAK(calThreadsPause(true,&e));
|
||||
|
@ -8636,13 +8636,15 @@ unsigned int BrfLibUsbDevice::prepareCalibrateBb(BrfBbCalData& data, bool dc,
|
|||
rxFreq = m_state.m_tx.frequency + (Fs / 4);
|
||||
data.resetOmega(M_PI,0);
|
||||
}
|
||||
s.m_tx.lpfBw = bw;
|
||||
s.m_tx.sampleRate = Fs;
|
||||
s.m_rx.lpfBw = bw;
|
||||
s.m_rx.sampleRate = Fs;
|
||||
s.m_rx.frequency = rxFreq;
|
||||
s.m_tx.vga1 = data.intParam(dc,YSTRING("txvga1"),
|
||||
BRF_TXVGA1_GAIN_DEF,BRF_TXVGA1_GAIN_MIN,BRF_TXVGA1_GAIN_MAX);
|
||||
s.m_tx.vga2 = data.intParam(dc,YSTRING("txvga2"),
|
||||
BRF_TXVGA2_GAIN_DEF,BRF_TXVGA2_GAIN_MIN,BRF_TXVGA2_GAIN_MAX);
|
||||
20,BRF_TXVGA2_GAIN_MIN,BRF_TXVGA2_GAIN_MAX);
|
||||
s.m_rx.vga1 = data.intParam(dc,YSTRING("rxvga1"),
|
||||
BRF_RXVGA1_GAIN_DEF,BRF_RXVGA1_GAIN_MIN,BRF_RXVGA1_GAIN_MAX);
|
||||
s.m_rx.vga2 = data.intParam(dc,YSTRING("rxvga2"),
|
||||
|
@ -8683,8 +8685,8 @@ unsigned int BrfLibUsbDevice::prepareCalibrateBb(BrfBbCalData& data, bool dc,
|
|||
|
||||
unsigned int BrfLibUsbDevice::calibrateBb(BrfBbCalData& data, bool dc, String* error)
|
||||
{
|
||||
const char* oper = dc ? "TX I/Q DC Offset (LO Leakage) calibration" :
|
||||
"TX I/Q Imbalance calibration";
|
||||
const char* oper = dc ? "TX I/Q DC Offset (LO Leakage)" :
|
||||
"TX I/Q Imbalance";
|
||||
Debug(m_owner,DebugAll,"calibrateBb %s [%p]",oper,this);
|
||||
|
||||
// VGA tests
|
||||
|
@ -8713,9 +8715,9 @@ unsigned int BrfLibUsbDevice::calibrateBb(BrfBbCalData& data, bool dc, String* e
|
|||
if (data.boolParam(dc,"dump_status_start"))
|
||||
dumpState(s,data.m_params,true);
|
||||
if (dbg)
|
||||
Debug(m_owner,level,"%s starting [%p]%s",oper,m_owner,encloseDashes(s,true));
|
||||
Debug(m_owner,level,"%s calibration starting [%p]%s",oper,m_owner,encloseDashes(s,true));
|
||||
else
|
||||
Output("%s starting omega_cal=%f omega_test=%f [%p]%s",
|
||||
Output("%s calibration starting omega_cal=%f omega_test=%f [%p]%s",
|
||||
oper,data.omega(true),data.omega(false),m_owner,encloseDashes(s,true));
|
||||
}
|
||||
|
||||
|
@ -8753,7 +8755,7 @@ unsigned int BrfLibUsbDevice::calibrateBb(BrfBbCalData& data, bool dc, String* e
|
|||
result << "I=" << data.m_dcI << " " << "Q=" << data.m_dcQ;
|
||||
else
|
||||
result << "PHASE=" << data.m_phase << " " << "GAIN=" << data.m_gain;
|
||||
Debug(m_owner,level,"%s finished in %s %s [%p]",
|
||||
Debug(m_owner,level,"%s calibration finished in %s %s [%p]",
|
||||
oper,duration.secStr(),result.c_str(),m_owner);
|
||||
}
|
||||
|
||||
|
@ -8838,9 +8840,10 @@ unsigned int BrfLibUsbDevice::calibrateBaseband(String* error)
|
|||
BRF_FUNC_CALL_BREAK(prepareCalibrateBb(data,false,&e));
|
||||
BRF_FUNC_CALL_BREAK(calibrateBb(data,false,&e));
|
||||
// Update calibrated data
|
||||
m_calibration.addParam("frequency",String(data.m_calFreq));
|
||||
m_calibration.addParam("samplerate",String(data.m_calSampleRate));
|
||||
m_calibration.addParam("filter",String(m_state.m_tx.lpfBw));
|
||||
// Use initial tunning values: we may change them during calibration
|
||||
m_calibration.addParam("frequency",String(oldState.m_tx.frequency));
|
||||
m_calibration.addParam("samplerate",String(oldState.m_tx.sampleRate));
|
||||
m_calibration.addParam("filter",String(oldState.m_tx.lpfBw));
|
||||
m_calibration.addParam("cal_tx_dc_i",String(data.m_dcI));
|
||||
m_calibration.addParam("cal_tx_dc_q",String(data.m_dcQ));
|
||||
m_calibration.addParam("cal_tx_fpga_corr_phase",String(data.m_phase));
|
||||
|
@ -8900,17 +8903,17 @@ unsigned int BrfLibUsbDevice::calibrateBaseband(String* error)
|
|||
return showError(status,e,0,error);
|
||||
}
|
||||
|
||||
unsigned int BrfLibUsbDevice::deviceCheck(String* error)
|
||||
unsigned int BrfLibUsbDevice::loopbackCheck(String* error)
|
||||
{
|
||||
Configuration cfg;
|
||||
loadCfg(&cfg,false);
|
||||
NamedList& p = *cfg.createSection(YSTRING("device-check"));
|
||||
NamedList& p = *cfg.createSection(YSTRING("loopback-check"));
|
||||
// Prepare data dump
|
||||
m_dbgMutex.lock();
|
||||
BrfDumpFile dump(&p,m_devCheckFile);
|
||||
m_dbgMutex.unlock();
|
||||
|
||||
Debug(m_owner,DebugNote,"Device check starting ... [%p]",m_owner);
|
||||
Debug(m_owner,DebugNote,"Loopback check starting ... [%p]",m_owner);
|
||||
BrfDuration duration;
|
||||
String e;
|
||||
unsigned int status = 0;
|
||||
|
@ -8923,7 +8926,7 @@ unsigned int BrfLibUsbDevice::deviceCheck(String* error)
|
|||
m_state.m_tx.frequency,0);
|
||||
if (!txFreq)
|
||||
BRF_FUNC_CALL_BREAK(setErrorFail(&e,"Frequency not set"));
|
||||
unsigned int nBuffs = p.getIntValue("buffers",5,1);
|
||||
unsigned int nBuffs = p.getIntValue("buffers",10,1);
|
||||
unsigned int bw = m_state.m_tx.lpfBw;
|
||||
unsigned int sampleRate = m_state.m_tx.sampleRate;
|
||||
bw = p.getIntValue(YSTRING("bandwidth"),bw ? bw : 1500000,1500000);
|
||||
|
@ -8942,7 +8945,7 @@ unsigned int BrfLibUsbDevice::deviceCheck(String* error)
|
|||
minDeltaFreq + (maxDeltaFreq - minDeltaFreq) / 2,minDeltaFreq,maxDeltaFreq);
|
||||
if (deltaFreq == (sampleRate / 4)) {
|
||||
// TODO: Properly adjust it
|
||||
Debug(m_owner,DebugStub,"Device check adjusting delta freq [%p]",m_owner);
|
||||
Debug(m_owner,DebugStub,"Loopback check adjusting delta freq [%p]",m_owner);
|
||||
deltaFreq += 1000;
|
||||
}
|
||||
// Sanity check
|
||||
|
@ -9041,7 +9044,7 @@ unsigned int BrfLibUsbDevice::deviceCheck(String* error)
|
|||
}
|
||||
}
|
||||
t.append(tmp,"\r\n");
|
||||
Output("Device check: frequency tx=%u rx=%u (delta=%u omega=%f) "
|
||||
Output("Loopback check: frequency tx=%u rx=%u (delta=%u omega=%f) "
|
||||
"samplerate=%u bandwidth=%u samples=%u buffers=%u [%p]%s",
|
||||
txFreq,rxFreq,deltaFreq,omega,sampleRate,bw,buf.length(),
|
||||
nBuffs,m_owner,encloseDashes(t,true));
|
||||
|
@ -9060,8 +9063,11 @@ unsigned int BrfLibUsbDevice::deviceCheck(String* error)
|
|||
// Run it
|
||||
int dumpRxBeforeRead = p.getIntValue(YSTRING("dump_before_read_rx"),0,0);
|
||||
int dumpTxBeforeRead = p.getIntValue(YSTRING("dump_before_read_tx"),0,0);
|
||||
unsigned int allowFail = p.getIntValue(YSTRING("allow_fail"),0,0,nBuffs - 1);
|
||||
for (unsigned int i = 0; i < nBuffs; i++) {
|
||||
unsigned int tmp = nBuffs / 4;
|
||||
unsigned int limitFailures =
|
||||
p.getIntValue(YSTRING("sample_limit_allow_fail"),tmp,0,nBuffs - 1);
|
||||
unsigned int allowFail = p.getIntValue(YSTRING("allow_fail"),tmp,0,nBuffs - 1);
|
||||
for (int i = 0; i < (int)nBuffs; i++) {
|
||||
if (dumpRxBeforeRead) {
|
||||
dumpRxBeforeRead--;
|
||||
showBuf(false,1,false);
|
||||
|
@ -9075,8 +9081,19 @@ unsigned int BrfLibUsbDevice::deviceCheck(String* error)
|
|||
uint64_t ts = m_syncTxState.m_tx.m_timestamp + m_radioCaps.rxLatency;
|
||||
BRF_FUNC_CALL_BREAK(capture(false,(float*)buf.data(),buf.length(),ts,&e));
|
||||
// Check for out of range values
|
||||
BRF_FUNC_CALL_BREAK(checkSampleLimit((float*)buf.data(),buf.length(),
|
||||
limit,&e));
|
||||
status = checkSampleLimit((float*)buf.data(),buf.length(),limit,&e);
|
||||
if (status) {
|
||||
if (trace)
|
||||
Output("%-5u [%10s]\tsample invalid (remains=%d): %s",
|
||||
i,String(ts).c_str(),limitFailures,e.c_str());
|
||||
if (!limitFailures)
|
||||
break;
|
||||
limitFailures--;
|
||||
i--;
|
||||
e.clear();
|
||||
status = 0;
|
||||
continue;
|
||||
}
|
||||
// Apply test pattern (check algorithm)
|
||||
if (testPattern.length())
|
||||
buf.copy(testPattern,testPattern.length());
|
||||
|
@ -9116,18 +9133,18 @@ unsigned int BrfLibUsbDevice::deviceCheck(String* error)
|
|||
break;
|
||||
}
|
||||
allowFail--;
|
||||
DDebug(m_owner,DebugInfo,"Device check failure %s [%p]",e.safe(),m_owner);
|
||||
DDebug(m_owner,DebugInfo,"Loopback check failure %s [%p]",e.safe(),m_owner);
|
||||
e.clear();
|
||||
}
|
||||
if (status)
|
||||
break;
|
||||
if (trace == 1)
|
||||
Output("Device check succesfully ended");
|
||||
Output("Loopback check succesfully ended");
|
||||
// VGA test
|
||||
BRF_FUNC_CALL_BREAK(testVgaCheck(p,"Device check",omega,&e));
|
||||
BRF_FUNC_CALL_BREAK(testVgaCheck(p,"Loopback check",omega,&e));
|
||||
break;
|
||||
}
|
||||
Debug(m_owner,DebugAll,"Finalizing device check [%p]",m_owner);
|
||||
Debug(m_owner,DebugAll,"Finalizing loopback check [%p]",m_owner);
|
||||
if (!status) {
|
||||
calThreadsPause(true);
|
||||
status = setState(oldState,&e);
|
||||
|
@ -9135,11 +9152,11 @@ unsigned int BrfLibUsbDevice::deviceCheck(String* error)
|
|||
}
|
||||
duration.stop();
|
||||
if (status == 0) {
|
||||
Debug(m_owner,DebugNote,"Device check ended duration=%s [%p]",
|
||||
Debug(m_owner,DebugNote,"Loopback check ended duration=%s [%p]",
|
||||
duration.secStr(),m_owner);
|
||||
return 0;
|
||||
}
|
||||
e.printf(1024,"Device check failed: %s",e.c_str());
|
||||
e.printf(1024,"Loopback check failed: %s",e.c_str());
|
||||
return showError(status,e,0,error);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue