Support Iceman fork(Command Line only)

pull/4/head
wh201906 4 years ago
parent 6f860111df
commit ef6ebea568

@ -16,16 +16,25 @@ PM3Process::PM3Process(QThread* thread, QObject* parent): QProcess(parent)
void PM3Process::connectPM3(const QString path, const QString port)
{
QString result;
setRequiringOutput(true);
// using "-f" option to make the client output flushed after every print.
start(path, QStringList() << port << "-f", QProcess::Unbuffered | QProcess::ReadWrite);
if(waitForStarted(10000))
{
while(waitForReadyRead(1000))
;
waitForReadyRead(1000);
setRequiringOutput(false);
QString result = *requiredOutput;
result = *requiredOutput;
if(result.indexOf("[=]") != -1)
{
emit changeClientType(Util::CLIENTTYPE_ICEMAN);
setRequiringOutput(true);
write("hw version\r\n");
waitForReadyRead(1000);
result = *requiredOutput;
setRequiringOutput(false);
}
if(result.indexOf("os: ") != -1) // make sure the PM3 is connected
{
result = result.mid(result.indexOf("os: "));

@ -9,6 +9,8 @@
#include <QtSerialPort/QSerialPortInfo>
#include <QtSerialPort/QSerialPort>
#include "util.h"
class PM3Process : public QProcess
{
Q_OBJECT
@ -34,6 +36,7 @@ private:
signals:
void PM3StatedChanged(bool st, QString info = "");
void newOutput(QString output);
void changeClientType(Util::ClientType);
};
#endif // PM3PROCESS_H

@ -1,11 +1,12 @@
#include "util.h"
Util::Util(Util::ClientType clientType, QObject *parent) : QObject(parent)
Util::Util(QObject *parent) : QObject(parent)
{
isRequiringOutput = false;
requiredOutput = new QString();
timeStamp = QTime::currentTime();
this->clientType = clientType;
this->clientType = CLIENTTYPE_OFFICIAL;
qRegisterMetaType<Util::ClientType>("Util::ClientType");
}
void Util::processOutput(QString output)
@ -55,3 +56,8 @@ Util::ClientType Util::getClientType()
{
return this->clientType;
}
void Util::setClientType(Util::ClientType clientType)
{
this->clientType = clientType;
}

@ -8,6 +8,7 @@
#include <QApplication>
#include <QTime>
#include <QTimer>
#include <QMetaType>
class Util : public QObject
{
@ -15,10 +16,13 @@ class Util : public QObject
public:
enum ClientType
{
OFFICIAL,
ICEMAN,
CLIENTTYPE_OFFICIAL,
CLIENTTYPE_ICEMAN,
};
explicit Util(Util::ClientType clientType, QObject *parent = nullptr);
Q_ENUM(Util::ClientType)
explicit Util(QObject *parent = nullptr);
void execCMD(QString cmd);
QString execCMDWithOutput(QString cmd, unsigned long timeout = 2000);
@ -26,6 +30,7 @@ public:
ClientType getClientType();
public slots:
void processOutput(QString output);
void setClientType(Util::ClientType clientType);
private:
bool isRequiringOutput;

@ -131,7 +131,7 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, int w
return "";
}
if(util->getClientType() == Util::OFFICIAL)
if(util->getClientType() == Util::CLIENTTYPE_OFFICIAL)
{
// use the given key type to read the target block
result = util->execCMDWithOutput(
@ -205,7 +205,7 @@ QStringList Mifare::_readsec(int sectorId, KeyType keyType, const QString& key,
return data;
}
if(util->getClientType() == Util::OFFICIAL)
if(util->getClientType() == Util::CLIENTTYPE_OFFICIAL)
{
result = util->execCMDWithOutput(
"hf mf rdsc "

@ -24,7 +24,7 @@ MainWindow::MainWindow(QWidget *parent):
pm3Thread->start();
pm3state = false;
util = new Util(Util::OFFICIAL, this);
util = new Util(this);
mifare = new Mifare(ui, util, this);
}
@ -784,6 +784,7 @@ void MainWindow::uiInit()
void MainWindow::signalInit()
{
connect(pm3, &PM3Process::newOutput, util, &Util::processOutput);
connect(pm3, &PM3Process::changeClientType, util, &Util::setClientType);
connect(util, &Util::refreshOutput, this, &MainWindow::refreshOutput);
connect(this, &MainWindow::connectPM3, pm3, &PM3Process::connectPM3);

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Trailer Decoder</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>

Loading…
Cancel
Save