QTools 6.9.3
qspy.h
Go to the documentation of this file.
1 
40 #ifndef QSPY_H
41 #define QSPY_H
42 
43 #define QSPY_VER "6.9.3"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
50 typedef enum {
54 
56 typedef enum {
57  QSPY_ATTACH = 128,
69  /* ... */
71 
73 typedef struct {
74  uint8_t const *start;
75  uint8_t const *pos;
76  uint32_t tot_len;
77  int32_t len;
78  uint8_t rec;
79 } QSpyRecord;
80 
82 typedef struct {
83  uint16_t version;
84  uint8_t endianness;
85  uint8_t objPtrSize;
86  uint8_t funPtrSize;
87  uint8_t tstampSize;
88  uint8_t sigSize;
89  uint8_t evtSize;
90  uint8_t queueCtrSize;
91  uint8_t poolCtrSize;
92  uint8_t poolBlkSize;
93  uint8_t tevtCtrSize;
94  uint8_t tstamp[6];
95 } QSpyConfig;
96 
97 typedef uint64_t KeyType;
98 typedef uint32_t SigType;
99 typedef uint64_t ObjType;
100 
101 /* limits */
102 enum {
103  QS_RECORD_SIZE_MAX = 512, /* max QS record size [bytes] */
104  QS_LINE_LEN_MAX = 1000, /* max length of a QSPY line [chars] */
105  QS_FNAME_LEN_MAX = 256, /* max length of filenames [chars] */
106  QS_SEQ_LIST_LEN_MAX = 300, /* max length of the Seq list [chars] */
107  QS_DNAME_LEN_MAX = 64, /* max dictionary name length [chars] */
108 };
109 
110 /* pointer to the callback function for customized QS record parsing */
111 typedef int (*QSPY_CustParseFun)(QSpyRecord * const me);
112 typedef void (*QSPY_resetFun)(void);
113 
114 void QSpyRecord_init (QSpyRecord * const me,
115  uint8_t const *start, size_t tot_len);
117 uint32_t QSpyRecord_getUint32(QSpyRecord * const me, uint8_t size);
118 int32_t QSpyRecord_getInt32 (QSpyRecord * const me, uint8_t size);
119 uint64_t QSpyRecord_getUint64(QSpyRecord * const me, uint8_t size);
120 int64_t QSpyRecord_getInt64 (QSpyRecord * const me, uint8_t size);
121 char const *QSpyRecord_getStr (QSpyRecord * const me);
122 uint8_t const *QSpyRecord_getMem(QSpyRecord * const me,
123  uint8_t size,
124  uint32_t *pNum);
125 
126 /* QSPY configuration and high-level interface .............................*/
127 void QSPY_config(QSpyConfig const *config,
128  void *matFile,
129  void *seqFile, char const *seqList,
130  QSPY_CustParseFun custParseFun);
133 
134 void QSPY_configMatFile(void *matFile);
135 void QSPY_configSeqFile(void *seqFile);
136 
137 void QSPY_reset(void);
138 void QSPY_parse(uint8_t const *buf, uint32_t nBytes);
139 void QSPY_txReset(void);
140 
141 void QSPY_setExternDict(char const *dictName);
144 
145 bool QSPY_command(uint8_t cmdId); /* execute an internal QSPY command */
146 void QSPY_sendEvt(QSpyRecord const * const qrec);
147 void QSPY_sendObj(QSpyRecord const * const qrec);
148 void QSPY_sendCmd(QSpyRecord const * const qrec);
149 void QSPY_sendTP (QSpyRecord const * const qrec);
150 
151 size_t QSPY_encode(uint8_t *dstBuf, size_t dstSize,
152  uint8_t const *srcBuf, size_t srcBytes);
153 size_t QSPY_encodeResetCmd(uint8_t *dstBuf, size_t dstSize);
154 size_t QSPY_encodeInfoCmd (uint8_t *dstBuf, size_t dstSize);
155 size_t QSPY_encodeTickCmd (uint8_t *dstBuf, size_t dstSize, uint8_t rate);
156 
157 SigType QSPY_findSig(char const *name, ObjType obj);
158 KeyType QSPY_findObj(char const *name);
159 KeyType QSPY_findFun(char const *name);
160 KeyType QSPY_findUsr(char const *name);
161 
162 void QSPY_stop(void); /* orderly close all used files */
163 char const* QSPY_tstampStr(void);
164 
165 /* last human-readable line of output from QSPY */
166 #define QS_LINE_OFFSET 8
168 typedef struct {
170  int len; /* the length of the composed string */
171  int rec; /* the corresponding QS record ID */
172  int type; /* the type of the output */
174 
176 
177 void QSPY_onPrintLn(void); /* callback to print the last line of output */
178 
179 #define SNPRINTF_LINE(format_, ...) do { \
180  int n_ = SNPRINTF_S(&QSPY_output.buf[QS_LINE_OFFSET], \
181  (QS_LINE_LEN_MAX - QS_LINE_OFFSET), \
182  format_, ##__VA_ARGS__); \
183  if ((0 < n_) && (n_ < QS_LINE_LEN_MAX - QS_LINE_OFFSET)) { \
184  QSPY_output.len = n_; \
185  } \
186  else { \
187  QSPY_output.len = QS_LINE_LEN_MAX - QS_LINE_OFFSET; \
188  } \
189 } while (0)
190 
191 #define SNPRINTF_APPEND(format_, ...) do { \
192  int n_ = SNPRINTF_S(&QSPY_output.buf[QS_LINE_OFFSET + QSPY_output.len],\
193  (QS_LINE_LEN_MAX - QS_LINE_OFFSET - QSPY_output.len), \
194  format_, ##__VA_ARGS__); \
195  if ((0 < n_) \
196  && (n_ < QS_LINE_LEN_MAX - QS_LINE_OFFSET - QSPY_output.len)) { \
197  QSPY_output.len += n_; \
198  } \
199  else { \
200  QSPY_output.len = QS_LINE_LEN_MAX - QS_LINE_OFFSET; \
201  } \
202 } while (0)
203 
204 /* prints information message to the QSPY output (without sending it to FE) */
205 void QSPY_printInfo(void);
206 
207 /* prints error message to the QSPY output (sending it to FE) */
208 void QSPY_printError(void);
209 
210 /* for backwards compatibility */
211 #define QSPY_line (&QSPY_output.buf[QS_LINE_OFFSET])
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif /* QSPY_H */
QSpyStatus
low-level facilities for configuring QSpy and parsing QS records ...
Definition: qspy.h:50
@ QSPY_SUCCESS
Definition: qspy.h:52
@ QSPY_ERROR
Definition: qspy.h:51
uint8_t poolCtrSize
Definition: qspy.h:91
void QSPY_sendTP(QSpyRecord const *const qrec)
SigType QSPY_findSig(char const *name, ObjType obj)
int32_t QSpyRecord_getInt32(QSpyRecord *const me, uint8_t size)
uint8_t endianness
Definition: qspy.h:84
void QSPY_config(QSpyConfig const *config, void *matFile, void *seqFile, char const *seqList, QSPY_CustParseFun custParseFun)
uint8_t const * start
start of the record
Definition: qspy.h:74
QSpyCommands
commands to QSPY;
Definition: qspy.h:56
@ QSPY_SEQUENCE_OUT
toggle Sequence output to a file in QSPY
Definition: qspy.h:63
@ QSPY_SEND_CURR_OBJ
send current Object (QSPY supplying addr)
Definition: qspy.h:66
@ QSPY_SCREEN_OUT
toggle screen output to a file in QSPY
Definition: qspy.h:60
@ QSPY_ATTACH
attach to the QSPY Back-End
Definition: qspy.h:57
@ QSPY_SEND_TEST_PROBE
send Test-Probe (QSPY supplying apiId)
Definition: qspy.h:68
@ QSPY_SEND_AO_FILTER
send Local Filter (QSPY supplying addr)
Definition: qspy.h:65
@ QSPY_MATLAB_OUT
toggle Matlab output to a file in QSPY
Definition: qspy.h:62
@ QSPY_SAVE_DICT
save dictionaries to a file in QSPY
Definition: qspy.h:59
@ QSPY_BIN_OUT
toggle binary output to a file in QSPY
Definition: qspy.h:61
@ QSPY_DETACH
detach from the QSPY Back-End
Definition: qspy.h:58
@ QSPY_SEND_COMMAND
send command (QSPY supplying cmdId)
Definition: qspy.h:67
@ QSPY_SEND_EVENT
send event (QSPY supplying signal)
Definition: qspy.h:64
void QSPY_setExternDict(char const *dictName)
QSpyStatus QSpyRecord_OK(QSpyRecord *const me)
QSpyStatus QSPY_readDict(void)
uint32_t QSpyRecord_getUint32(QSpyRecord *const me, uint8_t size)
size_t QSPY_encode(uint8_t *dstBuf, size_t dstSize, uint8_t const *srcBuf, size_t srcBytes)
uint8_t sigSize
Definition: qspy.h:88
uint64_t KeyType
Definition: qspy.h:97
uint8_t tstampSize
Definition: qspy.h:87
uint8_t const * pos
current position in the stream
Definition: qspy.h:75
uint64_t QSpyRecord_getUint64(QSpyRecord *const me, uint8_t size)
uint32_t SigType
Definition: qspy.h:98
int64_t QSpyRecord_getInt64(QSpyRecord *const me, uint8_t size)
int(* QSPY_CustParseFun)(QSpyRecord *const me)
Definition: qspy.h:111
char const * QSPY_tstampStr(void)
QSpyStatus QSPY_writeDict(void)
uint8_t funPtrSize
Definition: qspy.h:86
QSPY_LastOutputType
Definition: qspy.h:167
@ INF_OUT
Definition: qspy.h:167
@ ERR_OUT
Definition: qspy.h:167
@ REG_OUT
Definition: qspy.h:167
void QSPY_reset(void)
int32_t len
current length of the stream
Definition: qspy.h:77
void QSpyRecord_init(QSpyRecord *const me, uint8_t const *start, size_t tot_len)
bool QSPY_command(uint8_t cmdId)
void QSPY_sendCmd(QSpyRecord const *const qrec)
char const * QSpyRecord_getStr(QSpyRecord *const me)
void QSPY_printInfo(void)
QSPY_LastOutput QSPY_output
uint8_t rec
the record-ID (see enum QSpyRecords in qs.h)
Definition: qspy.h:78
void QSPY_sendEvt(QSpyRecord const *const qrec)
uint8_t const * QSpyRecord_getMem(QSpyRecord *const me, uint8_t size, uint32_t *pNum)
uint8_t tevtCtrSize
Definition: qspy.h:93
void QSPY_parse(uint8_t const *buf, uint32_t nBytes)
void QSPY_stop(void)
void QSPY_configTxReset(QSPY_resetFun txResetFun)
KeyType QSPY_findObj(char const *name)
uint8_t queueCtrSize
Definition: qspy.h:90
uint16_t version
Definition: qspy.h:83
void QSPY_onPrintLn(void)
void QSPY_printError(void)
uint64_t ObjType
Definition: qspy.h:99
uint8_t poolBlkSize
Definition: qspy.h:92
void QSPY_configMatFile(void *matFile)
size_t QSPY_encodeResetCmd(uint8_t *dstBuf, size_t dstSize)
uint8_t objPtrSize
Definition: qspy.h:85
uint32_t tot_len
total length of the record, including chksum
Definition: qspy.h:76
void(* QSPY_resetFun)(void)
Definition: qspy.h:112
@ QS_SEQ_LIST_LEN_MAX
Definition: qspy.h:106
@ QS_RECORD_SIZE_MAX
Definition: qspy.h:103
@ QS_DNAME_LEN_MAX
Definition: qspy.h:107
@ QS_FNAME_LEN_MAX
Definition: qspy.h:105
@ QS_LINE_LEN_MAX
Definition: qspy.h:104
size_t QSPY_encodeTickCmd(uint8_t *dstBuf, size_t dstSize, uint8_t rate)
void QSPY_sendObj(QSpyRecord const *const qrec)
#define QS_LINE_OFFSET
Definition: qspy.h:166
KeyType QSPY_findFun(char const *name)
void QSPY_txReset(void)
uint8_t evtSize
Definition: qspy.h:89
QSpyConfig const * QSPY_getConfig(void)
KeyType QSPY_findUsr(char const *name)
void QSPY_configSeqFile(void *seqFile)
size_t QSPY_encodeInfoCmd(uint8_t *dstBuf, size_t dstSize)
QSPY configuration parameters.
Definition: qspy.h:82
QSPY record being processed.
Definition: qspy.h:73