Пример #1
0
retCode sliceDisp(ioPo out, termPo t, integer precision, integer depth, logical alt) {
  listPo list = C_LIST(t);
  basePo base = C_BASE(list->base);

  retCode ret = outChar(out, '[');

  if (depth > 0) {
    integer ix = list->start;
    integer lx = ix + list->length;
    integer maxIx = (precision == 0 ? list->length + 1 : precision);

    char *sep = "";

    while (ret == Ok && ix < lx && maxIx-- > 0) {
      ret = outStr(out, sep);
      sep = ", ";
      if (ret == Ok)
        ret = dispTerm(out, base->els[ix], precision, depth - 1, alt);
      ix++;
    }
    if (ret == Ok && maxIx <= 0) {
      ret = outStr(out, "..");
    }
  } else if (ret == Ok)
    ret = outStr(out, "..");

  if (ret == Ok)
    ret = outChar(out, ']');
  return ret;
}
Пример #2
0
void outHexHalfByte(uint8_t b)
{
  b &= 0x0f;
  if ( b < 10 )
    outChar(b+'0');
  else
    outChar(b+'a'-10);
}
Пример #3
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();
}
Пример #4
0
int main(void) {
  uint8_t u8_c;

  configBasic(HELLO_MSG);

  while (1) {
    u8_c = inChar();
    --u8_c;
    outChar(u8_c);
  }
}
Пример #5
0
void outStr(const char *s)
{
  while( *s )
    outChar(*s++);
}