Once interrupts are enabled, the parallel port generates an interrupt whenever the electrical signal at pin 10, dubbed the ACK bit, changes from low to high (Corbet et al., 2005).
To toggle the electrical signal at pin 10, I connected pin 10 to pin 9 (using a resistor) and then I executed the program shown in Example 8-2.
Example 8-2. tint.c
#include <sys/types.h> #include <machine/cpufunc.h> #include <err.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #define BASE_ADDRESS 0x378 int main(int argc, char *argv[]) { int fd; fd = open("/dev/io", O_RDWR); if (fd < 0) err(1, "open(/dev/io)"); outb(BASE_ADDRESS, 0x00); outb(BASE_ADDRESS, 0xff); outb(BASE_ADDRESS, 0x00); close(fd); return (0); }
Here, BASE_ADDRESS
denotes the base address of the parallel port. On most contemporary PCs, 0x378
is the base address of the parallel port. However, you can check your machine’s BIOS to be sure.
This program changes the electrical signal at pin 9 of the parallel port from low to high.
If you’re curious, pin 9 is the most significant bit of the parallel data byte (Corbet et al., 2005).
Here are the results from executing Example 8-2:
#echo "DON'T PANIC" > /dev/pint0
#cat /dev/pint0 &
[1] 1056 #./tint
DON'T PANIC
3.145.202.61