|
|
@ -1,6 +1,7 @@
|
|
|
|
#include "lf.h"
|
|
|
|
#include "lf.h"
|
|
|
|
|
|
|
|
#include <QJsonArray>
|
|
|
|
|
|
|
|
|
|
|
|
const LF::Config LF::defaultConfig;
|
|
|
|
const LF::LFConfig LF::defaultLFConfig;
|
|
|
|
|
|
|
|
|
|
|
|
LF::LF(Ui::MainWindow *ui, Util *addr, QWidget *parent): QObject(parent)
|
|
|
|
LF::LF(Ui::MainWindow *ui, Util *addr, QWidget *parent): QObject(parent)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -8,142 +9,122 @@ LF::LF(Ui::MainWindow *ui, Util *addr, QWidget *parent): QObject(parent)
|
|
|
|
util = addr;
|
|
|
|
util = addr;
|
|
|
|
this->ui = ui;
|
|
|
|
this->ui = ui;
|
|
|
|
|
|
|
|
|
|
|
|
configPattern = new QRegularExpression("(\\d+)|Yes|No");
|
|
|
|
LFconfigPattern = new QRegularExpression("(\\d+)|Yes|No");
|
|
|
|
currConfig = defaultConfig;
|
|
|
|
currLFConfig = defaultLFConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LF::read()
|
|
|
|
void LF::read()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
|
|
|
QVariantMap config = configMap["read"].toMap();
|
|
|
|
util->execCMD("lf read");
|
|
|
|
util->execCMD(config["cmd"].toString());
|
|
|
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
|
|
|
|
util->execCMD("lf read -v");
|
|
|
|
|
|
|
|
Util::gotoRawTab();
|
|
|
|
Util::gotoRawTab();
|
|
|
|
util->execCMD("data plot");
|
|
|
|
util->execCMD(config["show cmd"].toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LF::sniff()
|
|
|
|
void LF::sniff()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
|
|
|
QVariantMap config = configMap["sniff"].toMap();
|
|
|
|
util->execCMD("lf snoop");
|
|
|
|
util->execCMD(config["cmd"].toString());
|
|
|
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
|
|
|
|
util->execCMD("lf sniff -v");
|
|
|
|
|
|
|
|
Util::gotoRawTab();
|
|
|
|
Util::gotoRawTab();
|
|
|
|
util->execCMD("data plot");
|
|
|
|
util->execCMD(config["show cmd"].toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LF::search()
|
|
|
|
void LF::search()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
|
|
|
QVariantMap config = configMap["search"].toMap();
|
|
|
|
util->execCMD("lf search u");
|
|
|
|
util->execCMD(config["cmd"].toString());
|
|
|
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
|
|
|
|
util->execCMD("lf search -u");
|
|
|
|
|
|
|
|
Util::gotoRawTab();
|
|
|
|
Util::gotoRawTab();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LF::tune()
|
|
|
|
void LF::tune()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
|
|
|
QVariantMap config = configMap["tune"].toMap();
|
|
|
|
util->execCMD("hw tune l");
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
cmd.replace("<divisor>", QString::number(currLFConfig.divisor));
|
|
|
|
util->execCMD("lf tune --divisor " + QString::number(currConfig.divisor));
|
|
|
|
util->execCMD(cmd);
|
|
|
|
Util::gotoRawTab();
|
|
|
|
Util::gotoRawTab();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LF::getConfig()
|
|
|
|
bool LF::getLFConfig_helper(const QVariantMap& map, QString& str, int* result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
QString flag = map["flag"].toString();
|
|
|
|
QRegularExpressionMatch reMatch;
|
|
|
|
QRegularExpressionMatch reMatch;
|
|
|
|
QString result;
|
|
|
|
if(!str.contains(flag))
|
|
|
|
QStringList resultList;
|
|
|
|
return false;
|
|
|
|
QStringList symbolList =
|
|
|
|
len = str.length() - (str.indexOf(flag) + flag.length());
|
|
|
|
{
|
|
|
|
str = str.right(len);
|
|
|
|
"divisor",
|
|
|
|
if(map.contains("replace"))
|
|
|
|
"bps",
|
|
|
|
|
|
|
|
"bits per sample",
|
|
|
|
|
|
|
|
"decimation",
|
|
|
|
|
|
|
|
"averaging",
|
|
|
|
|
|
|
|
"trigger threshold",
|
|
|
|
|
|
|
|
"samples to skip"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
QStringList configList = {"", "", "", "", "", "", ""};
|
|
|
|
|
|
|
|
result = util->execCMDWithOutput("hw status", 400); // not all output from "hw status will be processed".
|
|
|
|
|
|
|
|
result = result.right(result.length() - result.indexOf("LF Sampling config"));
|
|
|
|
|
|
|
|
offset = result.indexOf("samples to skip");
|
|
|
|
|
|
|
|
offset = result.indexOf("\n", offset);
|
|
|
|
|
|
|
|
result = result.mid(0, offset + 2);
|
|
|
|
|
|
|
|
qDebug() << "LF CONFIG GET\n" << result;
|
|
|
|
|
|
|
|
resultList = result.split("\n");
|
|
|
|
|
|
|
|
for(int i = 0; i < resultList.length(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(int j = 0; j < symbolList.length(); j++)
|
|
|
|
QVariantMap table = map["replace"].toMap();
|
|
|
|
|
|
|
|
for(auto it = table.begin(); it != table.end(); it++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!configList[j].isEmpty())
|
|
|
|
str.replace(it.key(), it.value().toString());
|
|
|
|
continue;
|
|
|
|
|
|
|
|
offset = resultList[i].indexOf(symbolList[j]);
|
|
|
|
|
|
|
|
if(offset != -1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
reMatch = configPattern->match(resultList[i]);
|
|
|
|
|
|
|
|
qDebug() << "finded: " << resultList[i];
|
|
|
|
|
|
|
|
if(!reMatch.hasMatch())
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
qDebug() << "captured: " << reMatch.captured();
|
|
|
|
|
|
|
|
configList[j] = reMatch.captured();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
qDebug() << "configList: " << configList;
|
|
|
|
reMatch = QRegularExpression(map["pattern"].toString()).match(str);
|
|
|
|
currConfig.divisor = configList[0].toUInt();
|
|
|
|
if(!reMatch.hasMatch())
|
|
|
|
currConfig.decimation = configList[3].toUInt();
|
|
|
|
return false;
|
|
|
|
currConfig.triggerThreshold = configList[5].toUInt();
|
|
|
|
*result = reMatch.captured().toInt();
|
|
|
|
currConfig.samplesToSkip = configList[6].toUInt();
|
|
|
|
qDebug() << *result;
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
|
|
|
return true;
|
|
|
|
{
|
|
|
|
|
|
|
|
currConfig.bitPerSample = configList[1].toUInt();
|
|
|
|
}
|
|
|
|
currConfig.averaging = (configList[4] == "1");
|
|
|
|
|
|
|
|
}
|
|
|
|
void LF::getLFConfig()
|
|
|
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QRegularExpressionMatch reMatch;
|
|
|
|
|
|
|
|
QString result;
|
|
|
|
|
|
|
|
QStringList resultList;
|
|
|
|
|
|
|
|
int start, end, temp;
|
|
|
|
|
|
|
|
QVariantMap config = configMap["get config"].toMap();
|
|
|
|
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
|
|
|
|
result = util->execCMDWithOutput(cmd, 400);
|
|
|
|
|
|
|
|
start = result.indexOf(config["field start"].toString());
|
|
|
|
|
|
|
|
end = result.indexOf(config["field end"].toString());
|
|
|
|
|
|
|
|
result = result.mid(start, end - start);
|
|
|
|
|
|
|
|
resultList = result.split("\n", Qt::SkipEmptyParts);
|
|
|
|
|
|
|
|
qDebug() << "LF CONFIG GET\n" << resultList;
|
|
|
|
|
|
|
|
for(auto it = resultList.begin(); it != resultList.end(); it++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
currConfig.bitPerSample = configList[2].toUInt();
|
|
|
|
if(getLFConfig_helper(config["divisor"].toMap(), *it, &temp))
|
|
|
|
currConfig.averaging = (configList[4] == "Yes");
|
|
|
|
currLFConfig.divisor = temp;
|
|
|
|
|
|
|
|
else if(getLFConfig_helper(config["bits per sample"].toMap(), *it, &temp))
|
|
|
|
|
|
|
|
currLFConfig.bitsPerSample = temp;
|
|
|
|
|
|
|
|
else if(getLFConfig_helper(config["decimation"].toMap(), *it, &temp))
|
|
|
|
|
|
|
|
currLFConfig.decimation = temp;
|
|
|
|
|
|
|
|
else if(getLFConfig_helper(config["averaging"].toMap(), *it, &temp))
|
|
|
|
|
|
|
|
currLFConfig.averaging = (bool)temp;
|
|
|
|
|
|
|
|
else if(getLFConfig_helper(config["trigger threshold"].toMap(), *it, &temp))
|
|
|
|
|
|
|
|
currLFConfig.triggerThreshold = temp;
|
|
|
|
|
|
|
|
else if(getLFConfig_helper(config["samples to skip"].toMap(), *it, &temp))
|
|
|
|
|
|
|
|
currLFConfig.samplesToSkip = temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
syncWithUI();
|
|
|
|
syncWithUI();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LF::setConfig(LF::Config config)
|
|
|
|
void LF::setLFConfig(LF::LFConfig lfconfig)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
currConfig = config;
|
|
|
|
currLFConfig = lfconfig;
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
|
|
|
QVariantMap config = configMap["set config"].toMap();
|
|
|
|
{
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
util->execCMDWithOutput(QString("lf config")
|
|
|
|
cmd.replace("<divisor>", QString::number(currLFConfig.divisor));
|
|
|
|
+ " q " + QString::number(currConfig.divisor)
|
|
|
|
cmd.replace("<bits per sample>", QString::number(currLFConfig.bitsPerSample));
|
|
|
|
+ " b " + QString::number(currConfig.bitPerSample)
|
|
|
|
cmd.replace("<decimation>", QString::number(currLFConfig.decimation));
|
|
|
|
+ " d " + QString::number(currConfig.decimation)
|
|
|
|
cmd.replace("<averaging>", currLFConfig.averaging ? "1" : "0");
|
|
|
|
+ " a " + QString(currConfig.averaging ? "1" : "0")
|
|
|
|
cmd.replace("<trigger threshold>", QString::number(currLFConfig.triggerThreshold));
|
|
|
|
+ " t " + QString::number(currConfig.triggerThreshold)
|
|
|
|
cmd.replace("<samples to skip>", QString::number(currLFConfig.samplesToSkip));
|
|
|
|
+ " s " + QString::number(currConfig.samplesToSkip),
|
|
|
|
util->execCMDWithOutput(cmd, 500);
|
|
|
|
500);
|
|
|
|
cmd = config["divisor cmd"].toString();
|
|
|
|
util->execCMDWithOutput("hw setlfdivisor " + QString::number(currConfig.divisor), 500);
|
|
|
|
cmd.replace("<divisor>", QString::number(currLFConfig.divisor));
|
|
|
|
}
|
|
|
|
util->execCMDWithOutput(cmd, 500);
|
|
|
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
util->execCMDWithOutput(QString("lf config")
|
|
|
|
|
|
|
|
+ " -a " + QString(currConfig.averaging ? "1" : "0")
|
|
|
|
|
|
|
|
+ " -b " + QString::number(currConfig.bitPerSample)
|
|
|
|
|
|
|
|
+ " --dec " + QString::number(currConfig.decimation)
|
|
|
|
|
|
|
|
+ " --divisor " + QString::number(currConfig.divisor)
|
|
|
|
|
|
|
|
+ " -s " + QString::number(currConfig.samplesToSkip)
|
|
|
|
|
|
|
|
+ " -t " + QString::number(currConfig.triggerThreshold),
|
|
|
|
|
|
|
|
500);
|
|
|
|
|
|
|
|
util->execCMDWithOutput("hw setlfdivisor -d " + QString::number(currConfig.divisor), 500);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LF::resetConfig()
|
|
|
|
void LF::resetLFConfig()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setConfig(defaultConfig);
|
|
|
|
setLFConfig(defaultLFConfig);
|
|
|
|
getConfig();
|
|
|
|
getLFConfig();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float LF::divisor2Freq(uint8_t divisor)
|
|
|
|
float LF::divisor2Freq(uint8_t divisor)
|
|
|
@ -158,10 +139,16 @@ uint8_t LF::freq2Divisor(float freq)
|
|
|
|
|
|
|
|
|
|
|
|
void LF::syncWithUI()
|
|
|
|
void LF::syncWithUI()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->LF_Conf_freqDivisorBox->setValue(currConfig.divisor); // will trigger valueChanged()
|
|
|
|
ui->LF_LFConf_freqDivisorBox->setValue(currLFConfig.divisor); // will trigger valueChanged()
|
|
|
|
ui->LF_Conf_bitPerSampleBox->setValue(currConfig.bitPerSample);
|
|
|
|
ui->LF_LFConf_bitsPerSampleBox->setValue(currLFConfig.bitsPerSample);
|
|
|
|
ui->LF_Conf_decimationBox->setValue(currConfig.decimation);
|
|
|
|
ui->LF_LFConf_decimationBox->setValue(currLFConfig.decimation);
|
|
|
|
ui->LF_Conf_averagingBox->setChecked(currConfig.averaging);
|
|
|
|
ui->LF_LFConf_averagingBox->setChecked(currLFConfig.averaging);
|
|
|
|
ui->LF_Conf_thresholdBox->setValue(currConfig.triggerThreshold);
|
|
|
|
ui->LF_LFConf_thresholdBox->setValue(currLFConfig.triggerThreshold);
|
|
|
|
ui->LF_Conf_skipsBox->setValue(currConfig.samplesToSkip);
|
|
|
|
ui->LF_LFConf_skipsBox->setValue(currLFConfig.samplesToSkip);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LF::setConfigMap(const QVariantMap& configMap)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this->configMap = configMap;
|
|
|
|
|
|
|
|
qDebug() << configMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|