pref home next
day2: test parallel in


Added 2 switches to the schematic:

        note: S1 is only connected to pin1. I have done that because pin1 was always 'high' (+5V).

The Source codes:
Linux:
/*
 * test_input.c -- read all the ports specified in hex on the command line
 * p.s. you have to be root
 */

#ifndef __i386__
#  error "This program can't compile or run on non-intel computers"
#else

#include <stdio.h>

#include <stdlib.h>
#include <unistd.h>
#include <asm/io.h>

#define DATA 0x378


int main(int argc, char **argv)
{
    unsigned int i,n;

    setuid(0); /* if we're setuid, do it really */
	n = DATA + 1;
	printf("n = %03x \n",n);
        if (ioperm(n,1,1)) {perror("ioperm()"); exit(1);}
	printf("received status = %02x \n",inb(n));

        printf("%02x: %02x\n",n,inb(n));
	printf("%03x: %d\n",n,inb(n));
    return 0;

}

#endif /* __i386__ */


when I ran the program, this was the output:
[root@warbird parallel]# ./a.out
n = 379
received status = 7f
379: 7f
379: 127
The 127 is because the 7th input bit (pin 11) is inverted. If there is nothing connected, bit o to 6 is zero and bit 7 is 1 (binairy 10000000 gives 127)
When I closed S1 and ran the program again nothing happened. hmmm
when I closed S2 and ran the program, the value 31 was returned


pref home next
day2: test parallel in