/*====================================================*/ /* File : parport.c */ /* Reading and writing the parallel port */ /* Bruce A. Maxwell */ /*====================================================*/ #include #include #include #include #include #include #include /* Memory address of Parallel port */ #define DATA 0x378 #define STATUS DATA+1 /* This function reads the five input status lines of the parallel port and returns an unsigned char with the low five bits being the bits of interest. */ unsigned char ReadStatusLines(void) { unsigned char val; int fd; // open the port device fd = open("/dev/port", O_RDONLY); // seek to the port address lseek(fd, STATUS, SEEK_SET); // read the port read(fd, &val, 1); // close the port close(fd); // shift the values and invert the top one val = ( val^0x80) >> 3 ; // print out the resulting value in Hex printf("%X\n", (int)val); // return the values return(val); }