mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-02-16 22:21:30 +08:00
Add <client dir> for preload script path
This commit is contained in:
parent
aee621c196
commit
e6be456cfa
@ -63,6 +63,7 @@ void PM3Process::connectPM3(const QString& path, const QStringList args)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
qDebug() << "unexpected output:" << (result.isEmpty() ? "(empty)" : result);
|
||||||
emit HWConnectFailed();
|
emit HWConnectFailed();
|
||||||
kill();
|
kill();
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,14 @@ void MainWindow::on_PM3_connectButton_clicked()
|
|||||||
|
|
||||||
QString port = ui->PM3_portBox->currentData().toString();
|
QString port = ui->PM3_portBox->currentData().toString();
|
||||||
QString startArgs = ui->Set_Client_startArgsEdit->text();
|
QString startArgs = ui->Set_Client_startArgsEdit->text();
|
||||||
|
QString clientPath = ui->PM3_pathEdit->text();
|
||||||
|
QFileInfo clientFile(clientPath);
|
||||||
|
|
||||||
|
if(!clientFile.exists())
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, tr("Info"), tr("The client path is invalid"), QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// on RRG repo, if no port is specified, the client will search the available port
|
// on RRG repo, if no port is specified, the client will search the available port
|
||||||
if(port == "" && startArgs.contains("<port>")) // has <port>, no port
|
if(port == "" && startArgs.contains("<port>")) // has <port>, no port
|
||||||
@ -172,25 +180,29 @@ void MainWindow::on_PM3_connectButton_clicked()
|
|||||||
port = ""; // a symbol
|
port = ""; // a symbol
|
||||||
|
|
||||||
QStringList args = startArgs.replace("<port>", port).split(' ');
|
QStringList args = startArgs.replace("<port>", port).split(' ');
|
||||||
saveClientPath(ui->PM3_pathEdit->text());
|
saveClientPath(clientPath);
|
||||||
|
|
||||||
QProcess envSetProcess;
|
QProcess envSetProcess;
|
||||||
QFileInfo envScriptPath(ui->Set_Client_envScriptEdit->text());
|
QString envScriptPath = ui->Set_Client_envScriptEdit->text();
|
||||||
if(envScriptPath.exists())
|
if(envScriptPath.contains("<client dir>"))
|
||||||
|
envScriptPath.replace("<client dir>", clientFile.absoluteDir().absolutePath());
|
||||||
|
|
||||||
|
QFileInfo envScript(envScriptPath);
|
||||||
|
if(envScript.exists())
|
||||||
{
|
{
|
||||||
qDebug() << envScriptPath.absoluteFilePath();
|
qDebug() << envScript.absoluteFilePath();
|
||||||
// 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", {}, QProcess::Unbuffered | QProcess::ReadWrite | QProcess::Text);
|
envSetProcess.start("cmd", {}, QProcess::Unbuffered | QProcess::ReadWrite | QProcess::Text);
|
||||||
envSetProcess.write(QString("\"" + envScriptPath.absoluteFilePath() + "\">>nul\n").toLatin1());
|
envSetProcess.write(QString("\"" + envScript.absoluteFilePath() + "\">>nul\n").toLatin1());
|
||||||
envSetProcess.waitForReadyRead(10000);
|
envSetProcess.waitForReadyRead(10000);
|
||||||
envSetProcess.readAll();
|
envSetProcess.readAll();
|
||||||
envSetProcess.write("set\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'
|
||||||
envSetProcess.start("sh -c \' . \"" + envScriptPath.absoluteFilePath() + "\">>/dev/null && env");
|
envSetProcess.start("sh -c \' . \"" + envScript.absoluteFilePath() + "\">>/dev/null && env");
|
||||||
#endif
|
#endif
|
||||||
envSetProcess.waitForReadyRead(10000);
|
envSetProcess.waitForReadyRead(10000);
|
||||||
QString envSetResult = QString(envSetProcess.readAll());
|
QString envSetResult = QString(envSetProcess.readAll());
|
||||||
@ -219,7 +231,7 @@ void MainWindow::on_PM3_connectButton_clicked()
|
|||||||
emit setWorkingDir(clientWorkingDir->absolutePath());
|
emit setWorkingDir(clientWorkingDir->absolutePath());
|
||||||
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
emit connectPM3(ui->PM3_pathEdit->text(), args);
|
emit connectPM3(clientPath, args);
|
||||||
if(port != "" && !keepClientActive)
|
if(port != "" && !keepClientActive)
|
||||||
emit setSerialListener(port, true);
|
emit setSerialListener(port, true);
|
||||||
else if(!keepClientActive)
|
else if(!keepClientActive)
|
||||||
@ -232,7 +244,7 @@ void MainWindow::onPM3ErrorOccurred(QProcess::ProcessError error)
|
|||||||
{
|
{
|
||||||
qDebug() << "PM3 Error:" << error << pm3->errorString();
|
qDebug() << "PM3 Error:" << error << pm3->errorString();
|
||||||
if(error == QProcess::FailedToStart)
|
if(error == QProcess::FailedToStart)
|
||||||
QMessageBox::information(this, tr("Info"), tr("Failed to start the client"));
|
QMessageBox::information(this, tr("Info"), tr("Failed to start the client") + "\n" + pm3->errorString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onPM3HWConnectFailed()
|
void MainWindow::onPM3HWConnectFailed()
|
||||||
|
@ -2714,7 +2714,8 @@ or the communication between a tag and a reader.</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_13">
|
<widget class="QLabel" name="label_13">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>If the client requires some enviroment variables, you can make a script file(*.bat on Windows or *.sh on Linux) to configure them, then put the path of the script there.</string>
|
<string>If the client requires some enviroment variables, you can make a script file(*.bat on Windows or *.sh on Linux) to configure them, then put the path of the script there.
|
||||||
|
The "<client dir>" will be replaced by the directory of the "Client Path"</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user