hyperion.ng
ProviderRs232.h
1 #pragma once
2 
3 #include <QObject>
4 #include <QSerialPort>
5 #include <QTimer>
6 #include <QString>
7 
8 // Leddevice includes
9 #include <leddevice/LedDevice.h>
10 
14 class ProviderRs232 : public LedDevice
15 {
16  Q_OBJECT
17 
18 public:
22  ProviderRs232();
23 
29  virtual bool init(const QJsonObject &deviceConfig);
30 
34  virtual ~ProviderRs232();
35 
41  int open();
42 
43 private slots:
45  int rewriteLeds();
46 
48  void unblockAfterDelay();
49  void error(QSerialPort::SerialPortError error);
50  void bytesWritten(qint64 bytes);
51  void readyRead();
52 
53 signals:
54  void receivedData(QByteArray data);
55 
56 protected:
65  int writeBytes(const qint64 size, const uint8_t *data);
66 
67  void closeDevice();
68 
69  QString findSerialDevice();
70 
71  // tries to open device if not opened
72  bool tryOpen(const int delayAfterConnect_ms);
73 
74 
76  QString _deviceName;
77 
79  qint32 _baudRate_Hz;
80 
83 
85  QSerialPort _rs232Port;
86 
87  bool _blockedForDelay;
88 
89  bool _stateChanged;
90 
91  qint64 _bytesToWrite;
92  qint64 _bytesWritten;
93  qint64 _frameDropCounter;
94  QSerialPort::SerialPortError _lastError;
95  qint64 _preOpenDelayTimeOut;
96  int _preOpenDelay;
97  bool _enableAutoDeviceName;
98 };
Interface (pure virtual base class) for LedDevices.
Definition: LedDevice.h:32
int writeBytes(const qint64 size, const uint8_t *data)
Writes the given bytes to the RS232-device and.
Definition: ProviderRs232.cpp:205
QSerialPort _rs232Port
The RS232 serial-device.
Definition: ProviderRs232.h:85
qint32 _baudRate_Hz
The used baudrate of the output device.
Definition: ProviderRs232.h:79
int open()
Opens and configures the output device.
Definition: ProviderRs232.cpp:142
The ProviderRs232 implements an abstract base-class for LedDevices using a RS232-device.
Definition: ProviderRs232.h:14
ProviderRs232()
Constructs specific LedDevice.
Definition: ProviderRs232.cpp:15
virtual bool init(const QJsonObject &deviceConfig)
Sets configuration.
Definition: ProviderRs232.cpp:32
virtual ~ProviderRs232()
Destructor of the LedDevice; closes the output device if it is open.
Definition: ProviderRs232.cpp:127
QString _deviceName
The name of the output device.
Definition: ProviderRs232.h:76
int _delayAfterConnect_ms
Sleep after the connect before continuing.
Definition: ProviderRs232.h:82