1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/examples/qqtnetworkexample/qqtserialmessage.h

47 lines
1.1 KiB
C
Raw Normal View History

2017-10-17 22:00:45 +08:00
#ifndef QQTSERIALMESSAGE_H
#define QQTSERIALMESSAGE_H
#include "qqtmessage.h"
#define _SERIAL_HEAD 0xAA55
#define _SERIAL_TAIL 0xCC33
class QQTSerialMessage : public QQtMessage
2017-10-17 22:00:45 +08:00
{
public:
2018-01-15 09:08:57 +08:00
explicit QQTSerialMessage ( QObject* parent = 0 );
2017-10-17 22:00:45 +08:00
const quint16& head() const;
2018-01-15 09:08:57 +08:00
void setHead ( quint16 head );
2017-10-17 22:00:45 +08:00
const quint16& size() const;
2018-01-15 09:08:57 +08:00
void setSize ( quint16 size );
2017-10-17 22:00:45 +08:00
//user
const quint16& cmd() const;
2018-01-15 09:08:57 +08:00
void setCmd ( quint16 cmd );
2017-10-17 22:00:45 +08:00
//user
const QByteArray& data() const;
2018-01-15 09:08:57 +08:00
void setData ( QByteArray& data );
2017-10-17 22:00:45 +08:00
const quint16& sum() const;
2018-01-15 09:08:57 +08:00
void setSum ( quint16 sum );
2017-10-17 22:00:45 +08:00
const quint16& tail() const;
2018-01-15 09:08:57 +08:00
void setTail ( quint16 tail );
2017-10-17 22:00:45 +08:00
void translate();
// QQTSyntax interface
public:
2018-01-15 09:08:57 +08:00
void parser ( const QByteArray& l ) override;
void packer ( QByteArray& l ) const override;
2017-10-17 22:00:45 +08:00
private:
quint16 m_Head;
quint16 m_Size;
quint16 m_Cmd;
QByteArray m_Data;
quint16 m_Sum;
quint16 m_Tail;
};
2018-01-15 09:08:57 +08:00
QDebug operator<< ( QDebug dbg, const QQTSerialMessage& c );
2017-10-17 22:00:45 +08:00
#endif // QQTSERIALMESSAGE_H