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