[PARPORT] Porting an old program to C

From: Robert Davidson (bobdavo@optushome.com.au)
Date: Mon Mar 10 2003 - 15:44:41 EST

  • Next message: mark anderson: "[PARPORT] ECP and DMA"

    Hi all,

    I'm in the process of trying to port a really old (1993 or so) QBASIC
    program to C. The program interfaces with an LCD device which is
    controlled via the parallel port.

    I've read a fair bit of stuff about using outb() and friends in Linux C
    programs, but my problem is that it just doesn't seem to do what I want
    it to do. When I want to send data out to the LCD device I believe I
    need to send it by using hex values, where as I think QBASIC uses
    decimal values.

    So am I right in thinking that these two parts of each program are
    exactly the same?

    QBASIC Source:

    OUT 888, 15
    OUT 890, 7
    SLEEP 1
    OUT 890, 3

    My C Source:

    outb(0x0F, 0x378);
    outb(0x07, 0x37A);
    sleep(1);
    outb(0x03, 0x37A);

    If I can't get this to work I plan on re-writing my test program to use
    the /dev/parport interface and ioctls, but I'm not sure if this would
    help. It's a user-space program, I'm using -O2 with GCC so that outb()
    and that works. I'm using (just for now) iopl(3) to get access from the
    kernel to all ports on the system, but no matter what I do it seems it
    just doesn't want to work, when I run my C program (as root) it does
    some stuff to the LCD display but nothing like what I want it to do.

    When I run the QBASIC program off a boot disk in the same PC it works
    fine. I can post my source code if you like or send it to you in a
    private e-mail, it's very small (20 lines or so).

    -- 
    Regards,
    Robert Davidson.
    http://www.mlug.org.au/
    IRC: puttputt, AustNet, #mlug
    

    -- 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 : Mon Mar 10 2003 - 15:44:58 EST