/* Output Input Data0 BUSY DATA1 PAPERE DATA2 SELECT DATA3 ERROR DATA4 ACK Results of ioctl(fd, PPIGSTATUS, &status): Bit 0V 5V name MSB 1 0 BUSY 6th 0 1 ACK 5th 0 1 PAPERE 4th 0 1 SELECT 3rd 0 1 ERROR 2nd NC 1st NC 0th NC */ #include /* for open(2) close(2) */ #include /* for open(2) close(2) */ #include /* for ppi(4) */ #include /* for ppi(4) */ #include /* for getchar(3), fprintf(3) */ void printbinary(u_int8_t val) { u_int8_t cmp; cmp = 0x80; fprintf(stdout, "%1d\n", (cmp & val)?1:0); } main() { int fd; /* Integer which points /dev/ppi */ u_int8_t val; /* Data to output */ u_int8_t status; /* Status register */ if ((fd=open("/dev/ppi0", O_RDWR)) == -1) { fprintf(stderr, "Error!\n"); exit(); } ioctl(fd, PPIGSTATUS, &status); printbinary(status); close(fd); }