Initial commit: add Location Plotter
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class QSocketNotifier;
|
||||
class QTimer;
|
||||
|
||||
class SerialReader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SerialReader(QObject *parent = nullptr);
|
||||
~SerialReader() override;
|
||||
|
||||
[[nodiscard]] bool isOpen() const;
|
||||
[[nodiscard]] QString portName() const;
|
||||
|
||||
public slots:
|
||||
bool openPort(const QString &path, int baudRate);
|
||||
void closePort();
|
||||
|
||||
signals:
|
||||
void lineReceived(const QString &line);
|
||||
void statusChanged(const QString &status);
|
||||
void errorOccurred(const QString &message);
|
||||
|
||||
private slots:
|
||||
void handleReadyRead();
|
||||
void flushPartialLine();
|
||||
|
||||
private:
|
||||
bool configurePort(int baudRate);
|
||||
void processBuffer();
|
||||
void setModemControlLines();
|
||||
void emitSystemError(const QString &prefix);
|
||||
|
||||
int m_fd = -1;
|
||||
QSocketNotifier *m_notifier = nullptr;
|
||||
QTimer *m_pollTimer = nullptr;
|
||||
QTimer *m_partialLineTimer = nullptr;
|
||||
QByteArray m_buffer;
|
||||
QString m_portName;
|
||||
};
|
||||
Reference in New Issue
Block a user