Exemplo n.º 1
0
/*..........................................................................*/
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 */
}
Exemplo n.º 2
0
//............................................................................
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;
    }
}
Exemplo n.º 3
0
//............................................................................
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);
    }
}
Exemplo n.º 4
0
Arquivo: bsp.cpp Projeto: dgu123/qpcpp
//............................................................................
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);
    }
}
Exemplo n.º 5
0
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
}
Exemplo n.º 6
0
Arquivo: bsp.c Projeto: alisonjoe/qpc
/* QF callbacks ============================================================*/
void QF_onStartup(void) {
    QF_CRIT_STAT_TYPE cpu_sr;
    QF_CRIT_ENTRY(cpu_sr); /* DISABLED interrupts */

    /* initialize the system clock tick... */
    OS_CPU_SysTickInit(SystemCoreClock / OS_TICKS_PER_SEC);

    /* set priorities of ALL ISRs used in the system */
    NVIC_SetPriority(EXTI0_IRQn,   0xFFU);
    /* ... */

    /* enable IRQs in the NVIC... */
    NVIC_EnableIRQ(EXTI0_IRQn);

    /* NOTE: do not exit the critical section and leave interrupts DISABLED */
    (void)cpu_sr; /* avoid compiler warning about unused variable */
}
Exemplo n.º 7
0
/*..........................................................................*/
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;
        }
    }
}
Exemplo n.º 8
0
/*..........................................................................*/
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 */
}
Exemplo n.º 9
0
/*..........................................................................*/
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 */
}