-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqs_cmdthread.h
More file actions
113 lines (91 loc) · 2.62 KB
/
qs_cmdthread.h
File metadata and controls
113 lines (91 loc) · 2.62 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
* @file qs_cmdthread.h
* @author Fernando Morani
* @date 28 Mar 2022
* @brief Header file for the thread class that manages command
*/
#include <QObject>
#include <QThread>
#include <QDebug>
#include "qs_bootprotocoldef.h"
#include "qs_bootprotocolstruct.h"
#include "qs_serialthread.h"
class QS_CmdThread : public QS_SerialThread
{
Q_OBJECT
public:
QS_CmdThread(QObject *parent);
~QS_CmdThread();
/*!
* \brief setCmdRunning: Set the command is running flag
* \param _isRunning
*/
void setCmdRunning(bool _isRunning){m_cmdRunning = _isRunning;}
/*!
* \brief setBankInfoToSend: set payload info for QS_BOOTP_ERASE
* \param _ack
* \param _bankNumber
*/
void setBankInfoToSend(uint8_t _ack, uint8_t _bankNumber);
/*!
* \brief setReadFlashInfoToSend set payload info for QS_BOOTP_READ_FLASH
* \param _address
* \param _bytes_to_read
*/
void setReadFlashInfoToSend(uint16_t _address, uint16_t _bytes_to_read);
/*!
* \brief setWriteFlashInfoToSend set payload info for QS_BOOTP_WRITE_FLASH
* \param _block
* \param _element
*/
void setWriteFlashInfoToSend(uint8_t _block, uint8_t _element);
/*!
* \brief setPolicyInfo: Set policy info for the current command
* \param _policy
*/
void setPolicyInfo(POLICY_INFO _policy);
/*!
* \brief isCmdRunning: Get if a command is currently running
* \return
*/
bool isCmdRunning(){return m_cmdRunning;}
/*!
* \brief prepCommand: Prepare command to send
* \param _idCmd
* \return
*/
bool prepCommand(int _idCmd);
/*!
* \brief startSerialConnection: Start serial connection
* \param _comPort
* \param _baudRate
* \return
*/
bool startSerialConnection(QString _comPort, uint32_t _baudRate);
/*!
* \brief stopSerialConnection
*/
void stopSerialConnection();
/*!
* \brief resetCmdBuffer
*/
void resetCmdBuffer();
/*!
* \brief queueItemInCmdBuffer
* \param _item
*/
void queueItemInCmdBuffer(uint8_t _item);
QS_BOOT_PROT_T m_cmdToSend;
public slots:
void onRunCommand(int _idCmd);
private:
bool m_cmdRunning; // When true A command is currently running
BANK_INFO_T m_BankInfoToSend;
READ_FROM_FLASH_T m_ReadFromFlashToSend;
WRITE_TO_FLASH_T m_WriteInfoToSend;
POLICY_INFO m_CurrCmdPolInfo; // Policy info of the current command
uint8_t m_FullCmdBuffer[QS_BOOTP_MAX_CMD_LEN ];
int m_CmdBuffIndex;
signals:
void cmdResultReady(bool _result);
};