/* * example4.c: read the switches and display the switch status in decimal and hex * */ #include #include #include #define BASEPORT 0x2a2 /* PLC-730 card LED Output */ int main() { unsigned char x; /* Get access to the ports */ if (ioperm(BASEPORT, 3, 1)) {perror("ioperm"); exit(1);} while(1) { /* Read from the status port (BASE) and display the result */ x=inb(BASEPORT+1); printf("status: %d or 0x%.2x \n", x,x); } /* We don't need the ports anymore */ if (ioperm(BASEPORT, 3, 0)) {perror("ioperm"); exit(1);} exit(0); }