-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserialhelper.h
43 lines (35 loc) · 1.29 KB
/
serialhelper.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
/*!
* \brief Serial Helper Header File
* \author Armin K. Langroodi
* \version 1.0
* \date 2020
* \copyright GNU Public License.
*/
#ifndef SERIALHELPER_H
#define SERIALHELPER_H
//! \include Serial Port
#include <QSerialPort>
//! \include Tree Widget
#include <QTreeWidget>
//! \typedef Read Ready Callback
typedef void (*ReadReadyCallback)(QTreeWidget*, const QByteArray&);
//! \class Serial Communication Serial Helper
class SerialHelper : public QObject
{
Q_OBJECT
//! \public
public:
explicit SerialHelper(QSerialPort *serialPort /*!< [in] Serial Port Pointer */,
QTreeWidget *treeWidget /*!< [in] Tree Widget Object */,
ReadReadyCallback readReadyCallback /*!< [in] Serial Reading Ready Callback */,
QObject *parent = nullptr /*!< UI Pattern */); //!< Constructor
bool Write(const QByteArray &data /*!< [in] Data to be Written */); //!< Write Data to the Serial Port
private slots:
void onReadReady(); //!< On Serial Port Read Ready Signal Slot
//! \private
private:
QSerialPort *serialPort; //!< Serial Port Pointer
QTreeWidget* treeWidget; //!< Tree Widget Object
ReadReadyCallback readReadyCallback; //!< Serial Reading Ready Callback
};
#endif // SERIALHELPER_H