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; }
/** Read short command pDev: pointer to the device interface pCmd: pointer to command data \return IFX_SUCCESS if no error, otherwise IFX_ERROR */ IFX_int32_t VINETIC_Read_Sc (VINETIC_DEVICE * pDev, VINETIC_IO_READ_SC * pCmd) { IFX_uint16_t cmd = 0; IFX_int32_t err = IFX_SUCCESS; /* set parameters */ cmd = CMD1_RD | CMD1_SC | pCmd->nCmd; if (pCmd->nBc) { cmd |= CMD1_BC; } cmd |= (pCmd->nCh & CMD1_CH); err = ScRead (pDev, cmd, pCmd->pData, pCmd->count); return err; }