Re: [PARPORT] Problem with hardware aquiring port

From: Nate Jenkins (nate@uniwest.com)
Date: Wed Mar 05 2003 - 12:20:09 EST

  • Next message: Lucian Daniliuc: "[PARPORT] Problem with hardware aquiring port"

    Maybe I do not understand what you are trying to do...

    Why do you need to call open this way?
    p = open (argv[1], O_EXCL);
    Doesn't the later call give you exclusive access to the port?
    ioctl (p, PPCLAIM, 0);

    If you are trying to read and write to the port, then wouldn't you need to
    call open differently? Or does that flag mean all privileges?

    Why are you doing opens and claims inside of loop? Should you not do the
    exclusive claiming prior to loop and then if success, do the work inside the
    loop?

    Nate

    ----- Original Message -----
    From: "Lucian Daniliuc" <lucian@psdtimis.ro>
    To: <linux-parport@torque.net>
    Sent: Wednesday, March 05, 2003 9:20 AM
    Subject: [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. --
    >
    >

    -- 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 - 12:20:57 EST