Re: [PARPORT] It there a generic Parallel Port Sniffer

From: Urban Widmark (urban@svenskatest.se)
Date: Fri Mar 17 2000 - 15:24:17 EST

  • Next message: Tim Waugh: "Re: [PARPORT] It there a generic Parallel Port Sniffer"

    On Wed, 15 Mar 2000, Grahame M. Kelly wrote:

    > I and others in SLUG are into reverse engineering protocol(s) on some
    > of the newer products (eg: MPEG solid state players) that use parallel
    > port for I/O (its legal to do so in Australia) to build Open Source
    [snip]
    > Any assistance appreciated.

    Ok ... I'm not sure I understand how you run the application and how
    things are connected. The idea below isn't that clever and it isn't a
    ready made solution but it does fall in the "any" category you mention :)

    There is a really neat thing called ppdev in the 2.3 kernels
    (CONFIG_PPDEV, under character devices). It gives a userspace program
    (almost?) complete control over the parallel port. That way you can write
    a simple driver without having to put it in the kernel, but you still get
    help from the parport driver with finding the parallel port and things
    like EPP if the system supports that.

    To "sniff" I guess you want to continously read the state of all lines and
    log that.

    Read more in the kernel sources:
    drivers/char/ppdev.c

    Here are a few snippets that may be of some help:
        if( (fd = open("/dev/parport0", O_RDWR)) == -1) {
            perror("open");
            exit(1);
        }

        if(ioctl(fd, PPCLAIM, NULL) == -1) {
            perror("ioctl");
            exit(1);
        }

        /* setup data direction so that all data pins are input? */

        /* and then lots of read() or ioctl(PPRDATA, ...)
        while(1) {
            read(fd, ...);
            ioctl(fd, PPRDATA, ...);
            ...

            /* would be nicer to wait for something to change on the wire,
               but ... */
            usleep(1000);
        }

    If the application is running on the linux box then this may not work at
    all (but PPRDATA should?), but then you should be able to sniff the data
    by reading the io ports, typically at:
    #define DATA 0x378
    #define STATUS (DATA+1)
    #define CONTROL (DATA+2)
        ioperm(DATA, 3, 1);

        x = inb(DATA);
        y = inb(STATUS);
        z = inb(CONTROL);
    ...

    /Urban

    -- To unsubscribe, send mail to: linux-parport-request@torque.net --
    -- with the single word "unsubscribe" in the body of the message. --



    This archive was generated by hypermail 2b29 : Fri Mar 17 2000 - 15:29:11 EST