mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-04-21 03:56:19 +08:00
LF: support read LF config
This commit is contained in:
parent
019afed198
commit
466cd0ecc1
@ -6,6 +6,7 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LF::read()
|
void LF::read()
|
||||||
@ -45,3 +46,89 @@ void LF::tune()
|
|||||||
util->execCMD("lf tune"); // TODO: if freq is set, append it as a parameter
|
util->execCMD("lf tune"); // TODO: if freq is set, append it as a parameter
|
||||||
Util::gotoRawTab();
|
Util::gotoRawTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LF::getConfig()
|
||||||
|
{
|
||||||
|
QRegularExpressionMatch reMatch;
|
||||||
|
QString result;
|
||||||
|
QStringList resultList;
|
||||||
|
QStringList symbolList =
|
||||||
|
{
|
||||||
|
"divisor",
|
||||||
|
"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("\r\n", offset);
|
||||||
|
result = result.mid(0, offset + 2);
|
||||||
|
qDebug() << "LF CONFIG GET\n" << result;
|
||||||
|
resultList = result.split("\r\n");
|
||||||
|
for(int i = 0; i < resultList.length(); i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < symbolList.length(); j++)
|
||||||
|
{
|
||||||
|
if(!configList[j].isEmpty())
|
||||||
|
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;
|
||||||
|
currConfig.divisor = configList[0].toUInt();
|
||||||
|
currConfig.decimation = configList[3].toUInt();
|
||||||
|
currConfig.triggerThreshold = configList[5].toUInt();
|
||||||
|
currConfig.samplesToSkip = configList[6].toUInt();
|
||||||
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
||||||
|
{
|
||||||
|
currConfig.bitPerSample = configList[1].toUInt();
|
||||||
|
currConfig.averaging = (configList[4] == "1");
|
||||||
|
}
|
||||||
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||||
|
{
|
||||||
|
currConfig.bitPerSample = configList[2].toUInt();
|
||||||
|
currConfig.averaging = (configList[4] == "Yes");
|
||||||
|
}
|
||||||
|
syncWithUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LF::setConfig()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
float LF::divisor2Freq(uint8_t divisor)
|
||||||
|
{
|
||||||
|
return (12000.0 / (divisor + 1.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t LF::freq2Divisor(float freq)
|
||||||
|
{
|
||||||
|
return ((uint16_t)(12000.0 / freq + 0.5) - 1); // uint16_t for (divisor + 1) = 256
|
||||||
|
}
|
||||||
|
|
||||||
|
void LF::syncWithUI()
|
||||||
|
{
|
||||||
|
ui->LF_Conf_freqDivisorBox->setValue(currConfig.divisor);
|
||||||
|
ui->LF_Conf_bitPerSampleBox->setValue(currConfig.bitPerSample);
|
||||||
|
ui->LF_Conf_decimationBox->setValue(currConfig.decimation);
|
||||||
|
ui->LF_Conf_averagingBox->setChecked(currConfig.averaging);
|
||||||
|
ui->LF_Conf_thresholdBox->setValue(currConfig.triggerThreshold);
|
||||||
|
ui->LF_Conf_skipsBox->setValue(currConfig.samplesToSkip);
|
||||||
|
}
|
||||||
|
18
module/lf.h
18
module/lf.h
@ -12,15 +12,31 @@ class LF : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit LF(Ui::MainWindow *ui, Util *addr, QWidget *parent = nullptr);
|
explicit LF(Ui::MainWindow *ui, Util *addr, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
struct Config
|
||||||
|
{
|
||||||
|
uint8_t divisor;
|
||||||
|
uint8_t bitPerSample;
|
||||||
|
uint8_t decimation;
|
||||||
|
bool averaging;
|
||||||
|
uint8_t triggerThreshold;
|
||||||
|
uint16_t samplesToSkip;
|
||||||
|
};
|
||||||
|
|
||||||
void read();
|
void read();
|
||||||
void sniff();
|
void sniff();
|
||||||
void search();
|
void search();
|
||||||
void tune();
|
void tune();
|
||||||
|
void getConfig();
|
||||||
|
void setConfig();
|
||||||
|
static float divisor2Freq(uint8_t divisor);
|
||||||
|
static uint8_t freq2Divisor(float freq);
|
||||||
private:
|
private:
|
||||||
QWidget* parent;
|
QWidget* parent;
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
Util* util;
|
Util* util;
|
||||||
|
Config currConfig;
|
||||||
|
QRegularExpression* configPattern;
|
||||||
|
void syncWithUI();
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1251,7 +1251,7 @@ void MainWindow::onLFfreqConfChanged(int value, bool isCustomized)
|
|||||||
|
|
||||||
if(isCustomized)
|
if(isCustomized)
|
||||||
ui->LF_Conf_freqOtherButton->setChecked(true);
|
ui->LF_Conf_freqOtherButton->setChecked(true);
|
||||||
ui->LF_Conf_freqLabel->setText(QString("Actural Freq: %1kHz").arg(12000.0 / (value + 1.0), 0, 'f', 3));
|
ui->LF_Conf_freqLabel->setText(QString("Actural Freq: %1kHz").arg(LF::divisor2Freq(value), 0, 'f', 3));
|
||||||
ui->LF_Conf_freqDivisorBox->setValue(value);
|
ui->LF_Conf_freqDivisorBox->setValue(value);
|
||||||
ui->LF_Conf_freqSlider->setValue(value);
|
ui->LF_Conf_freqSlider->setValue(value);
|
||||||
|
|
||||||
@ -1334,3 +1334,8 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
{
|
{
|
||||||
contextMenu->exec(event->globalPos());
|
contextMenu->exec(event->globalPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_LF_Conf_getButton_clicked()
|
||||||
|
{
|
||||||
|
lf->getConfig();
|
||||||
|
}
|
||||||
|
@ -197,6 +197,8 @@ private slots:
|
|||||||
|
|
||||||
void on_LF_Op_sniffButton_clicked();
|
void on_LF_Op_sniffButton_clicked();
|
||||||
|
|
||||||
|
void on_LF_Conf_getButton_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
QButtonGroup* MFCardTypeBtnGroup;
|
QButtonGroup* MFCardTypeBtnGroup;
|
||||||
|
@ -136,7 +136,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="mifareTab">
|
<widget class="QWidget" name="mifareTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -1442,10 +1442,14 @@ You might need a modified LF antenna if the freq is not 125k/134k.</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QSpinBox" name="LF_Conf_skipsBox"/>
|
<widget class="QSpinBox" name="LF_Conf_skipsBox">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>65535</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QSpinBox" name="LF_Conf_bitRateBox">
|
<widget class="QSpinBox" name="LF_Conf_bitPerSampleBox">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
@ -1689,7 +1693,7 @@ On Iceman/RRG repo, press the button on PM3 to stop measuring</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_27">
|
<widget class="QLabel" name="label_27">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Sniff low frequency signal wit LF field OFF.
|
<string>Sniff low frequency signal with LF field OFF.
|
||||||
Use this to get raw data from a reader
|
Use this to get raw data from a reader
|
||||||
or the communication between a tag and a reader.</string>
|
or the communication between a tag and a reader.</string>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user