Re: [PARPORT] Example Code

From: Tim Waugh (tim@cyberelk.demon.co.uk)
Date: Fri Mar 30 2001 - 02:34:12 EST

  • Next message: Tim Waugh: "Re: [PARPORT] Freecom CD/RW problems"

    On Thu, Mar 29, 2001 at 04:17:59PM -0800, Peter Ryser wrote:

    > following is a piece of code that might help you with what you are
    > planning to do. Save it as lpttest.c and compile with:
    > gcc -o lpttest lpttest.c

    Of course, since it never strobes the character, it won't actually
    print anything..

    > Using ioctl's to access the parallel port is not very efficient since
    > for every single character you have to go from user space to kernel
    > space and back. A more efficient method would be to use ioperm(), inb()
    > and outb(). But then you have to run the program as root or setuid root.

    A more efficient method is to use the block writes, a bit like you
    indicate:

    > ioctl(fd, PPSETMODE, PARPORT_MODE_STUPID);
    > write(fd, buffer, 100); /* no handshaking, no timeouts, just write
    > data as fast as possible to the data port with only one context switch */

    But it still seems a bit strange to me to want to just write to the
    data port as fast as possible without ever touching the control lines.

    Is there really a need for this?

    (Currently, you can replace PARPORT_MODE_STUPID with
    IEEE1284_MODE_{COMPAT,ECP,EPP} and have it to the obvious thing.)

    Tim.
    */



    -- 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 30 2001 - 02:37:17 EST