This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
defcc7c
commit cb4445d
Showing
4 changed files
with
74 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,27 @@ | ||
#ifndef SERIALPACKAGE_H | ||
#define SERIALPACKAGE_H | ||
|
||
#include <QObject> | ||
#include <QString> | ||
#include <QDebug> | ||
|
||
#include "eventlog.h" | ||
|
||
class SerialPackage : public QObject | ||
class SerialPackage | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit SerialPackage(QObject *parent = nullptr); | ||
~SerialPackage(); | ||
|
||
bool parse(const QByteArray &package); | ||
|
||
void test(); | ||
quint8 address(); | ||
quint8 command(); | ||
quint8 checksum(); | ||
|
||
void setAddress(quint8 value); | ||
void setCommand(quint8 value); | ||
|
||
void push(quint8 value); | ||
void push(quint16 value); | ||
void push(quint32 value); | ||
|
||
void pop(quint8 &value); | ||
void pop(quint16 &value); | ||
void pop(quint32 &value); | ||
|
||
private: | ||
QString m_buffer; | ||
explicit SerialPackage(); | ||
|
||
void unpack(quint8 &value, int index); | ||
void unpack(quint16 &value, int index); | ||
void unpack(quint32 &value, int index); | ||
void pack(quint8 value, int index); | ||
void pack(quint16 value, int index); | ||
void pack(quint32 value, int index); | ||
static bool parse(QString &message); | ||
|
||
static const qint8 SIZE_PACKAGE_MINIMUM = 6; | ||
static const qint8 SIZE_PACKAGE_BUFFER = 64; | ||
static quint8 address(const QString &message); | ||
static quint8 command(const QString &message); | ||
static quint8 checksum(const QString &message); | ||
|
||
signals: | ||
void log(EventLogType type, const QString &message); | ||
static QString pack(quint8 value); | ||
static QString pack(quint16 value); | ||
static QString pack(quint32 value); | ||
|
||
static bool unpack(quint8 &value, const QString &textValue); | ||
static bool unpack(quint16 &value, const QString &textValue); | ||
static bool unpack(quint32 &value, const QString &textValue); | ||
}; | ||
|
||
#endif // SERIALPACKAGE_H |