equal
deleted
inserted
replaced
|
1 /* |
|
2 * Source File : me8100_test_dio.c |
|
3 * Destination : me8100_test_dio |
|
4 * Author : GG (Guenter Gebhardt) |
|
5 * |
|
6 * |
|
7 * File History: Version Date Editor Action |
|
8 *--------------------------------------------------------------------- |
|
9 * 1.00.00 01.07.12 GG first release |
|
10 * |
|
11 *--------------------------------------------------------------------- |
|
12 * |
|
13 * Description: |
|
14 * This program shows the use of the driver and the digital inputs |
|
15 * and outputs. First the outputs are tested in sink and source mode. |
|
16 * Then the inputs are tested. |
|
17 */ |
|
18 #include <stdio.h> |
|
19 #include <fcntl.h> |
|
20 #include <unistd.h> |
|
21 #include <sys/ioctl.h> |
|
22 #include <signal.h> |
|
23 |
|
24 #include "me8100.h" |
|
25 |
|
26 int main(void){ |
|
27 int err = 0; |
|
28 static int file_handle = -1; |
|
29 |
|
30 unsigned short value_a; |
|
31 |
|
32 printf("Read test, PID: %d\n", getpid()); |
|
33 file_handle = open("/dev/me8100_0", O_RDWR, 0); |
|
34 |
|
35 if(file_handle < 0){ |
|
36 printf("Cannot open path !\n"); |
|
37 return 1; |
|
38 } |
|
39 |
|
40 for (;;) { |
|
41 ioctl(file_handle, ME8100_READ_DI_A, &value_a); |
|
42 printf("Read %04x\n", value_a); |
|
43 sleep(1); |
|
44 } |
|
45 |
|
46 err = close(file_handle); |
|
47 if(err){ |
|
48 printf("Kann Pfad nicht schliessen\n"); |
|
49 return 1; |
|
50 } |
|
51 |
|
52 return 0; |
|
53 } |
|
54 /* |
|
55 vim:sts=2 sw=2 aw ai sm: |
|
56 */ |