static size_t diag_read(void *buf, size_t size, size_t count, void *file) { char *ch_buf = (char *) buf; int n = count * size; if (nonblocking) { for (int i = 0; i < n; ++i) { if (!diag_kbhit()) { if (0 == i) { return -EAGAIN; } return i; } if (save_to_buf(ch_buf, diag_getc())) { ch_buf++; } } } else { int i = n; while (i--) { if (save_to_buf(ch_buf, diag_getc())) { ch_buf++; } } } return n; }
static ssize_t diag_read(struct idesc *data, void *buf, size_t nbyte) { char *cbuf = (char *) buf; while (nbyte--) { *cbuf++ = diag_getc(); } return (void *) cbuf - buf; }
/* Receive char via uart and turn on LED */ void *led_handler(void *arg) { uint8_t ch = 0; while (1) { /* Read port */ ch = diag_getc(); ch %= 8; BSP_LED_Init(ch); BSP_LED_On(ch); ksleep(50); BSP_LED_Off(ch); ksleep(50); } return NULL; }
int race_is_car_moved(void) { return !diag_kbhit() && ' ' == diag_getc(); }