2020-04-06 23:48:08 +08:00
|
|
|
|
#ifndef PM3PROCESS_H
|
|
|
|
|
#define PM3PROCESS_H
|
|
|
|
|
|
|
|
|
|
#include <QProcess>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QDebug>
|
2020-04-18 02:01:42 +08:00
|
|
|
|
#include <QTimer>
|
2020-04-07 18:16:00 +08:00
|
|
|
|
#include <QtSerialPort/QSerialPortInfo>
|
|
|
|
|
#include <QtSerialPort/QSerialPort>
|
2020-04-06 23:48:08 +08:00
|
|
|
|
|
|
|
|
|
class PM3Process : public QProcess
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
explicit PM3Process(QObject* parent=nullptr);
|
2020-04-07 18:16:00 +08:00
|
|
|
|
bool start(const QString path, const QString port);
|
|
|
|
|
QStringList findPort();
|
2020-04-11 23:53:06 +08:00
|
|
|
|
QByteArray readLine(qint64 maxlen = 0);
|
|
|
|
|
void setRequiringOutput(bool st);
|
|
|
|
|
QString getRequiredOutput();
|
2020-04-16 00:39:10 +08:00
|
|
|
|
bool waitForReadyRead(int msecs = 2000);
|
2020-04-18 02:01:42 +08:00
|
|
|
|
void setSerialListener(const QString &name, bool state);
|
|
|
|
|
private slots:
|
|
|
|
|
void onTimeout();
|
2020-04-11 23:53:06 +08:00
|
|
|
|
private:
|
|
|
|
|
bool isRequiringOutput;
|
|
|
|
|
QString* requiredOutput;
|
2020-04-18 02:01:42 +08:00
|
|
|
|
QTimer* serialListener;
|
|
|
|
|
QSerialPortInfo* portInfo;
|
|
|
|
|
signals:
|
|
|
|
|
void PM3disconnected();
|
2020-04-06 23:48:08 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // PM3PROCESS_H
|