Tools/Firmware/DynamixelGateway/Host/SerialDevice.cc
//delete all the data in the input buffer
delete all the data in the input buffer
delete all the data in the input buffer
int SerialDevice::FlushInputBuffer()
{
  char c[1000];
  if (!_connected)
  {
#ifdef SERIAL_DEVICE_DEBUG
    std::cout << "SerialDevice::FlushInputBuffer: Error: not connected to the device" << std::endl;
#endif
    return -1;
  }
  int block=_block;
  _SetNonBlockingIO();
  while (read(_fd,c,1000) > 0){}
  if (block==1)
  {
    _SetBlockingIO();
  }
  return 0;
}
int SerialDevice :: FlushInputBuffer ( ) { char c [ 1000 ] ; if ( ! _connected ) { #ifdef SERIAL_DEVICE_DEBUG std :: cout << " " << std :: endl ; #endif return -1 ; } int block = _block ; _SetNonBlockingIO ( ) ; while ( read ( _fd , c , 1000 ) > 0 ) { } if ( block == 1 ) { _SetBlockingIO ( ) ; } return 0 ; }
delete all the data in the input buffer
delete all the data in the input buffer
//check whether we are connected to the device //TODO tcflush for some reason does not work..  //tcflush(_fd, TCIFLUSH); //read off all the chars