Add _readblk() (not tested)

This commit is contained in:
wh201906
2020-08-01 21:30:55 +08:00
parent cd122b8959
commit a77985824c
4 changed files with 93 additions and 13 deletions
+8 -3
View File
@@ -1,10 +1,11 @@
#include "util.h"
Util::Util(QObject *parent) : QObject(parent)
Util::Util(Util::ClientType clientType, QObject *parent) : QObject(parent)
{
isRequiringOutput = false;
requiredOutput = new QString();
timeStamp = QTime::currentTime();
this->clientType = clientType;
}
void Util::processOutput(QString output)
@@ -31,7 +32,7 @@ QString Util::execCMDWithOutput(QString cmd, unsigned long timeout)
isRequiringOutput = true;
requiredOutput->clear();
execCMD(cmd);
while( QTime::currentTime() < targetTime)
while(QTime::currentTime() < targetTime)
{
QApplication::processEvents();
if(timeStamp > currTime)
@@ -47,6 +48,10 @@ QString Util::execCMDWithOutput(QString cmd, unsigned long timeout)
void Util::delay(unsigned int msec)
{
QTime timer = QTime::currentTime().addMSecs(msec);
while( QTime::currentTime() < timer )
while(QTime::currentTime() < timer)
QApplication::processEvents(QEventLoop::AllEvents, 100);
}
Util::ClientType Util::getClientType()
{
return this->clientType;
}
+8 -1
View File
@@ -13,11 +13,17 @@ class Util : public QObject
{
Q_OBJECT
public:
explicit Util(QObject *parent = nullptr);
enum ClientType
{
OFFICIAL,
ICEMAN,
};
explicit Util(Util::ClientType clientType, QObject *parent = nullptr);
void execCMD(QString cmd);
QString execCMDWithOutput(QString cmd, unsigned long timeout = 2000);
void delay(unsigned int msec);
ClientType getClientType();
public slots:
void processOutput(QString output);
@@ -28,6 +34,7 @@ private:
signals:
void refreshOutput(const QString& output);
void write(QString data);
ClientType clientType;
};
#endif // UTIL_H