mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2026-07-14 22:55:32 +08:00
Support running a external script before client start,
to configure the environment variables Optimize stop(reconnect) logic Search valid ports automatically Update translations
This commit is contained in:
+23
-2
@@ -17,14 +17,19 @@ PM3Process::PM3Process(QThread* thread, QObject* parent): QProcess(parent)
|
||||
void PM3Process::connectPM3(const QString& path, const QString& port, const QStringList args)
|
||||
{
|
||||
QString result;
|
||||
Util::ClientType clientType = Util::CLIENTTYPE_OFFICIAL;
|
||||
Util::ClientType clientType;
|
||||
setRequiringOutput(true);
|
||||
|
||||
// stash for reconnect
|
||||
currPath = path;
|
||||
currPort = port;
|
||||
currArgs = args;
|
||||
|
||||
// using "-f" option to make the client output flushed after every print.
|
||||
start(path, args, QProcess::Unbuffered | QProcess::ReadWrite);
|
||||
if(waitForStarted(10000))
|
||||
{
|
||||
waitForReadyRead(1000);
|
||||
waitForReadyRead(10000);
|
||||
setRequiringOutput(false);
|
||||
result = *requiredOutput;
|
||||
if(result.indexOf("[=]") != -1)
|
||||
@@ -36,6 +41,10 @@ void PM3Process::connectPM3(const QString& path, const QString& port, const QStr
|
||||
result = *requiredOutput;
|
||||
setRequiringOutput(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
clientType = Util::CLIENTTYPE_OFFICIAL;
|
||||
}
|
||||
if(result.indexOf("os: ") != -1) // make sure the PM3 is connected
|
||||
{
|
||||
emit changeClientType(clientType);
|
||||
@@ -50,6 +59,11 @@ void PM3Process::connectPM3(const QString& path, const QString& port, const QStr
|
||||
}
|
||||
}
|
||||
|
||||
void PM3Process::reconnectPM3()
|
||||
{
|
||||
connectPM3(currPath, currPort, currArgs);
|
||||
}
|
||||
|
||||
void PM3Process::setRequiringOutput(bool st)
|
||||
{
|
||||
isRequiringOutput = st;
|
||||
@@ -110,3 +124,10 @@ void PM3Process::onReadyRead()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void PM3Process::setProcEnv(const QStringList* env)
|
||||
{
|
||||
// qDebug() << "passed Env List" << *env;
|
||||
this->setEnvironment(*env);
|
||||
// qDebug() << "final Env List" << processEnvironment().toStringList();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <QTimer>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QProcessEnvironment>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
@@ -24,6 +25,8 @@ public slots:
|
||||
void connectPM3(const QString& path, const QString& port, const QStringList args);
|
||||
void setSerialListener(const QString& name, bool state);
|
||||
qint64 write(QString data);
|
||||
void reconnectPM3();
|
||||
void setProcEnv(const QStringList* env);
|
||||
private slots:
|
||||
void onTimeout();
|
||||
void onReadyRead();
|
||||
@@ -33,6 +36,10 @@ private:
|
||||
void setRequiringOutput(bool st);// It only works in this class now
|
||||
QTimer* serialListener;
|
||||
QSerialPortInfo* portInfo;
|
||||
QString currPath;
|
||||
QString currPort;
|
||||
QStringList currArgs;
|
||||
|
||||
signals:
|
||||
void PM3StatedChanged(bool st, const QString& info = "");
|
||||
void newOutput(const QString& output);
|
||||
|
||||
Reference in New Issue
Block a user