//............................................................................ void QS_onEvent(void) { uint16_t nBytes = 1024; uint8_t const *block; QF_CRIT_ENTRY(dummy); if ((block = QS::getBlock(&nBytes)) != (uint8_t *)0) { QF_CRIT_EXIT(dummy); QSPY_parse(block, nBytes); } else { QF_CRIT_EXIT(dummy); } }
//............................................................................ void QP::QS_onEvent(void) { uint16_t nBytes = 1024; uint8_t const *block; QF_CRIT_ENTRY(dummy); if ((block = QS::getBlock(&nBytes)) != static_cast<uint8_t *>(0)) { QF_CRIT_EXIT(dummy); QSPY_parse(block, nBytes); } else { QF_CRIT_EXIT(dummy); } }
/*..........................................................................*/ static DWORD WINAPI idleThread(LPVOID par) {/* signature for CreateThread() */ (void)par; l_running = (uint8_t)1; while (l_running) { Sleep(10); /* wait for a while */ if (_kbhit()) { /* any key pressed? */ char payload[1024]; if(!gets_s(payload, sizeof(payload))) { // EOF reached printf("EOF received; exiting\n"); QF_stop(); } else { uint16_t len = strlen(payload); onPacket(payload, len, BSPConsole_print, NULL); } } #ifdef Q_SPY { uint16_t nBytes = 1024; uint8_t const *block; QF_CRIT_ENTRY(dummy); block = QS_getBlock(&nBytes); QF_CRIT_EXIT(dummy); if (block != (uint8_t *)0) { send(l_sock, (char const *)block, nBytes, 0); } } #endif } return 0; /* return success */ }
//............................................................................ void QP::QS::onFlush(void) { uint16_t nBytes = 1000; uint8_t const *block; QF_CRIT_ENTRY(dummy); while ((block = getBlock(&nBytes)) != (uint8_t *)0) { QF_CRIT_EXIT(dummy); QSPY_parse(block, nBytes); nBytes = 1024; } }
static DWORD WINAPI idleThread(LPVOID par) { // signature for CreateThread() (void)par; l_running = (uint8_t)1; while (l_running) { uint16_t nBytes = 1024; uint8_t const *block; QF_CRIT_ENTRY(dummy); block = QS::getBlock(&nBytes); QF_CRIT_EXIT(dummy); if (block != (uint8_t *)0) { send(l_sock, (char const *)block, nBytes, 0); } Sleep(10); // wait for a while } return 0; // return success }
/*..........................................................................*/ void QS_onFlush(void) { for (;;) { uint16_t nBytes = 1024; uint8_t const *block; QF_CRIT_ENTRY(dummy); block = QS_getBlock(&nBytes); QF_CRIT_EXIT(dummy); if (block != (uint8_t const *)0) { QSPY_parse(block, nBytes); nBytes = 1024; } else { break; } } }
/*..........................................................................*/ static DWORD WINAPI idleThread(LPVOID par) {/* signature for CreateThread() */ (void)par; SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); l_running = (uint8_t)1; while (l_running) { uint16_t nBytes = 256; uint8_t const *block; QF_CRIT_ENTRY(dummy); block = QS_getBlock(&nBytes); QF_CRIT_EXIT(dummy); if (block != (uint8_t *)0) { QSPY_parse(block, nBytes); } Sleep(10); /* wait for a while */ } return 0; /* return success */ }
/*..........................................................................*/ static DWORD WINAPI idleThread(LPVOID par) {/* signature for CreateThread() */ (void)par; while (l_sock != INVALID_SOCKET) { uint16_t nBytes; uint8_t const *block; /* try to receive bytes from the QS socket... */ nBytes = QS_rxGetNfree(); if (nBytes > 0U) { uint8_t buf[64]; int status; if (nBytes > sizeof(buf)) { nBytes = sizeof(buf); } status = recv(l_sock, (char *)buf, (int)nBytes, 0); if (status != SOCKET_ERROR) { uint16_t i; nBytes = (uint16_t)status; for (i = 0U; i < nBytes; ++i) { QS_RX_PUT(buf[i]); } } } QS_rxParse(); /* parse all the received bytes */ nBytes = 1024U; QF_CRIT_ENTRY(dummy); block = QS_getBlock(&nBytes); QF_CRIT_EXIT(dummy); if (block != (uint8_t *)0) { send(l_sock, (char const *)block, nBytes, 0); } Sleep(20); /* sleep for xx milliseconds */ } return (DWORD)0; /* return success */ }