Re: Direct access to parport

From: Eric Lammerts (eric@lammerts.org)
Date: Tue Mar 04 2003 - 17:31:52 EST


On Tue, 4 Mar 2003, Uwe Reimann wrote:
> I'd like to connect some self made hardware to the parallel port and
> read the values of the dataline using linux. Can this be done in
> userspace or do I have to write kernel code to do so? I'm currently
> thinking of writing a device like lp, which in turn uses the parport
> device. Does this sound like a good idea?

>From userspace it's quite simple:

#include <stdio.h>
#include <sys/io.h>

int main(int argc, char **argv)
{
        int addr = 0x378;

        if(ioperm(addr, 3, 1) == -1) {
                perror("ioperm");
                exit(1);
        }
        printf("0x%02x\n", inb(addr + 1));
}

The ioperm() only works if you're root.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 07 2003 - 22:00:25 EST