equal
deleted
inserted
replaced
40 if(file_handle < 0){ |
40 if(file_handle < 0){ |
41 printf("Cannot open path !\n"); |
41 printf("Cannot open path !\n"); |
42 return 1; |
42 return 1; |
43 } |
43 } |
44 |
44 |
45 for (;;) { |
45 for (;;sleep(1)) { |
46 #ifdef USE_READ |
46 #ifdef USE_READ |
47 read(file_handle, &value_a, sizeof(value_a)); |
47 int n; |
|
48 n =read(file_handle, &value_a, sizeof(value_a)); |
|
49 if (n == 0) { |
|
50 fprintf(stderr, "read 0 bytes\n"); |
|
51 continue; |
|
52 } |
|
53 if (n < 0) { |
|
54 fprintf(stderr, "read 0 bytes: %m\n"); |
|
55 continue; |
|
56 } |
48 #else |
57 #else |
49 ioctl(file_handle, ME8100_READ_DI_A, &value_a); |
58 ioctl(file_handle, ME8100_READ_DI_A, &value_a); |
50 #endif |
59 #endif |
51 printf("Read %04x\n", value_a); |
60 printf("Read %04x\n", value_a); |
52 sleep(1); |
|
53 } |
61 } |
54 |
62 |
55 err = close(file_handle); |
63 err = close(file_handle); |
56 if(err){ |
64 if(err){ |
57 printf("Kann Pfad nicht schliessen\n"); |
65 printf("Kann Pfad nicht schliessen\n"); |