Line | |
---|
1 | /* This will stop the strobe signal */ |
---|
2 | |
---|
3 | #include <stdio.h> |
---|
4 | #include <stdlib.h> |
---|
5 | #include <unistd.h> |
---|
6 | #include <fcntl.h> /* lowlevel io */ |
---|
7 | #include <errno.h> |
---|
8 | |
---|
9 | #include <sys/ioctl.h> |
---|
10 | #include <linux/ppdev.h> |
---|
11 | #include <linux/parport.h> |
---|
12 | |
---|
13 | #define DEBUG |
---|
14 | #define PARPORT_DEVICE "/dev/parport0" |
---|
15 | |
---|
16 | int main(int argc, char **argv) { |
---|
17 | int parport_fd; |
---|
18 | int mode; /* IEEE1284_MODE_COMAT == compatibility mode */ |
---|
19 | |
---|
20 | parport_fd = open(PARPORT_DEVICE, O_RDWR); |
---|
21 | if(parport_fd == -1) { |
---|
22 | perror("open device failed"); |
---|
23 | return 1; |
---|
24 | } |
---|
25 | |
---|
26 | if(ioctl(parport_fd, PPCLAIM)) { |
---|
27 | perror ("claiming port (PPCLAIM)"); |
---|
28 | close (parport_fd); |
---|
29 | return 1; |
---|
30 | } |
---|
31 | |
---|
32 | mode = IEEE1284_MODE_COMPAT; |
---|
33 | if(ioctl(parport_fd, PPNEGOT, &mode)) { |
---|
34 | perror ("Setting compatibilty mode (PPNEGOT)"); |
---|
35 | close (parport_fd); |
---|
36 | return 1; |
---|
37 | } |
---|
38 | |
---|
39 | { |
---|
40 | static unsigned char mask = PARPORT_CONTROL_STROBE; |
---|
41 | printf("Setting null mask to control pins (strobe,etc.)...\n"); |
---|
42 | if(ioctl(parport_fd, PPWCONTROL, &mask)) { |
---|
43 | perror("null mask"); |
---|
44 | close(parport_fd); |
---|
45 | return 1; |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | ioctl(parport_fd, PPRELEASE); |
---|
50 | close(parport_fd); |
---|
51 | return 0; |
---|
52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.