QTools  6.9.4
Collection of Host-Based Tools
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.4"
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 void QSPY_cleanup(void); /* cleanup after the run */
164 
165 char const* QSPY_tstampStr(void);
166 
167 /* last human-readable line of output from QSPY */
168 #define QS_LINE_OFFSET 8
170 typedef struct {
172  int len; /* the length of the composed string */
173  int rec; /* the corresponding QS record ID */
174  int type; /* the type of the output */
176 
178 
179 void QSPY_onPrintLn(void); /* callback to print the last line of output */
180 
181 #define SNPRINTF_LINE(format_, ...) do { \
182  int n_ = SNPRINTF_S(&QSPY_output.buf[QS_LINE_OFFSET], \
183  (QS_LINE_LEN_MAX - QS_LINE_OFFSET), \
184  format_, ##__VA_ARGS__); \
185  if ((0 < n_) && (n_ < QS_LINE_LEN_MAX - QS_LINE_OFFSET)) { \
186  QSPY_output.len = n_; \
187  } \
188  else { \
189  QSPY_output.len = QS_LINE_LEN_MAX - QS_LINE_OFFSET; \
190  } \
191 } while (0)
192 
193 #define SNPRINTF_APPEND(format_, ...) do { \
194  int n_ = SNPRINTF_S(&QSPY_output.buf[QS_LINE_OFFSET + QSPY_output.len],\
195  (QS_LINE_LEN_MAX - QS_LINE_OFFSET - QSPY_output.len), \
196  format_, ##__VA_ARGS__); \
197  if ((0 < n_) \
198  && (n_ < QS_LINE_LEN_MAX - QS_LINE_OFFSET - QSPY_output.len)) { \
199  QSPY_output.len += n_; \
200  } \
201  else { \
202  QSPY_output.len = QS_LINE_LEN_MAX - QS_LINE_OFFSET; \
203  } \
204 } while (0)
205 
206 /* prints information message to the QSPY output (without sending it to FE) */
207 void QSPY_printInfo(void);
208 
209 /* prints error message to the QSPY output (sending it to FE) */
210 void QSPY_printError(void);
211 
212 /* for backwards compatibility */
213 #define QSPY_line (&QSPY_output.buf[QS_LINE_OFFSET])
214 
215 #ifdef __cplusplus
216 }
217 #endif
218 
219 #endif /* QSPY_H */
QSpyStatus
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
Definition: qspy.h:74
QSpyCommands
Definition: qspy.h:56
@ QSPY_SEQUENCE_OUT
Definition: qspy.h:63
@ QSPY_SEND_CURR_OBJ
Definition: qspy.h:66
@ QSPY_SCREEN_OUT
Definition: qspy.h:60
@ QSPY_ATTACH
Definition: qspy.h:57
@ QSPY_SEND_TEST_PROBE
Definition: qspy.h:68
@ QSPY_SEND_AO_FILTER
Definition: qspy.h:65
@ QSPY_MATLAB_OUT
Definition: qspy.h:62
@ QSPY_SAVE_DICT
Definition: qspy.h:59
@ QSPY_BIN_OUT
Definition: qspy.h:61
@ QSPY_DETACH
Definition: qspy.h:58
@ QSPY_SEND_COMMAND
Definition: qspy.h:67
@ QSPY_SEND_EVENT
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
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:169
@ INF_OUT
Definition: qspy.h:169
@ ERR_OUT
Definition: qspy.h:169
@ REG_OUT
Definition: qspy.h:169
void QSPY_reset(void)
int32_t len
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_cleanup(void)
void QSPY_printInfo(void)
QSPY_LastOutput QSPY_output
uint8_t rec
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
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:168
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)