Re: [PARPORT] Using C to program printer port

From: Joseph DiVerdi (diverdi@xtrsystems.com)
Date: Sun Jan 26 2003 - 19:19:07 EST

  • Next message: Jim Earl: "[PARPORT] Fw: Using C to program printer port"

    Not silly just basic. Here is a working example:

    ----------------------------------------------
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/io.h>

    #define BASE 0x378
    #define DATA BASE+0
    #define STATUS BASE+1
    #define CONTROL BASE+2
    #define PIN16 0x04

    int main()
    {
            unsigned value;
            
            if (ioperm(BASE, 3, 1)) {
                    printf("IO space access denied!\n");
                    exit(1);
            }
            
            value = 0;
            value = inb(CONTROL);
                    
            while (1) {
                    outb(value | PIN16, CONTROL);
                    outb(value & ~PIN16, CONTROL);
            } while (0);
            
    }
    ----------------------------------------------

    I just used this program earlier today on a RedHat Linux 7.2 AMD K6 system to diddle pin # 16 on the parallel port's DB-25 connector.

    Hope this helps.
    Joseph

    -- 
    Joseph A. DiVerdi, Ph.D., M.B.A.          
    http://diverditech.com/           970.980.5868 (voice) 
    http://xtrsystems.com/            970.224.3723 (fax)
    PGP Key ID: 0xD50A9E33
    

    -- 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 : Sun Jan 26 2003 - 19:26:18 EST