Esempio n. 1
0
int svrGwsPolling(bool _debug_output,SerialCom* comm,int* nTimer) {
    int nData = 0;
    char sData[512];

    if (*nTimer > 0) {
        memset(sData, 0x00, 512);
        SVR_DEBUG(_debug_output,VT100_RESET VT100_INVERT "\b\b\b\b\b\b<%02d>", *nTimer);
        nData = ScRead(comm, sData, 512);
        SVR_DEBUG(_debug_output,"%d",nData);
        if (nData > 0) {
            idel_times = 0;
            BufAppend(&local_gws_buff, sData);
            return TASK_POLLING_RADIO;
        } else { //If we have read something, and after 5 times of reading nothing,
            if (!BufIsEmpty(&local_gws_buff)) {
                idel_times ++;
            }
            if (idel_times >= 5) { //consider it was over
                BufAppend(&local_gws_buff, NULL);
                idel_times = 0;
                SetTimerOut(*nTimer);
                return TASK_UPDATE_RADIO;
            } else return TASK_POLLING_RADIO;
        }
    } else return TASK_IDEL;
}
Esempio n. 2
0
int Buffer::Write(uchar c)
{
    char* ptr = BufAppend(1);
    if (ptr) {
        *ptr = c;
        return 1;
    }
    else
        return -1;
}