-
Notifications
You must be signed in to change notification settings - Fork 1
/
beanpacket.h
88 lines (53 loc) · 1.6 KB
/
beanpacket.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef BEANPACKET_H
#define BEANPACKET_H
#include <QDateTime>
#include <QtSerialPort/QSerialPort>
#include <QString>
#include <QTimer>
class BeanPacket : public QObject {
Q_OBJECT
public:
BeanPacket();
~BeanPacket() override;
explicit BeanPacket(BeanPacket *srcPacket);
qint64 timeEpoch{}; // time recieved by app from serial or previous in monitor
uint8_t dstId{0x00};
uint8_t msgId{0x00};
QString parsedDlc;
uint8_t dlc{8};
uint8_t data[11]{};
uint8_t prio{0};
uint8_t crc{0};
// for monitor
uint counter{1};
uint repeat{0};
bool ro{true}; // read-only
QString debug;
bool bad{}; // packet is bad parsed, etc
static BeanPacket *fromSerialMsg(const QString &serialMsg);
static BeanPacket *fromCSVLine(const QString &csvLine);
void sendToSerialBin(QSerialPort *seriall);
void runPacketSending(int millis);
void stopPacketSending();
QString getPrioStr() const;
QString getParsedDlc() const;
QString getDataStr() const;
QString getDlcStr() const;
QString getMsgIdStr() const;
QString getDstIdStr() const;
QString getCrcStr() const;
QString getRepeatStr() const;
QString getCounterStr() const;
void dataFrom(const QByteArray &arr);
void sendOnce();
private slots:
void sendPacket();
private:
static QString trimQuotes(QString &arg);
static QString parseDataStr(const QString &dataStr);
static QByteArray parseData(const QString &dataStr);
QTimer *timer = nullptr;
void dataFrom(const QString &str);
void notifyModel();
};
#endif // BEANPACKET_H