Try to process the origin output(in hf mf chk)

pull/2/head
wh201906 5 years ago
parent d2689c333c
commit 5d793eb764

@ -139,3 +139,22 @@ void MainWindow::uiInit()
on_moreFuncCheckBox_stateChanged(0); on_moreFuncCheckBox_stateChanged(0);
on_portButton_clicked(); on_portButton_clicked();
} }
void MainWindow::on_MFChkButton_clicked()
{
pm3->setRequiringOutput(true);
ui->commandEdit->setText("hf mf chk *1 ?");
on_sendButton_clicked();
while(pm3->waitForReadyRead(5000))
;
QString result=pm3->getRequiredOutput();
pm3->setRequiringOutput(false);
result=result.mid(result.indexOf("|---|----------------|----------------|"));
QStringList keys=result.split("\r\n");
for(int i=0;i<16;i++)
{
ui->MFKeyWidget->setItem(i,1,new QTableWidgetItem(keys[i+3].mid(7,12).trimmed().toUpper()));
ui->MFKeyWidget->setItem(i,2,new QTableWidgetItem(keys[i+3].mid(24,12).trimmed().toUpper()));
}
qDebug()<<"***********\n"<<keys<<"***********\n";
}

@ -41,6 +41,8 @@ private slots:
void on_CMDHistoryWidget_itemDoubleClicked(QListWidgetItem *item); void on_CMDHistoryWidget_itemDoubleClicked(QListWidgetItem *item);
void on_MFChkButton_clicked();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
PM3Process* pm3; PM3Process* pm3;

@ -81,7 +81,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="mifareTab"> <widget class="QWidget" name="mifareTab">
<attribute name="title"> <attribute name="title">
@ -130,8 +130,8 @@
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>150</x> <x>120</x>
<y>410</y> <y>370</y>
<width>338</width> <width>338</width>
<height>55</height> <height>55</height>
</rect> </rect>
@ -174,9 +174,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>170</x> <x>170</x>
<y>480</y> <y>440</y>
<width>338</width> <width>338</width>
<height>55</height> <height>71</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
@ -184,30 +184,85 @@
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>
<widget class="QPushButton" name="pushButton_9"> <widget class="QPushButton" name="MFChkButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="text"> <property name="text">
<string>PushButton</string> <string>Check
Default</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_10"> <widget class="QPushButton" name="MFNestedButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="text"> <property name="text">
<string>PushButton</string> <string>Nested</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_11"> <widget class="QPushButton" name="MFHardnestedButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="text"> <property name="text">
<string>PushButton</string> <string>Hardnested</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_12"> <widget class="QPushButton" name="MFSniffButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="text"> <property name="text">
<string>PushButton</string> <string>Sniff</string>
</property> </property>
</widget> </widget>
</item> </item>

@ -3,6 +3,8 @@
PM3Process::PM3Process(QObject* parent): QProcess(parent) PM3Process::PM3Process(QObject* parent): QProcess(parent)
{ {
setProcessChannelMode(PM3Process::MergedChannels); setProcessChannelMode(PM3Process::MergedChannels);
isRequiringOutput=false;
requiredOutput=new QString();
} }
QStringList PM3Process::findPort() QStringList PM3Process::findPort()
@ -27,3 +29,22 @@ bool PM3Process::start(const QString path, const QString port)
QProcess::start(path, QStringList()<<port<<"-f",QProcess::Unbuffered|QProcess::ReadWrite); QProcess::start(path, QStringList()<<port<<"-f",QProcess::Unbuffered|QProcess::ReadWrite);
return waitForStarted(); return waitForStarted();
} }
void PM3Process::setRequiringOutput(bool st)
{
isRequiringOutput=st;
if(isRequiringOutput)
requiredOutput->clear();
}
QByteArray PM3Process::readLine(qint64 maxlen)
{
QByteArray buff;
buff=QProcess::readLine(maxlen);
if(isRequiringOutput)
requiredOutput->append(buff);
return buff;
}
QString PM3Process::getRequiredOutput()
{
return *requiredOutput;
}

@ -14,6 +14,12 @@ public:
explicit PM3Process(QObject* parent=nullptr); explicit PM3Process(QObject* parent=nullptr);
bool start(const QString path, const QString port); bool start(const QString path, const QString port);
QStringList findPort(); QStringList findPort();
QByteArray readLine(qint64 maxlen = 0);
void setRequiringOutput(bool st);
QString getRequiredOutput();
private:
bool isRequiringOutput;
QString* requiredOutput;
}; };
#endif // PM3PROCESS_H #endif // PM3PROCESS_H

Loading…
Cancel
Save