mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2026-07-14 22:55:32 +08:00
Some changes
Refactor execCMDWithOutput Add UI for advanced settings Add stop button(reconnect) Update translations
This commit is contained in:
+12
-4
@@ -22,13 +22,16 @@ void Util::processOutput(const QString& output)
|
||||
|
||||
void Util::execCMD(const QString& cmd)
|
||||
{
|
||||
qDebug() << cmd;
|
||||
qDebug() << "executing: " << cmd;
|
||||
if(isRunning)
|
||||
emit write(cmd + "\r\n");
|
||||
}
|
||||
|
||||
QString Util::execCMDWithOutput(const QString& cmd, ReturnTrigger trigger)
|
||||
{
|
||||
// if the trigger is empty, this function will wait trigger.waitTime then return all outputs during the wait time.
|
||||
// otherwise, this function will return empty string if no trigger is detected, or return outputs if any trigger is detected.
|
||||
// the waitTime will be refreshed if the client have new outputs
|
||||
bool isResultFound = false;
|
||||
QRegularExpression re;
|
||||
re.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
|
||||
@@ -42,27 +45,32 @@ QString Util::execCMDWithOutput(const QString& cmd, ReturnTrigger trigger)
|
||||
execCMD(cmd);
|
||||
while(QTime::currentTime() < targetTime)
|
||||
{
|
||||
if(!isRunning)
|
||||
break;
|
||||
QApplication::processEvents();
|
||||
for(QString otpt : trigger.expectedOutputs)
|
||||
{
|
||||
re.setPattern(otpt);
|
||||
isResultFound = re.match(*requiredOutput).hasMatch();
|
||||
if(requiredOutput->contains(otpt))
|
||||
if(isResultFound)
|
||||
{
|
||||
qDebug() << "output Matched: " << *requiredOutput;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(isResultFound)
|
||||
{
|
||||
delay(200);
|
||||
break;
|
||||
}
|
||||
if(timeStamp > currTime)
|
||||
if(timeStamp > currTime) //has new output
|
||||
{
|
||||
currTime = timeStamp;
|
||||
targetTime = timeStamp.addMSecs(trigger.waitTime);
|
||||
}
|
||||
}
|
||||
isRequiringOutput = false;
|
||||
return *requiredOutput;
|
||||
return (isResultFound || trigger.expectedOutputs.isEmpty() ? *requiredOutput : "");
|
||||
}
|
||||
|
||||
void Util::delay(unsigned int msec)
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
QString execCMDWithOutput(const QString& cmd, ReturnTrigger trigger = 10000);
|
||||
void delay(unsigned int msec);
|
||||
ClientType getClientType();
|
||||
static const int rawTabIndex = 1;
|
||||
public slots:
|
||||
void processOutput(const QString& output);
|
||||
void setClientType(Util::ClientType clientType);
|
||||
|
||||
Reference in New Issue
Block a user