From 5d793eb7647e19d1c042a01559ebd3f15eb57a97 Mon Sep 17 00:00:00 2001 From: wh201906 <62299611+wh201906@users.noreply.github.com> Date: Sat, 11 Apr 2020 23:53:06 +0800 Subject: [PATCH] Try to process the origin output(in hf mf chk) --- mainwindow.cpp | 19 ++++++++++++ mainwindow.h | 2 ++ mainwindow.ui | 81 ++++++++++++++++++++++++++++++++++++++++++-------- pm3process.cpp | 21 +++++++++++++ pm3process.h | 6 ++++ 5 files changed, 116 insertions(+), 13 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 97b31af..19ae8ff 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -139,3 +139,22 @@ void MainWindow::uiInit() on_moreFuncCheckBox_stateChanged(0); 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"< - 1 + 0 @@ -130,8 +130,8 @@ - 150 - 410 + 120 + 370 338 55 @@ -174,9 +174,9 @@ 170 - 480 + 440 338 - 55 + 71 @@ -184,30 +184,85 @@ - + + + + 0 + 0 + + + + + 0 + 40 + + + + + 16777215 + 40 + + - PushButton + Check +Default - + + + + 0 + 40 + + + + + 16777215 + 40 + + - PushButton + Nested - + + + + 0 + 40 + + + + + 16777215 + 40 + + - PushButton + Hardnested - + + + + 0 + 40 + + + + + 16777215 + 40 + + - PushButton + Sniff diff --git a/pm3process.cpp b/pm3process.cpp index 59e6ca7..fdad430 100644 --- a/pm3process.cpp +++ b/pm3process.cpp @@ -3,6 +3,8 @@ PM3Process::PM3Process(QObject* parent): QProcess(parent) { setProcessChannelMode(PM3Process::MergedChannels); + isRequiringOutput=false; + requiredOutput=new QString(); } QStringList PM3Process::findPort() @@ -27,3 +29,22 @@ bool PM3Process::start(const QString path, const QString port) QProcess::start(path, QStringList()<clear(); +} +QByteArray PM3Process::readLine(qint64 maxlen) +{ + QByteArray buff; + buff=QProcess::readLine(maxlen); + if(isRequiringOutput) + requiredOutput->append(buff); + return buff; +} +QString PM3Process::getRequiredOutput() +{ + return *requiredOutput; +} diff --git a/pm3process.h b/pm3process.h index e1c0e45..b24c742 100644 --- a/pm3process.h +++ b/pm3process.h @@ -14,6 +14,12 @@ public: explicit PM3Process(QObject* parent=nullptr); bool start(const QString path, const QString port); QStringList findPort(); + QByteArray readLine(qint64 maxlen = 0); + void setRequiringOutput(bool st); + QString getRequiredOutput(); +private: + bool isRequiringOutput; + QString* requiredOutput; }; #endif // PM3PROCESS_H