Skip to content

Commit 4eda652

Browse files
author
Nguyen Do
committed
Remove QSpy related parts
1 parent 3d7b331 commit 4eda652

File tree

20 files changed

+31
-813
lines changed

20 files changed

+31
-813
lines changed

README.MD

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,4 @@ Open any of the examples and upload to an ESP32.
1515

1616
- Typically `QF::run()` should be executed as a last instruction before QP takes charge of executing the framework. As such, it should not return and instead give control to the scheduler of the host. However, the ESP32 framework (esp-idf) already runs the scheduler [before](https://github.com/espressif/arduino-esp32/blob/8ee5f0a11e5423a018e0f89146e05074466274db/cores/esp32/main.cpp#L55) `void setup()` and `void loop()`. This means that instead of running `QF::run()` in a loop, it suffices to execute it once as the last instruction in `void setup()`.
1717

18-
## QPSY
19-
20-
[QSPY](https://www.state-machine.com/qtools/qspy.html) can be activated by defining `QS_ON`in `bsp.cpp` of both examples
21-
22-
Example of how to communicate with esp32 target with qspy enabled.
23-
24-
```bash
25-
qspy -c YOUR_SERIAL_PORT -b 115200
26-
```
27-
28-
## QView
29-
30-
DPP example can be tested with [QView™](https://www.state-machine.com/qtools/qview.html) example located in `examples/dpp_bsp-esp32/qview`. There are two bat scripts (Windows) which can run the QView scripts.
31-
32-
33-
Note: QSpy must be running before using QView.
34-
35-
36-
37-
18+
- No more QSpy on this port

examples/blinky_bsp-esp32/blinky_bsp-esp32.qm

Lines changed: 10 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,11 @@ public:
9090
#include "blinky.hpp" // Blinky application interface
9191
#include "bsp.hpp" // Board Support Package (BSP)
9292
#include "Arduino.h"
93-
#include "esp_log.h"
9493
#include "esp_freertos_hooks.h"
9594

9695
using namespace QP;
97-
static constexpr unsigned LED_BUILTIN = 13;
98-
// QS facilities
96+
static constexpr unsigned LED_BUILTIN = 2;
9997

100-
// un-comment if QS instrumentation needed
101-
//#define QS_ON
10298
// BSP functions
10399
static void tickHook_ESP32(void); /*Tick hook for QP */
104100
static uint8_t const l_TickHook = static_cast<uint8_t>(0);
@@ -121,62 +117,21 @@ void BSP::init(void) {
121117
pinMode(LED_BUILTIN, OUTPUT);
122118
Serial.begin(115200); // run serial port at 115200 baud rate
123119
QS_INIT(nullptr);
124-
#ifdef QS_ON
125-
// setup the QS filters...
126-
QS_GLB_FILTER(QP::QS_SM_RECORDS); // state machine records
127-
QS_GLB_FILTER(QP::QS_AO_RECORDS); // active object records
128-
QS_GLB_FILTER(QP::QS_UA_RECORDS); // all user records
129-
#endif
130120
}
131121
//............................................................................
132122
void BSP::ledOff(void) {
133123
digitalWrite(LED_BUILTIN, LOW);
134-
log_i("led off");
124+
Serial.println("led off");
135125
}
136126
//............................................................................
137127
void BSP::ledOn(void) {
138128
digitalWrite(LED_BUILTIN, HIGH);
139-
log_i("led on");
129+
Serial.println("led on");
140130
}
141-
142131
//............................................................................
143-
void QSpy_Task(void *) {
144-
while(1)
145-
{
146-
// transmit QS outgoing data (QS-TX)
147-
uint16_t len = Serial.availableForWrite();
148-
if (len > 0U) { // any space available in the output buffer?
149-
uint8_t const *buf = QS::getBlock(&len);
150-
if (buf) {
151-
Serial.write(buf, len); // asynchronous and non-blocking
152-
}
153-
}
154-
155-
// receive QS incoming data (QS-RX)
156-
len = Serial.available();
157-
if (len > 0U) {
158-
do {
159-
QP::QS::rxPut(Serial.read());
160-
} while (--len > 0U);
161-
QS::rxParse();
162-
}
163-
delay(100);
164-
};
165-
}
166-
167132
void QF::onStartup(void) {
168133
esp_register_freertos_tick_hook_for_cpu(tickHook_ESP32, QP_CPU_NUM);
169134
QS_OBJ_DICTIONARY(&l_TickHook);
170-
#ifdef QS_ON
171-
xTaskCreatePinnedToCore(
172-
QSpy_Task, /* Function to implement the task */
173-
"QSPY", /* Name of the task */
174-
10000, /* Stack size in words */
175-
NULL, /* Task input parameter */
176-
configMAX_PRIORITIES-1, /* Priority of the task */
177-
NULL, /* Task handle. */
178-
QP_CPU_NUM); /* Core where the task should run */
179-
#endif
180135
}
181136
//............................................................................
182137
extern "C" Q_NORETURN Q_onAssert(char const * const module, int location) {
@@ -185,63 +140,14 @@ extern "C" Q_NORETURN Q_onAssert(char const * const module, int locati
185140
//
186141
(void)module;
187142
(void)location;
188-
log_e("QP Assert module: %s @ %d", module, location);
143+
Serial.print("QP Assert module: ");
144+
Serial.print(module);
145+
Serial.print("@ ");
146+
Serial.println(location);
189147
QF_INT_DISABLE(); // disable all interrupts
190148
for (;;) { // sit in an endless loop for now
191149
}
192-
}
193-
194-
//----------------------------------------------------------------------------
195-
// QS callbacks...
196-
//............................................................................
197-
namespace QP {
198-
#ifdef Q_SPY
199-
namespace QS {
200-
bool onStartup(void const * arg) {
201-
static uint8_t qsTxBuf[1024]; // buffer for QS transmit channel (QS-TX)
202-
static uint8_t qsRxBuf[128]; // buffer for QS receive channel (QS-RX)
203-
initBuf (qsTxBuf, sizeof(qsTxBuf));
204-
rxInitBuf(qsRxBuf, sizeof(qsRxBuf));
205-
return true; // return success
206-
}
207-
//............................................................................
208-
void onCommand(uint8_t cmdId, uint32_t param1,
209-
uint32_t param2, uint32_t param3)
210-
{
211-
(void)cmdId;
212-
(void)param1;
213-
(void)param2;
214-
(void)param3;
215-
}
216-
//............................................................................
217-
void onCleanup(void) {
218-
}
219-
//............................................................................
220-
QP::QTimeEvtCtr onGetTime(void) {
221-
return millis();
222-
}
223-
//............................................................................
224-
void onFlush(void) {
225-
#ifdef QS_ON
226-
uint16_t len = 0xFFFFU; // big number to get as many bytes as available
227-
uint8_t const *buf = QS::getBlock(&len); // get continguous block of data
228-
while (buf != nullptr) { // data available?
229-
Serial.write(buf, len); // might poll until all bytes fit
230-
len = 0xFFFFU; // big number to get as many bytes as available
231-
buf = QS::getBlock(&len); // try to get more data
232-
}
233-
Serial.flush(); // wait for the transmission of outgoing data to complete
234-
#endif // QS_ON
235-
}
236-
//............................................................................
237-
void onReset(void) {
238-
esp_restart();
239-
}
240-
} // namespace QS
241-
242-
#endif // Q_SPY
243-
244-
} // namespace QP</text>
150+
}</text>
245151
</file>
246152
<file name="blinky.hpp">
247153
<text>#ifndef BLINKY_HPP
@@ -259,7 +165,7 @@ $declare${AOs::AO_Blinky}
259165
#endif // BLINKY_HPP
260166
</text>
261167
</file>
262-
<file name="main.cpp">
168+
<file name="blinky_bsp-esp32.ino">
263169
<text>#include &quot;qpcpp.hpp&quot; // QP-C++ framework
264170
#include &quot;blinky.hpp&quot; // Blinky application interface
265171
#include &quot;bsp.hpp&quot; // Board Support Package (BSP)
@@ -285,7 +191,7 @@ void setup() {
285191
AO_Blinky-&gt;start(1U, // priority
286192
blinky_queueSto, // queue storage for events
287193
Q_DIM(blinky_queueSto), //len of queue
288-
stack,
194+
stack,
289195
sizeof(stack));
290196

291197
QF::run(); // Normally QF Run is located in a loop

examples/blinky_bsp-esp32/bsp.cpp

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@
4242
#include "esp_freertos_hooks.h"
4343

4444
using namespace QP;
45-
static constexpr unsigned LED_BUILTIN = 13;
46-
// QS facilities
45+
static constexpr unsigned LED_BUILTIN = 2;
4746

48-
// un-comment if QS instrumentation needed
49-
//#define QS_ON
5047
// BSP functions
5148
static void tickHook_ESP32(void); /*Tick hook for QP */
5249
static uint8_t const l_TickHook = static_cast<uint8_t>(0);
@@ -69,12 +66,6 @@ void BSP::init(void) {
6966
pinMode(LED_BUILTIN, OUTPUT);
7067
Serial.begin(115200); // run serial port at 115200 baud rate
7168
QS_INIT(nullptr);
72-
#ifdef QS_ON
73-
// setup the QS filters...
74-
QS_GLB_FILTER(QP::QS_SM_RECORDS); // state machine records
75-
QS_GLB_FILTER(QP::QS_AO_RECORDS); // active object records
76-
QS_GLB_FILTER(QP::QS_UA_RECORDS); // all user records
77-
#endif
7869
}
7970
//............................................................................
8071
void BSP::ledOff(void) {
@@ -86,45 +77,10 @@ void BSP::ledOn(void) {
8677
digitalWrite(LED_BUILTIN, HIGH);
8778
Serial.println("led on");
8879
}
89-
9080
//............................................................................
91-
void QSpy_Task(void *) {
92-
while(1)
93-
{
94-
// transmit QS outgoing data (QS-TX)
95-
uint16_t len = Serial.availableForWrite();
96-
if (len > 0U) { // any space available in the output buffer?
97-
uint8_t const *buf = QS::getBlock(&len);
98-
if (buf) {
99-
Serial.write(buf, len); // asynchronous and non-blocking
100-
}
101-
}
102-
103-
// receive QS incoming data (QS-RX)
104-
len = Serial.available();
105-
if (len > 0U) {
106-
do {
107-
QP::QS::rxPut(Serial.read());
108-
} while (--len > 0U);
109-
QS::rxParse();
110-
}
111-
delay(100);
112-
};
113-
}
114-
11581
void QF::onStartup(void) {
11682
esp_register_freertos_tick_hook_for_cpu(tickHook_ESP32, QP_CPU_NUM);
11783
QS_OBJ_DICTIONARY(&l_TickHook);
118-
#ifdef QS_ON
119-
xTaskCreatePinnedToCore(
120-
QSpy_Task, /* Function to implement the task */
121-
"QSPY", /* Name of the task */
122-
10000, /* Stack size in words */
123-
NULL, /* Task input parameter */
124-
configMAX_PRIORITIES-1, /* Priority of the task */
125-
NULL, /* Task handle. */
126-
QP_CPU_NUM); /* Core where the task should run */
127-
#endif
12884
}
12985
//............................................................................
13086
extern "C" Q_NORETURN Q_onAssert(char const * const module, int location) {
@@ -140,56 +96,4 @@ extern "C" Q_NORETURN Q_onAssert(char const * const module, int location) {
14096
QF_INT_DISABLE(); // disable all interrupts
14197
for (;;) { // sit in an endless loop for now
14298
}
143-
}
144-
145-
//----------------------------------------------------------------------------
146-
// QS callbacks...
147-
//............................................................................
148-
namespace QP {
149-
#ifdef Q_SPY
150-
namespace QS {
151-
bool onStartup(void const * arg) {
152-
static uint8_t qsTxBuf[1024]; // buffer for QS transmit channel (QS-TX)
153-
static uint8_t qsRxBuf[128]; // buffer for QS receive channel (QS-RX)
154-
initBuf (qsTxBuf, sizeof(qsTxBuf));
155-
rxInitBuf(qsRxBuf, sizeof(qsRxBuf));
156-
return true; // return success
157-
}
158-
//............................................................................
159-
void onCommand(uint8_t cmdId, uint32_t param1,
160-
uint32_t param2, uint32_t param3)
161-
{
162-
(void)cmdId;
163-
(void)param1;
164-
(void)param2;
165-
(void)param3;
166-
}
167-
//............................................................................
168-
void onCleanup(void) {
169-
}
170-
//............................................................................
171-
QP::QTimeEvtCtr onGetTime(void) {
172-
return millis();
173-
}
174-
//............................................................................
175-
void onFlush(void) {
176-
#ifdef QS_ON
177-
uint16_t len = 0xFFFFU; // big number to get as many bytes as available
178-
uint8_t const *buf = QS::getBlock(&len); // get continguous block of data
179-
while (buf != nullptr) { // data available?
180-
Serial.write(buf, len); // might poll until all bytes fit
181-
len = 0xFFFFU; // big number to get as many bytes as available
182-
buf = QS::getBlock(&len); // try to get more data
183-
}
184-
Serial.flush(); // wait for the transmission of outgoing data to complete
185-
#endif // QS_ON
186-
}
187-
//............................................................................
188-
void onReset(void) {
189-
esp_restart();
190-
}
191-
} // namespace QS
192-
193-
#endif // Q_SPY
194-
195-
} // namespace QP
99+
}

0 commit comments

Comments
 (0)