62 lines
1.3 KiB
C++
Executable File
62 lines
1.3 KiB
C++
Executable File
/**
|
|
* Connection Handler for the RS232 serial connection to the sfm
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Philipp Dassow, NLST, 2018-01-29
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "logger.h"
|
|
#include <LtsSerialPortQuerry/lts_serial_port_querry.h>
|
|
|
|
#include <QObject>
|
|
#include <QTimer>
|
|
#include <QSerialPort>
|
|
|
|
|
|
namespace EffectShowClient
|
|
{
|
|
|
|
class ConnectionHandlerSerial : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ConnectionHandlerSerial(QObject *parent = nullptr);
|
|
~ConnectionHandlerSerial();
|
|
|
|
bool init();
|
|
bool send(const QByteArray &binaryData);
|
|
bool open();
|
|
bool isOpen() const;
|
|
|
|
|
|
signals:
|
|
/**
|
|
* @brief received emits a byte pair with command and payload byte when a available. It is guaranteed that there will be 2 bytes
|
|
* @param ba is a byte pair, with command 1st and payload 2nd.
|
|
*/
|
|
void received(const QByteArray &ba);
|
|
void connectedToSerialConverter();
|
|
void disconnectedFromSerialConverter();
|
|
|
|
|
|
private slots:
|
|
void read();
|
|
|
|
private:
|
|
bool isValidCommandByte(const unsigned char command);
|
|
bool isValidPayloadByte(const unsigned char payload);
|
|
LtsSerialPortQuerry::LtsSerialPortQuerry *m_spQuerry;
|
|
QSerialPort *m_serialPort;
|
|
QTimer *m_receiveTimeoutTimer;
|
|
QByteArray m_currentDataRead;
|
|
QString m_portName;
|
|
QByteArray *m_readBuffer;
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
|
|
} // namespace EffectShowClient
|