me8100_test_dio/rtest.c
changeset 12 67e56b4bce81
parent 8 12065fad228b
child 15 b9baa645576a
--- a/me8100_test_dio/rtest.c	Fri Jan 18 21:00:56 2002 +0100
+++ b/me8100_test_dio/rtest.c	Mon Jan 21 19:35:53 2002 +0100
@@ -42,14 +42,22 @@
     return 1;
   }
 
-  for (;;) {
+  for (;;sleep(1)) {
 #ifdef USE_READ
-    read(file_handle, &value_a, sizeof(value_a));
+    int n;
+    n =read(file_handle, &value_a, sizeof(value_a));
+    if (n == 0) {
+      fprintf(stderr, "read 0 bytes\n");
+      continue;
+    } 
+    if (n < 0) {
+      fprintf(stderr, "read 0 bytes: %m\n");
+      continue;
+    }
 #else
     ioctl(file_handle, ME8100_READ_DI_A, &value_a);
 #endif
     printf("Read  %04x\n", value_a);
-    sleep(1);
   }
 
   err = close(file_handle);