diff --git a/src/common/pm3process.cpp b/src/common/pm3process.cpp index 76c13b8..1d86468 100644 --- a/src/common/pm3process.cpp +++ b/src/common/pm3process.cpp @@ -35,19 +35,19 @@ void PM3Process::connectPM3(const QString& path, const QStringList args) waitForReadyRead(10000); setRequiringOutput(false); result = *requiredOutput; + // Workaround for wayland system, e.g. Ubuntu 22.04 + // The issue is that the warning is read and nothing else, hence the process is killed. + if(result.contains("Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.")) + { + setRequiringOutput(true); + readWaitForConnection(&result); + } if(result.contains("[=]")) { clientType = Util::CLIENTTYPE_ICEMAN; setRequiringOutput(true); write("hw version\n"); - for(int i = 0; i < 50; i++) - { - waitForReadyRead(200); - result += *requiredOutput; - if(result.contains("os: ")) - break; - } - setRequiringOutput(false); + readWaitForConnection(&result); } else { @@ -72,6 +72,18 @@ void PM3Process::connectPM3(const QString& path, const QStringList args) setRequiringOutput(false); } +void PM3Process::readWaitForConnection(QString *result) +{ + for(int i = 0; i < 50; i++) + { + waitForReadyRead(200); + (*result) += *requiredOutput; + if(result->contains("os: ")) + break; + } + setRequiringOutput(false); +} + void PM3Process::reconnectPM3() { connectPM3(currPath, currArgs); diff --git a/src/common/pm3process.h b/src/common/pm3process.h index 5ae747b..f5736c8 100644 --- a/src/common/pm3process.h +++ b/src/common/pm3process.h @@ -38,6 +38,7 @@ private: bool isRequiringOutput; QString* requiredOutput; // It only works in this class now void setRequiringOutput(bool st);// It only works in this class now + void readWaitForConnection(QString *result); QTimer* serialListener; QSerialPortInfo* portInfo; QString currPath;