Add MF_ReadAll function

pull/2/head
wh201906 5 years ago
parent 1d8d931752
commit c25e2f9e4a

@ -110,13 +110,7 @@ void MainWindow::on_Raw_CMDHistoryWidget_itemDoubleClicked(QListWidgetItem *item
void MainWindow::on_MF_Attack_chkButton_clicked() void MainWindow::on_MF_Attack_chkButton_clicked()
{ {
pm3->setRequiringOutput(true); QString result = execCMDWithOutput("hf mf chk *1 ?");
execCMD("hf mf chk *1 ?",false);
on_Raw_sendCMDButton_clicked();
while(pm3->waitForReadyRead())
;
QString result=pm3->getRequiredOutput();
pm3->setRequiringOutput(false);
result = result.mid(result.indexOf("|---|----------------|----------------|")); result = result.mid(result.indexOf("|---|----------------|----------------|"));
QStringList keys = result.split("\r\n"); QStringList keys = result.split("\r\n");
for(int i = 0; i < 16; i++) for(int i = 0; i < 16; i++)
@ -129,12 +123,7 @@ void MainWindow::on_MF_Attack_chkButton_clicked()
void MainWindow::on_MF_Attack_nestedButton_clicked() void MainWindow::on_MF_Attack_nestedButton_clicked()
{ {
pm3->setRequiringOutput(true); QString result = execCMDWithOutput("hf mf nested 1 *");
execCMD("hf mf nested 1 *",false);
while(pm3->waitForReadyRead())
;
QString result=pm3->getRequiredOutput();
pm3->setRequiringOutput(false);
result = result.mid(result.indexOf("|---|----------------|---|----------------|---|")); result = result.mid(result.indexOf("|---|----------------|---|----------------|---|"));
QStringList keys = result.split("\r\n"); QStringList keys = result.split("\r\n");
for(int i = 0; i < 16; i++) for(int i = 0; i < 16; i++)
@ -164,6 +153,58 @@ void MainWindow::on_MF_Attack_listButton_clicked()
execCMD("hf list mf", true); execCMD("hf list mf", true);
} }
void MainWindow::on_MF_RW_readAllButton_clicked()
{
QString result;
int validkey;
const int waitTime=500;
for(int i = 0; i < 16; i++)
{
QApplication::processEvents();
result = "";
validkey = -1;
if(MF_isKeyValid(ui->MF_keyWidget->item(i, 1)->text()))
{
result = execCMDWithOutput("hf mf rdbl "
+ QString::number(4 * i)
+ " A "
+ ui->MF_keyWidget->item(i, 1)->text(),waitTime);
if(result.indexOf("isOk:01") != -1)
{
validkey = 1;
ui->MF_dataWidget->setItem(4 * i, 2,new QTableWidgetItem(result.mid(result.indexOf("isOk:01")+13, 47).toUpper()));
}
}
if(validkey == -1 && MF_isKeyValid(ui->MF_keyWidget->item(i, 2)->text()))
{
result = execCMDWithOutput("hf mf rdbl "
+ QString::number(4 * i)
+ " B "
+ ui->MF_keyWidget->item(i, 2)->text(),waitTime);
if(result.indexOf("isOk:01") != -1)
{
validkey = 2;
ui->MF_dataWidget->setItem(4 * i, 2,new QTableWidgetItem(result.mid(result.indexOf("isOk:01")+13, 47).toUpper()));
}
}
if(validkey!=-1)
{
for(int j = 1; j < 4; j++)
{
QApplication::processEvents();
result = execCMDWithOutput("hf mf rdbl "
+ QString::number(4 * i + j)
+ " "
+ (validkey==1?"A":"B")
+ " "
+ ui->MF_keyWidget->item(i, validkey)->text(),waitTime);
ui->MF_dataWidget->setItem(4 * i + j, 2,new QTableWidgetItem(result.mid(result.indexOf("isOk:01")+13, 47).toUpper()));
}
}
}
}
// ************************************************ // ************************************************
@ -246,4 +287,26 @@ void MainWindow::execCMD(QString cmd,bool gotoRawTab)
if(gotoRawTab) if(gotoRawTab)
ui->funcTab->setCurrentIndex(1); ui->funcTab->setCurrentIndex(1);
} }
QString MainWindow::execCMDWithOutput(QString cmd, int msec)
{
pm3->setRequiringOutput(true);
execCMD(cmd, false);
while(pm3->waitForReadyRead(msec))
;
pm3->setRequiringOutput(false);
return pm3->getRequiredOutput();
}
bool MainWindow::MF_isKeyValid(const QString key)
{
if(key.length() != 12)
return false;
for(int i = 0; i < 12; i++)
{
if(!((key[i] >= '0' && key[i] <= '9') || (key[i] >= 'A' && key[i] <= 'F')))
return false;
}
return true;
}
// *********************************************** // ***********************************************

@ -22,6 +22,8 @@ public:
MainWindow(QWidget *parent = nullptr); MainWindow(QWidget *parent = nullptr);
~MainWindow(); ~MainWindow();
bool MF_isKeyValid(const QString key);
QString execCMDWithOutput(QString cmd, int msec=2000);
public slots: public slots:
void refresh(); void refresh();
void setStatusBar(QLabel* target,const QString & text); void setStatusBar(QLabel* target,const QString & text);
@ -55,6 +57,8 @@ private slots:
void on_MF_Attack_listButton_clicked(); void on_MF_Attack_listButton_clicked();
void on_MF_RW_readAllButton_clicked();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
PM3Process* pm3; PM3Process* pm3;

@ -161,7 +161,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -180,7 +180,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -199,7 +199,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -218,7 +218,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -237,7 +237,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -293,7 +293,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -312,7 +312,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -337,7 +337,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -362,7 +362,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -499,7 +499,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -518,7 +518,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -543,7 +543,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -568,7 +568,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -678,7 +678,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -697,7 +697,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -716,7 +716,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -735,7 +735,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>40</height> <height>30</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">

@ -53,3 +53,4 @@ bool PM3Process::waitForReadyRead(int msecs)
{ {
return QProcess::waitForReadyRead(msecs); return QProcess::waitForReadyRead(msecs);
} }

@ -17,7 +17,7 @@ public:
QByteArray readLine(qint64 maxlen = 0); QByteArray readLine(qint64 maxlen = 0);
void setRequiringOutput(bool st); void setRequiringOutput(bool st);
QString getRequiredOutput(); QString getRequiredOutput();
bool waitForReadyRead(int msecs = 3000); bool waitForReadyRead(int msecs = 2000);
private: private:
bool isRequiringOutput; bool isRequiringOutput;
QString* requiredOutput; QString* requiredOutput;

Loading…
Cancel
Save