[PARPORT] Problem with hardware aquiring port

From: Lucian Daniliuc (lucian@psdtimis.ro)
Date: Wed Mar 05 2003 - 12:20:23 EST

  • Next message: Tim Waugh: "Re: [PARPORT] Problem with hardware aquiring port"

    I just cannot get exclusive access to the parport, there still seems to be
    some noise getting out the parallel port pins.

    I used ioctl(), in the following piece of code:

    /*
     * User-space parport hogger (for stress-testing parport).
     *
     * Copyright (c) 1998 Tim Waugh <tim@cyberelk.demon.co.uk>
     */

    #include <time.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <sys/ioctl.h>
    #include <linux/ppdev.h>

    int main (int argc, char * argv [])
    {
            int p;
            /* Check we've been told which device to open */
            if (argc < 2) {
                    fprintf (stderr, "Hog which parport???\n");
                    return 1;
            }
            /* Open the device */
            p = open (argv[1], O_EXCL);
            if (p < 0) {
                    fprintf (stderr, "Couldn't open %s\n", argv[1]);
                    return 2;
            }
            /* Now hog the port. */
            for (;;) {
                    const struct timespec w = {5, 250000000}; /* 250ms */

                    /* Claim the port */
                    if (ioctl (p, PPEXCL,0)) {
                            printf ("I guess i couldn't get exclusive.\n");
                            continue;
                    }
                    if (ioctl (p, PPCLAIM, 0)) {
                            printf ("Couldn't claim port!\n");
                            continue;
                    }

                    /* Wait for a while */
                    nanosleep (&w, NULL);

                    /* Release the port */
                    if (ioctl (p, PPRELEASE, 0))
                            printf ("Couldn't release port!\n");
                    putchar ('.');
                    fflush(NULL);
            }

            return 0;
    }

    I don't get any error, everything works fine, but even after aquiring the
    port in EXCLUSIVE mode, i still get signal noise or something out of the
    parallel port.

    I do not have any problem as such under Windoze platform (but W. is
    useless to me).

    Can anyone help?

    ----------------------------
    ataraxis@disponibil.net
    lucian@psdtimis.ro
    0740.959.300

    -- 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 : Wed Mar 05 2003 - 11:05:26 EST