void flushInterface(void) { // empty output buffer while (sdPutWouldBlock(_interface)); // very small sleep to reduce chance of race conditions chThdSleepMilliseconds(1); // empty input buffer while (!sdGetWouldBlock(_interface)) sdGet(_interface); }
void vexLcdCheckReceiveMessage( LcdData *lcd ) { int16_t i; // any characters if( sdGetWouldBlock(lcd->sdp) ) return; // read up to 16 bytes from serial port for(i=0;i<16;i++) { int16_t c; c = sdGetTimeout( lcd->sdp, TIME_IMMEDIATE); if( c != Q_TIMEOUT ) lcd->rxbuf[i] = c; else break; } // 6 chars ? if( i == 6 ) { // lcd message ? if( (lcd->rxbuf[0] == 0xAA) && (lcd->rxbuf[1] == 0x55) && (lcd->rxbuf[2] == 0x16)) // verify checksum if( !((lcd->rxbuf[4] + lcd->rxbuf[5]) & 0xFF) ) lcd->buttons = lcd->rxbuf[4]; } // flush anything left if( !sdGetWouldBlock(lcd->sdp) ) { chSysLock(); chIQResetI( &(lcd->sdp)->iqueue ); chSysUnlock(); } }
static void cmd_apollo( vexStream *chp, int argc, char *argv[]) { (void)argc; (void)argv; apolloInit(); // run until any key press //while( chIOGetWouldBlock(chp) ) while( sdGetWouldBlock((SerialDriver *)chp) ) { apolloUpdate(); //chThdSleepMilliseconds(50); } apolloDeinit(); }