QP/C++ 6.9.3
qs_pkg.hpp
Go to the documentation of this file.
1 
39 #ifndef QS_PKG_HPP
40 #define QS_PKG_HPP
41 
43 #define QS_INSERT_BYTE_(b_) \
44  buf_[head_] = (b_); \
45  ++head_; \
46  if (head_ == end_) { \
47  head_ = 0U; \
48  }
49 
51 #define QS_INSERT_ESC_BYTE_(b_) \
52  chksum_ += (b_); \
53  if (((b_) != QS_FRAME) && ((b_) != QS_ESC)) { \
54  QS_INSERT_BYTE_(b_) \
55  } \
56  else { \
57  QS_INSERT_BYTE_(QS_ESC) \
58  QS_INSERT_BYTE_(static_cast<std::uint8_t>((b_) ^ QS_ESC_XOR)) \
59  ++priv_.used; \
60  }
61 
62 //****************************************************************************
63 // Macros for use inside other macros or internally in the QP code
64 
71 #define QS_BEGIN_PRE_(rec_, qs_id_) \
72  if (QS_GLB_CHECK_(rec_) && QS_LOC_CHECK_(qs_id_)) { \
73  QS_CRIT_E_(); \
74  QP::QS::beginRec_(static_cast<std::uint_fast8_t>(rec_));
75 
82 #define QS_END_PRE_() \
83  QP::QS::endRec_(); \
84  QS_CRIT_X_(); \
85  }
86 
92 #define QS_BEGIN_NOCRIT_PRE_(rec_, qs_id_) \
93  if (QS_GLB_CHECK_(rec_) && QS_LOC_CHECK_(qs_id_)) { \
94  QP::QS::beginRec_(static_cast<std::uint_fast8_t>(rec_));
95 
100 #define QS_END_NOCRIT_PRE_() \
101  QP::QS::endRec_(); \
102  }
103 
104 #if (Q_SIGNAL_SIZE == 1U)
108  #define QS_SIG_PRE_(sig_) \
109  (QP::QS::u8_raw_(static_cast<std::uint8_t>(sig_)))
110 #elif (Q_SIGNAL_SIZE == 2U)
111  #define QS_SIG_PRE_(sig_) \
112  (QP::QS::u16_raw_(static_cast<std::uint16_t>(sig_)))
113 #elif (Q_SIGNAL_SIZE == 4U)
114  #define QS_SIG_PRE_(sig_) \
115  (QP::QS::u32_raw_(static_cast<std::uint32_t>(sig_)))
116 #endif
117 
119 #define QS_U8_PRE_(data_) \
120  (QP::QS::u8_raw_(static_cast<std::uint8_t>(data_)))
121 
123 #define QS_2U8_PRE_(data1_, data2_) \
124  (QP::QS::u8u8_raw_(static_cast<std::uint8_t>(data1_), \
125  static_cast<std::uint8_t>(data2_)))
126 
128 #define QS_U16_PRE_(data_) \
129  (QP::QS::u16_raw_(static_cast<std::uint16_t>(data_)))
130 
132 #define QS_U32_PRE_(data_) \
133  (QP::QS::u32_raw_(static_cast<std::uint32_t>(data_)))
134 
137 #define QS_STR_PRE_(msg_) (QP::QS::str_raw_(msg_))
138 
140 #define QS_OBJ_PRE_(obj_) (QP::QS::obj_raw_(obj_))
141 
142 #if (QS_FUN_PTR_SIZE == 1U)
143  #define QS_FUN_PRE_(fun_) \
144  (QP::QS::u8_raw_(reinterpret_cast<std::uint8_t>(fun_)))
145 #elif (QS_FUN_PTR_SIZE == 2U)
146  #define QS_FUN_PRE_(fun_) \
147  (QP::QS::u16_raw_(reinterpret_cast<std::uint16_t>(fun_)))
148 #elif (QS_FUN_PTR_SIZE == 4U)
149  #define QS_FUN_PRE_(fun_) \
150  (QP::QS::u32_raw_(reinterpret_cast<std::uint32_t>(fun_)))
151 #elif (QS_FUN_PTR_SIZE == 8U)
152  #define QS_FUN_PRE_(fun_) \
153  (QP::QS::u64_raw_(reinterpret_cast<std::uint64_t>(fun_)))
154 #else
155 
161  #define QS_FUN_PRE_(fun_) \
162  (QP::QS::u32_raw_(reinterpret_cast<std::uint32_t>(fun_)))
163 #endif
164 
165 #if (QF_EQUEUE_CTR_SIZE == 1U)
166 
170  #define QS_EQC_PRE_(ctr_) \
171  QS::u8_raw_(static_cast<std::uint8_t>(ctr_))
172 #elif (QF_EQUEUE_CTR_SIZE == 2U)
173  #define QS_EQC_PRE_(ctr_) \
174  QS::u16_raw_(static_cast<std::uint16_t>(ctr_))
175 #elif (QF_EQUEUE_CTR_SIZE == 4U)
176  #define QS_EQC_PRE_(ctr_) \
177  QS::u32_raw_(static_cast<std::uint32_t>(ctr_))
178 #else
179  #error "QF_EQUEUE_CTR_SIZE not defined"
180 #endif
181 
182 
183 #if (QF_EVENT_SIZ_SIZE == 1U)
184 
188  #define QS_EVS_PRE_(size_) \
189  QS::u8_raw_(static_cast<std::uint8_t>(size_))
190 #elif (QF_EVENT_SIZ_SIZE == 2U)
191  #define QS_EVS_PRE_(size_) \
192  QS::u16_raw_(static_cast<std::uint16_t>(size_))
193 #elif (QF_EVENT_SIZ_SIZE == 4U)
194  #define QS_EVS_PRE_(size_) \
195  QS::u32_raw_(static_cast<std::uint32_t>(size_))
196 #endif
197 
198 
199 #if (QF_MPOOL_SIZ_SIZE == 1U)
200 
204  #define QS_MPS_PRE_(size_) \
205  QS::u8_raw_(static_cast<std::uint8_t>(size_))
206 #elif (QF_MPOOL_SIZ_SIZE == 2U)
207  #define QS_MPS_PRE_(size_) \
208  QS::u16_raw_(static_cast<std::uint16_t>(size_))
209 #elif (QF_MPOOL_SIZ_SIZE == 4U)
210  #define QS_MPS_PRE_(size_) \
211  QS::u32_raw_(static_cast<std::uint32_t>(size_))
212 #endif
213 
214 #if (QF_MPOOL_CTR_SIZE == 1U)
215 
219  #define QS_MPC_PRE_(ctr_) \
220  QS::u8_raw_(static_cast<std::uint8_t>(ctr_))
221 #elif (QF_MPOOL_CTR_SIZE == 2U)
222  #define QS_MPC_PRE_(ctr_) \
223  QS::u16_raw_(static_cast<std::uint16_t>(ctr_))
224 #elif (QF_MPOOL_CTR_SIZE == 4U)
225  #define QS_MPC_PRE_(ctr_) \
226  QS::u32_raw_(static_cast<std::uint32_t>(ctr_))
227 #endif
228 
229 
230 #if (QF_TIMEEVT_CTR_SIZE == 1U)
231 
235  #define QS_TEC_PRE_(ctr_) \
236  QS::u8_raw_(static_cast<std::uint8_t>(ctr_))
237 #elif (QF_TIMEEVT_CTR_SIZE == 2U)
238  #define QS_TEC_PRE_(ctr_) \
239  QS::u16_raw_(static_cast<std::uint16_t>(ctr_))
240 #elif (QF_TIMEEVT_CTR_SIZE == 4U)
241  #define QS_TEC_PRE_(ctr_) \
242  QS::u32_raw_(static_cast<std::uint32_t>(ctr_))
243 #endif
244 
250 #define QS_REC_NUM_(enum_) (static_cast<std::uint_fast8_t>(enum_))
251 
252 namespace QP {
253 
255 constexpr std::uint8_t QS_FRAME = 0x7EU;
256 
258 constexpr std::uint8_t QS_ESC = 0x7DU;
259 
264 constexpr std::uint8_t QS_ESC_XOR = 0x20U;
265 
267 constexpr std::uint8_t QS_GOOD_CHKSUM = 0xFFU;
268 
270 void QS_target_info_(std::uint8_t const isReset) noexcept;
271 
272 } // namespace QP
273 
274 #endif // QS_PKG_HPP
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: 16bit/stdint.h:29
namespace associated with the QP/C++ framework
Definition: struct.dox:1
constexpr std::uint8_t QS_ESC
Escape character of the QS output protocol.
Definition: qs_pkg.hpp:258
void QS_target_info_(std::uint8_t const isReset) noexcept
send the Target info (object sizes, build time-stamp, QP version)
Definition: qs.cpp:464
constexpr std::uint8_t QS_ESC_XOR
Escape modifier of the QS output protocol.
Definition: qs_pkg.hpp:264
constexpr std::uint8_t QS_GOOD_CHKSUM
Escape character of the QS output protocol.
Definition: qs_pkg.hpp:267
constexpr std::uint8_t QS_FRAME
Frame character of the QS output protocol.
Definition: qs_pkg.hpp:255