mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-02-16 22:21:30 +08:00
Make execCmd() adapted to QThread
This commit is contained in:
parent
5c5fb84811
commit
a6a699d33c
@ -20,13 +20,15 @@ SOURCES += \
|
||||
mainwindow.cpp \
|
||||
mf_attack_hardnesteddialog.cpp \
|
||||
mifare.cpp \
|
||||
pm3process.cpp
|
||||
pm3process.cpp \
|
||||
util.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
mf_attack_hardnesteddialog.h \
|
||||
mifare.h \
|
||||
pm3process.h
|
||||
pm3process.h \
|
||||
util.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
|
@ -23,6 +23,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
emit killPM3();
|
||||
pm3Thread->exit(0);
|
||||
pm3Thread->wait(5000);
|
||||
delete pm3;
|
||||
@ -62,7 +63,6 @@ void MainWindow::on_PM3_connectButton_clicked()
|
||||
QMessageBox::information(NULL, "Info", "Plz choose a port first", QMessageBox::Ok);
|
||||
else
|
||||
{
|
||||
emit requiringOutput(true);
|
||||
emit connectPM3(ui->PM3_pathEdit->text(), port);
|
||||
}
|
||||
}
|
||||
@ -95,11 +95,7 @@ void MainWindow::on_PM3_disconnectButton_clicked()
|
||||
|
||||
void MainWindow::on_Raw_sendCMDButton_clicked()
|
||||
{
|
||||
if(ui->Raw_CMDHistoryWidget->count() == 0 || ui->Raw_CMDHistoryWidget->item(ui->Raw_CMDHistoryWidget->count() - 1)->text() != ui->Raw_CMDEdit->text())
|
||||
ui->Raw_CMDHistoryWidget->addItem(ui->Raw_CMDEdit->text());
|
||||
qDebug() << (ui->Raw_CMDEdit->text().toLocal8Bit());
|
||||
pm3->write((ui->Raw_CMDEdit->text() + "\r\n").toLocal8Bit());
|
||||
pm3->waitForBytesWritten(3000);
|
||||
execCMD(ui->Raw_CMDEdit->text());
|
||||
}
|
||||
|
||||
void MainWindow::on_Raw_clearOutputButton_clicked()
|
||||
@ -466,6 +462,8 @@ void MainWindow::signalInit()
|
||||
connect(this,&MainWindow::connectPM3,pm3,&PM3Process::connectPM3);
|
||||
connect(pm3, &PM3Process::PM3StatedChanged, this, &MainWindow::onPM3StateChanged);
|
||||
connect(this,&MainWindow::killPM3,pm3,&PM3Process::kill);
|
||||
|
||||
connect(this,&MainWindow::write,pm3,&PM3Process::write);
|
||||
}
|
||||
|
||||
void MainWindow::setStatusBar(QLabel* target, const QString & text)
|
||||
@ -481,15 +479,18 @@ void MainWindow::setStatusBar(QLabel* target, const QString & text)
|
||||
void MainWindow::execCMD(QString cmd, bool gotoRawTab)
|
||||
{
|
||||
ui->Raw_CMDEdit->setText(cmd);
|
||||
on_Raw_sendCMDButton_clicked();
|
||||
if(ui->Raw_CMDHistoryWidget->count() == 0 || ui->Raw_CMDHistoryWidget->item(ui->Raw_CMDHistoryWidget->count() - 1)->text() != cmd)
|
||||
ui->Raw_CMDHistoryWidget->addItem(cmd);
|
||||
qDebug() << cmd;
|
||||
emit write(cmd + "\r\n");
|
||||
if(gotoRawTab)
|
||||
ui->funcTab->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
QString MainWindow::execCMDWithOutput(QString cmd, int msec)
|
||||
{
|
||||
pm3->setRequiringOutput(true);
|
||||
execCMD(cmd, false);
|
||||
emit requiringOutput(true);
|
||||
execCMD(cmd);
|
||||
while(pm3->waitForReadyRead(msec))
|
||||
;
|
||||
pm3->setRequiringOutput(false);
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
public slots:
|
||||
void refresh();
|
||||
void setStatusBar(QLabel* target,const QString & text);
|
||||
void execCMD(QString cmd, bool gotoRawTab);
|
||||
void execCMD(QString cmd, bool gotoRawTab=false);
|
||||
void onPM3StateChanged(bool st, QString info);
|
||||
private slots:
|
||||
|
||||
@ -89,5 +89,6 @@ signals:
|
||||
void connectPM3(const QString path, const QString port);
|
||||
void killPM3();
|
||||
void setSerialListener(const QString &name, bool state);
|
||||
void write(QString data);
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -623,6 +623,44 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Lock UFUID Card</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About UID Card</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_12">
|
||||
<property name="orientation">
|
||||
@ -848,6 +886,19 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="Raw_CMDHistoryBox">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>History:</string>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="Raw_CMDHistoryWidget">
|
||||
<property name="sizePolicy">
|
||||
@ -874,19 +925,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="Raw_CMDHistoryBox">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>History:</string>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -77,7 +77,7 @@ void PM3Process::setSerialListener(const QString& name,bool state)
|
||||
}
|
||||
}
|
||||
|
||||
void PM3Process::onTimeout()
|
||||
void PM3Process::onTimeout() //when the proxmark3 client is unexpectedly terminated or the PM3 hardware is removed, the isBusy() will return false(tested on Windows);
|
||||
{
|
||||
qDebug()<<portInfo->isBusy();
|
||||
if(!portInfo->isBusy())
|
||||
@ -92,3 +92,9 @@ void PM3Process::testThread()
|
||||
{
|
||||
qDebug()<<"PM3:"<<QThread::currentThread();
|
||||
}
|
||||
|
||||
|
||||
qint64 PM3Process::write(QString data)
|
||||
{
|
||||
return QProcess::write(data.toLatin1());
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public slots:
|
||||
void setRequiringOutput(bool st);
|
||||
void connectPM3(const QString path, const QString port);
|
||||
void setSerialListener(const QString &name, bool state);
|
||||
qint64 write(QString data);
|
||||
private slots:
|
||||
void onTimeout();
|
||||
private:
|
||||
|
6
util.cpp
Normal file
6
util.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "util.h"
|
||||
|
||||
Util::Util(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user