示例#1
0
uint
receiveVar(char* p_c) {
  // Receive the data by stepping the machine until it outputs
  // something
  do {
    // While there's no data, run the timeout counter
    RECEIVE_ERROR re;
    uint32_t u32_count = 0;
    while (!isCharReady()) {
      if (u32_count < RECEIVE_TIMEOUT)
        u32_count++;
      doHeartbeat();
    }

    // Step the machine
    *p_c = inChar();
    if (u32_count >= RECEIVE_TIMEOUT)
      notifyOfTimeout();
    re = stepReceiveMachine(*p_c);
    if (re != ERR_NONE) {
      outString("Data receive error: ");
      outString(getReceiveErrorString());
      outChar('\n');
    }
  } while (!isReceiveMachineChar() && !isReceiveMachineData());

  // Note that p_c already contains the received character, since it's
  // always the last thing received from inChar().
  return getReceiveMachineIndex();
}
示例#2
0
int Comm::comm_gets( char *Buffer, int max )
{
  unsigned char c;
  int x=0;
  Buffer = NULL;
  do {
    ssize_t rv = read( m_fd, &c, 1 );
    Buffer[ x++ ] = c;
  } while( isCharReady() && ( x<max ) );
  Buffer[x-1]=0;
  return x;
}
示例#3
0
void Comm::FlushInQue( void )
{
  while( isCharReady() ) {
    comm_getc();
  }
}