QP/C++  7.0.1
Real-Time Embedded Framework
qs_pkg.hpp
Go to the documentation of this file.
1//============================================================================
2// QP/C++ Real-Time Embedded Framework (RTEF)
3// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
4//
5// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
6//
7// This software is dual-licensed under the terms of the open source GNU
8// General Public License version 3 (or any later version), or alternatively,
9// under the terms of one of the closed source Quantum Leaps commercial
10// licenses.
11//
12// The terms of the open source GNU General Public License version 3
13// can be found at: <www.gnu.org/licenses/gpl-3.0>
14//
15// The terms of the closed source Quantum Leaps commercial licenses
16// can be found at: <www.state-machine.com/licensing>
17//
18// Redistributions in source code must retain this top-level comment block.
19// Plagiarizing this software to sidestep the license obligations is illegal.
20//
21// Contact information:
22// <www.state-machine.com>
23// <info@state-machine.com>
24//============================================================================
30
31#ifndef QS_PKG_HPP
32#define QS_PKG_HPP
33
34//============================================================================
35namespace QP {
36
40enum QSpyRxRecords : std::uint8_t {
58};
59
61constexpr std::uint8_t QS_FRAME = 0x7EU;
62
64constexpr std::uint8_t QS_ESC = 0x7DU;
65
70constexpr std::uint8_t QS_ESC_XOR = 0x20U;
71
73constexpr std::uint8_t QS_GOOD_CHKSUM = 0xFFU;
74
76void QS_target_info_(std::uint8_t const isReset) noexcept;
77
78} // namespace QP
79
80//============================================================================
81// Macros for use inside other macros or internally in the QP code
82
84#define QS_INSERT_BYTE_(b_) \
85 buf_[head_] = (b_); \
86 ++head_; \
87 if (head_ == end_) { \
88 head_ = 0U; \
89 }
90
92#define QS_INSERT_ESC_BYTE_(b_) \
93 chksum_ += (b_); \
94 if (((b_) != QS_FRAME) && ((b_) != QS_ESC)) { \
95 QS_INSERT_BYTE_(b_) \
96 } \
97 else { \
98 QS_INSERT_BYTE_(QS_ESC) \
99 QS_INSERT_BYTE_(static_cast<std::uint8_t>((b_) ^ QS_ESC_XOR)) \
100 priv_.used = (priv_.used + 1U); \
101 }
102
109#define QS_BEGIN_PRE_(rec_, qs_id_) \
110 if (QS_GLB_CHECK_(rec_) && QS_LOC_CHECK_(qs_id_)) { \
111 QS_CRIT_E_(); \
112 QP::QS::beginRec_(static_cast<std::uint_fast8_t>(rec_));
113
120#define QS_END_PRE_() \
121 QP::QS::endRec_(); \
122 QS_CRIT_X_(); \
123 }
124
130#define QS_BEGIN_NOCRIT_PRE_(rec_, qs_id_) \
131 if (QS_GLB_CHECK_(rec_) && QS_LOC_CHECK_(qs_id_)) { \
132 QP::QS::beginRec_(static_cast<std::uint_fast8_t>(rec_));
133
138#define QS_END_NOCRIT_PRE_() \
139 QP::QS::endRec_(); \
140 }
141
142#if (Q_SIGNAL_SIZE == 1U)
146 #define QS_SIG_PRE_(sig_) \
147 (QP::QS::u8_raw_(static_cast<std::uint8_t>(sig_)))
148#elif (Q_SIGNAL_SIZE == 2U)
149 #define QS_SIG_PRE_(sig_) \
150 (QP::QS::u16_raw_(static_cast<std::uint16_t>(sig_)))
151#elif (Q_SIGNAL_SIZE == 4U)
152 #define QS_SIG_PRE_(sig_) \
153 (QP::QS::u32_raw_(static_cast<std::uint32_t>(sig_)))
154#endif
155
157#define QS_U8_PRE_(data_) \
158 (QP::QS::u8_raw_(static_cast<std::uint8_t>(data_)))
159
161#define QS_2U8_PRE_(data1_, data2_) \
162 (QP::QS::u8u8_raw_(static_cast<std::uint8_t>(data1_), \
163 static_cast<std::uint8_t>(data2_)))
164
166#define QS_U16_PRE_(data_) \
167 (QP::QS::u16_raw_(static_cast<std::uint16_t>(data_)))
168
170#define QS_U32_PRE_(data_) \
171 (QP::QS::u32_raw_(static_cast<std::uint32_t>(data_)))
172
175#define QS_STR_PRE_(msg_) (QP::QS::str_raw_(msg_))
176
178#define QS_OBJ_PRE_(obj_) (QP::QS::obj_raw_(obj_))
179
180#if (QS_FUN_PTR_SIZE == 1U)
181 #define QS_FUN_PRE_(fun_) \
182 (QP::QS::u8_raw_(reinterpret_cast<std::uint8_t>(fun_)))
183#elif (QS_FUN_PTR_SIZE == 2U)
184 #define QS_FUN_PRE_(fun_) \
185 (QP::QS::u16_raw_(reinterpret_cast<std::uint16_t>(fun_)))
186#elif (QS_FUN_PTR_SIZE == 4U)
187 #define QS_FUN_PRE_(fun_) \
188 (QP::QS::u32_raw_(reinterpret_cast<std::uint32_t>(fun_)))
189#elif (QS_FUN_PTR_SIZE == 8U)
190 #define QS_FUN_PRE_(fun_) \
191 (QP::QS::u64_raw_(reinterpret_cast<std::uint64_t>(fun_)))
192#else
193
199 #define QS_FUN_PRE_(fun_) \
200 (QP::QS::u32_raw_(reinterpret_cast<std::uint32_t>(fun_)))
201#endif
202
203#if (QF_EQUEUE_CTR_SIZE == 1U)
204
208 #define QS_EQC_PRE_(ctr_) \
209 QS::u8_raw_(static_cast<std::uint8_t>(ctr_))
210#elif (QF_EQUEUE_CTR_SIZE == 2U)
211 #define QS_EQC_PRE_(ctr_) \
212 QS::u16_raw_(static_cast<std::uint16_t>(ctr_))
213#elif (QF_EQUEUE_CTR_SIZE == 4U)
214 #define QS_EQC_PRE_(ctr_) \
215 QS::u32_raw_(static_cast<std::uint32_t>(ctr_))
216#else
217 #error "QF_EQUEUE_CTR_SIZE not defined"
218#endif
219
220
221#if (QF_EVENT_SIZ_SIZE == 1U)
222
226 #define QS_EVS_PRE_(size_) \
227 QS::u8_raw_(static_cast<std::uint8_t>(size_))
228#elif (QF_EVENT_SIZ_SIZE == 2U)
229 #define QS_EVS_PRE_(size_) \
230 QS::u16_raw_(static_cast<std::uint16_t>(size_))
231#elif (QF_EVENT_SIZ_SIZE == 4U)
232 #define QS_EVS_PRE_(size_) \
233 QS::u32_raw_(static_cast<std::uint32_t>(size_))
234#endif
235
236
237#if (QF_MPOOL_SIZ_SIZE == 1U)
238
242 #define QS_MPS_PRE_(size_) \
243 QS::u8_raw_(static_cast<std::uint8_t>(size_))
244#elif (QF_MPOOL_SIZ_SIZE == 2U)
245 #define QS_MPS_PRE_(size_) \
246 QS::u16_raw_(static_cast<std::uint16_t>(size_))
247#elif (QF_MPOOL_SIZ_SIZE == 4U)
248 #define QS_MPS_PRE_(size_) \
249 QS::u32_raw_(static_cast<std::uint32_t>(size_))
250#endif
251
252#if (QF_MPOOL_CTR_SIZE == 1U)
253
257 #define QS_MPC_PRE_(ctr_) \
258 QS::u8_raw_(static_cast<std::uint8_t>(ctr_))
259#elif (QF_MPOOL_CTR_SIZE == 2U)
260 #define QS_MPC_PRE_(ctr_) \
261 QS::u16_raw_(static_cast<std::uint16_t>(ctr_))
262#elif (QF_MPOOL_CTR_SIZE == 4U)
263 #define QS_MPC_PRE_(ctr_) \
264 QS::u32_raw_(static_cast<std::uint32_t>(ctr_))
265#endif
266
267
268#if (QF_TIMEEVT_CTR_SIZE == 1U)
269
273 #define QS_TEC_PRE_(ctr_) \
274 QS::u8_raw_(static_cast<std::uint8_t>(ctr_))
275#elif (QF_TIMEEVT_CTR_SIZE == 2U)
276 #define QS_TEC_PRE_(ctr_) \
277 QS::u16_raw_(static_cast<std::uint16_t>(ctr_))
278#elif (QF_TIMEEVT_CTR_SIZE == 4U)
279 #define QS_TEC_PRE_(ctr_) \
280 QS::u32_raw_(static_cast<std::uint32_t>(ctr_))
281#endif
282
288#define QS_REC_NUM_(enum_) (static_cast<std::uint_fast8_t>(enum_))
289
290#endif // QS_PKG_HPP
namespace associated with the QP/C++ framework
Definition: exa_native.dox:1
constexpr std::uint8_t QS_ESC
Escape character of the QS output protocol.
Definition: qs_pkg.hpp:64
void QS_target_info_(std::uint8_t const isReset) noexcept
send the Target info (object sizes, build time-stamp, QP version)
Definition: qs.cpp:461
constexpr std::uint8_t QS_ESC_XOR
Escape modifier of the QS output protocol.
Definition: qs_pkg.hpp:70
constexpr std::uint8_t QS_GOOD_CHKSUM
Escape character of the QS output protocol.
Definition: qs_pkg.hpp:73
constexpr std::uint8_t QS_FRAME
Frame character of the QS output protocol.
Definition: qs_pkg.hpp:61
QSpyRxRecords
QS received record types (RX channel)
Definition: qs_pkg.hpp:40
@ QS_RX_RESET
reset the Target
Definition: qs_pkg.hpp:43
@ QS_RX_EVENT
inject an event to the Target (post/publish)
Definition: qs_pkg.hpp:57
@ QS_RX_LOC_FILTER
set local filters in the Target
Definition: qs_pkg.hpp:52
@ QS_RX_FILL
fill Target memory
Definition: qs_pkg.hpp:47
@ QS_RX_AO_FILTER
set local AO filter in the Target
Definition: qs_pkg.hpp:53
@ QS_RX_TICK
call QF_tick()
Definition: qs_pkg.hpp:44
@ QS_RX_PEEK
peek Target memory
Definition: qs_pkg.hpp:45
@ QS_RX_CURR_OBJ
set the "current-object" in the Target
Definition: qs_pkg.hpp:54
@ QS_RX_GLB_FILTER
set global filters in the Target
Definition: qs_pkg.hpp:51
@ QS_RX_POKE
poke Target memory
Definition: qs_pkg.hpp:46
@ QS_RX_INFO
query Target info (ver, config, tstamp)
Definition: qs_pkg.hpp:41
@ QS_RX_TEST_TEARDOWN
test teardown
Definition: qs_pkg.hpp:49
@ QS_RX_TEST_PROBE
set a Test-Probe in the Target
Definition: qs_pkg.hpp:50
@ QS_RX_TEST_SETUP
test setup
Definition: qs_pkg.hpp:48
@ QS_RX_COMMAND
execute a user-defined command in the Target
Definition: qs_pkg.hpp:42
@ QS_RX_TEST_CONTINUE
continue a test after QS_RX_TEST_WAIT()
Definition: qs_pkg.hpp:55
@ QS_RX_QUERY_CURR
query the "current object" in the Target
Definition: qs_pkg.hpp:56