mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-02-17 06:31:33 +08:00
Fix a bug
Trying to fix #22 Open client with QProcess::Text for proper newline character(s) On Raspbian, the isBusy() function will always return false, even the serial port is actually connected.
This commit is contained in:
parent
02a8fe03e3
commit
12a0837c50
@ -26,7 +26,7 @@ void PM3Process::connectPM3(const QString& path, const QStringList args)
|
|||||||
currArgs = args;
|
currArgs = args;
|
||||||
|
|
||||||
// using "-f" option to make the client output flushed after every print.
|
// using "-f" option to make the client output flushed after every print.
|
||||||
start(path, args, QProcess::Unbuffered | QProcess::ReadWrite);
|
start(path, args, QProcess::Unbuffered | QProcess::ReadWrite | QProcess::Text);
|
||||||
if(waitForStarted(10000))
|
if(waitForStarted(10000))
|
||||||
{
|
{
|
||||||
waitForReadyRead(10000);
|
waitForReadyRead(10000);
|
||||||
@ -36,11 +36,13 @@ void PM3Process::connectPM3(const QString& path, const QStringList args)
|
|||||||
{
|
{
|
||||||
clientType = Util::CLIENTTYPE_ICEMAN;
|
clientType = Util::CLIENTTYPE_ICEMAN;
|
||||||
setRequiringOutput(true);
|
setRequiringOutput(true);
|
||||||
write("hw version\r\n");
|
write("hw version\n");
|
||||||
for(int i = 0; i < 10; i++)
|
for(int i = 0; i < 50; i++)
|
||||||
{
|
{
|
||||||
waitForReadyRead(200);
|
waitForReadyRead(200);
|
||||||
result += *requiredOutput;
|
result += *requiredOutput;
|
||||||
|
if(result.indexOf("os: ") != -1)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
setRequiringOutput(false);
|
setRequiringOutput(false);
|
||||||
}
|
}
|
||||||
@ -52,8 +54,8 @@ void PM3Process::connectPM3(const QString& path, const QStringList args)
|
|||||||
{
|
{
|
||||||
emit changeClientType(clientType);
|
emit changeClientType(clientType);
|
||||||
result = result.mid(result.indexOf("os: "));
|
result = result.mid(result.indexOf("os: "));
|
||||||
result = result.left(result.indexOf("\r\n"));
|
result = result.left(result.indexOf("\n"));
|
||||||
result = result.mid(3, result.lastIndexOf(" ") - 3);
|
result = result.mid(4, result.indexOf(" ", 4) - 4);
|
||||||
emit PM3StatedChanged(true, result);
|
emit PM3StatedChanged(true, result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -105,11 +107,15 @@ void PM3Process::setSerialListener(bool state)
|
|||||||
|
|
||||||
void PM3Process::onTimeout() //when the proxmark3 client is unexpectedly terminated or the PM3 hardware is removed, the isBusy() will return false(only tested on Windows);
|
void PM3Process::onTimeout() //when the proxmark3 client is unexpectedly terminated or the PM3 hardware is removed, the isBusy() will return false(only tested on Windows);
|
||||||
{
|
{
|
||||||
|
// isBusy() is a deprecated function.
|
||||||
|
// It will always return false on Raspbian.
|
||||||
|
// SerialListener need to be removed.
|
||||||
|
//
|
||||||
// qDebug()<<portInfo->isBusy();
|
// qDebug()<<portInfo->isBusy();
|
||||||
if(!portInfo->isBusy())
|
// if(!portInfo->isBusy())
|
||||||
{
|
// {
|
||||||
killPM3();
|
// killPM3();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void PM3Process::testThread()
|
void PM3Process::testThread()
|
||||||
|
@ -31,7 +31,7 @@ void Util::execCMD(const QString& cmd)
|
|||||||
{
|
{
|
||||||
qDebug() << "executing: " << cmd;
|
qDebug() << "executing: " << cmd;
|
||||||
if(isRunning)
|
if(isRunning)
|
||||||
emit write(cmd + "\r\n");
|
emit write(cmd + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Util::execCMDWithOutput(const QString& cmd, ReturnTrigger trigger)
|
QString Util::execCMDWithOutput(const QString& cmd, ReturnTrigger trigger)
|
||||||
|
@ -70,10 +70,10 @@ void LF::getConfig()
|
|||||||
result = util->execCMDWithOutput("hw status", 400); // not all output from "hw status will be processed".
|
result = util->execCMDWithOutput("hw status", 400); // not all output from "hw status will be processed".
|
||||||
result = result.right(result.length() - result.indexOf("LF Sampling config"));
|
result = result.right(result.length() - result.indexOf("LF Sampling config"));
|
||||||
offset = result.indexOf("samples to skip");
|
offset = result.indexOf("samples to skip");
|
||||||
offset = result.indexOf("\r\n", offset);
|
offset = result.indexOf("\n", offset);
|
||||||
result = result.mid(0, offset + 2);
|
result = result.mid(0, offset + 2);
|
||||||
qDebug() << "LF CONFIG GET\n" << result;
|
qDebug() << "LF CONFIG GET\n" << result;
|
||||||
resultList = result.split("\r\n");
|
resultList = result.split("\n");
|
||||||
for(int i = 0; i < resultList.length(); i++)
|
for(int i = 0; i < resultList.length(); i++)
|
||||||
{
|
{
|
||||||
for(int j = 0; j < symbolList.length(); j++)
|
for(int j = 0; j < symbolList.length(); j++)
|
||||||
|
@ -794,7 +794,7 @@ void Mifare::setParameterC()
|
|||||||
QMessageBox::information(parent, tr("Info"), tr("Failed to read card."));
|
QMessageBox::information(parent, tr("Info"), tr("Failed to read card."));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result.replace("\r\n", "");
|
result.replace("\n", "");
|
||||||
result.replace(QRegularExpression("\\[.\\]"), "");
|
result.replace(QRegularExpression("\\[.\\]"), "");
|
||||||
result.replace("UID", "");
|
result.replace("UID", "");
|
||||||
result.replace("ATQA", "");
|
result.replace("ATQA", "");
|
||||||
@ -1071,7 +1071,7 @@ bool Mifare::data_loadDataFile(const QString& filename)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString tmp = buff.left(cardType.block_size * 34);
|
QString tmp = buff.left(cardType.block_size * 34);
|
||||||
QStringList tmpList = tmp.split("\r\n");
|
QStringList tmpList = tmp.split("\n");
|
||||||
for(int i = 0; i < cardType.block_size; i++)
|
for(int i = 0; i < cardType.block_size; i++)
|
||||||
{
|
{
|
||||||
dataList->replace(i, tmpList[i].toUpper());
|
dataList->replace(i, tmpList[i].toUpper());
|
||||||
@ -1174,7 +1174,7 @@ bool Mifare::data_saveDataFile(const QString& filename, bool isBin)
|
|||||||
for(int i = 0; i < cardType.block_size; i++)
|
for(int i = 0; i < cardType.block_size; i++)
|
||||||
{
|
{
|
||||||
buff += dataList->at(i);
|
buff += dataList->at(i);
|
||||||
buff += "\r\n";
|
buff += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool ret = file.write(buff) != -1;
|
bool ret = file.write(buff) != -1;
|
||||||
|
@ -126,11 +126,11 @@ void MainWindow::on_PM3_connectButton_clicked()
|
|||||||
// use the shell session to keep the environment then read it
|
// use the shell session to keep the environment then read it
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// cmd /c "<path>">>nul && set
|
// cmd /c "<path>">>nul && set
|
||||||
envSetProcess.start("cmd");
|
envSetProcess.start("cmd", {}, QProcess::Unbuffered | QProcess::ReadWrite | QProcess::Text);
|
||||||
envSetProcess.write(QString("\"" + envScriptPath.absoluteFilePath() + "\">>nul\r\n").toLatin1());
|
envSetProcess.write(QString("\"" + envScriptPath.absoluteFilePath() + "\">>nul\n").toLatin1());
|
||||||
envSetProcess.waitForReadyRead(10000);
|
envSetProcess.waitForReadyRead(10000);
|
||||||
envSetProcess.readAll();
|
envSetProcess.readAll();
|
||||||
envSetProcess.write("set\r\n");
|
envSetProcess.write("set\n");
|
||||||
#else
|
#else
|
||||||
// need implementation(or test if space works)
|
// need implementation(or test if space works)
|
||||||
// sh -c '. "<path>">>/dev/null && env'
|
// sh -c '. "<path>">>/dev/null && env'
|
||||||
@ -138,7 +138,7 @@ void MainWindow::on_PM3_connectButton_clicked()
|
|||||||
#endif
|
#endif
|
||||||
envSetProcess.waitForReadyRead(10000);
|
envSetProcess.waitForReadyRead(10000);
|
||||||
QString envSetResult = QString(envSetProcess.readAll());
|
QString envSetResult = QString(envSetProcess.readAll());
|
||||||
clientEnv = envSetResult.split(QRegExp("[\r\n]{1,2}"), QString::SkipEmptyParts);
|
clientEnv = envSetResult.split("\n", QString::SkipEmptyParts);
|
||||||
if(clientEnv.size() > 2) // the first element is "set" and the last element is the current path
|
if(clientEnv.size() > 2) // the first element is "set" and the last element is the current path
|
||||||
{
|
{
|
||||||
clientEnv.removeFirst();
|
clientEnv.removeFirst();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user