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(); }
ReturnStatus g__inchar(processPo p, ptrPo tos) { ioPo io = ioChannel(C_IO(tos[0])); codePoint cp; retCode ret = inChar(io, &cp); if (ret == Ok) { ReturnStatus rt = {.ret=Ok, .result=(termPo) allocateInteger(processHeap(p), cp)}; return rt; } else {
int main(void) { uint8_t u8_c; configBasic(HELLO_MSG); while (1) { u8_c = inChar(); --u8_c; outChar(u8_c); } }