2026-06-01 09:46:36 +08:00
|
|
|
|
#ifndef TERMINAL_H
|
|
|
|
|
|
#define TERMINAL_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
|
|
|
|
#include "QDebug"
|
|
|
|
|
|
#include "QThread"
|
|
|
|
|
|
#include "mavlink.h"
|
|
|
|
|
|
#include "QTimer"
|
|
|
|
|
|
#include "QTime"
|
|
|
|
|
|
#include <QtEndian>
|
|
|
|
|
|
|
|
|
|
|
|
#include "ThreadTemplet.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef QtMavlinkNode
|
|
|
|
|
|
#include <mavlinknodeglobal.h>
|
|
|
|
|
|
class MAVLINKNODESHARED_EXPORT terminal : public ThreadTemplet {
|
|
|
|
|
|
#else
|
|
|
|
|
|
class terminal : public ThreadTemplet
|
|
|
|
|
|
{
|
|
|
|
|
|
#endif
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit terminal(QObject *parent = nullptr);
|
|
|
|
|
|
~terminal();
|
|
|
|
|
|
mavlink_serial_control_t m_serial_control;
|
|
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
//读取和写入指令
|
|
|
|
|
|
void Transmit(QString msg);
|
|
|
|
|
|
|
|
|
|
|
|
//线程对外接口
|
|
|
|
|
|
void Parse(mavlink_message_t msg);
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
//线程私有接口
|
|
|
|
|
|
|
|
|
|
|
|
void process();
|
|
|
|
|
|
|
|
|
|
|
|
//状态机
|
|
|
|
|
|
void ReadStateMachine(void);
|
|
|
|
|
|
void WriteStateMachine(void);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//所有相关函数
|
|
|
|
|
|
void serial_control(void);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void readError();
|
|
|
|
|
|
|
|
|
|
|
|
void commandAccepted(bool flag,uint16_t command,uint8_t result);
|
|
|
|
|
|
|
|
|
|
|
|
void Recieve(QString msg);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
bool running_flag = false;
|
|
|
|
|
|
quint32 running_frq = 200;//200Hz
|
|
|
|
|
|
QThread *thread = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//超时时间(ms)
|
|
|
|
|
|
int readTimeout = 5000;
|
|
|
|
|
|
int sendTimeout = 5000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString SerialData;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // STATUSPROCESS_H
|