-
Notifications
You must be signed in to change notification settings - Fork 11
/
serial_io.h
46 lines (29 loc) · 932 Bytes
/
serial_io.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef SERIALIO_H
#define SERIALIO_H
#include <QThread>
class QSerialPort;
class SerialIO : public QThread
{
Q_OBJECT
public:
SerialIO(QString port_name, int baudrate, QObject* parent=nullptr);
signals:
void imageDataParsed(const QString& name, const QImage& image);
void imageParsed(const QString& name);
void paramParsed(const QString& name, double min_value, double max_value, double step_value, double current_value);
void optionParsed(const QString& name, bool current_option);
void buttonParsed(const QString& name);
public slots:
void sendImage(const QString& name);
void sendParam(const QString& name, double value);
void sendOption(const QString& name, bool option);
void sendButton(const QString& name);
private slots:
void tryReadPort();
private:
void run();
void parseOnce();
QByteArray buffer;
QSerialPort* port;
};
#endif // SERIALIO_H