#include #include #include #include #include #include #define BASEPORT 0x378 /* lp1 */ int main() { char c; int n, tem; printf("Hit Enter key to stop\n"); //set permissions to access port if (ioperm(BASEPORT, 3, 1)) {perror("ioperm"); exit(1);} tem = fcntl(0, F_GETFL, 0); fcntl (0, F_SETFL, (tem | O_NDELAY)); //main loop where actual blinking is done while (1) { //if Enter key is pressed, break out from loop n = read(0, &c, 1); if (n > 0) break; //write 'on' bit on all data pins and wait 1/4 second outb(255, BASEPORT); usleep(250000); //write 'off' bit on all data pins and wait 1/4 second outb(0, BASEPORT); usleep(250000); //if Enter key is pressed, break out from loop n = read(0, &c, 1); if (n > 0) break; } fcntl(0, F_SETFL, tem); outb(0, BASEPORT); //take away permissions to access port if (ioperm(BASEPORT, 3, 0)) {perror("ioperm"); exit(1);} exit(0); }