[PARPORT] How to detect the status of the printer connected to parallel port??

From: Archana Vasant Deshmukh (archana.deshmukh@wipro.com)
Date: Thu Nov 15 2001 - 05:34:06 EST

  • Next message: Mirek Kwasniak: "[PARPORT] Re: How to detect the status of the printer connected to parallel port??"

    Hi All,

    I need to detect the status of the printer connected to the parellel port of Linux Machine(kernel 2.4.8),Redhat 6.2

    I have written a small application:

    #include <stdlib.h>
    #include <stdio.h>

    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <sys/ioctl.h>
    #include <linux/lp.h>
    #include <errno.h>

    int main(int argc, char *argv[])
    {
            int fd;
            unsigned int status=0;
            char *fname = "/dev/lp0";

            fd = open(fname, O_RDONLY);

            if(fd <=0 )
            {
                    printf("can not open /dev/lp0\n");
                    return fd ;
            }
            else
            {
                    ioctl(fd, LPGETSTATUS, &status);
                    printf("Status 0x%x\n", status);

                    if(!(status & LP_PBUSY))
                            printf("Busy \n");
                    else
                            printf("Not Busy\n");

                    if(status & LP_PACK)
                            printf("Ack high\n");
                    else
                            printf("Ack low\n");

                    if(status & LP_POUTPA)
                            printf("out of paper\n");
                    else
                            printf("Paper\n");

                    if(!(status & LP_PSELECD))
                            printf("Printer is offline\n");
                    else
                            printf("Printer is online\n");

                    if(!(status & LP_PERRORP))
                            printf("Error \n");
                    else
                            printf("No errors\n");

                    close(fd);
                    return status;
            }
    }

    This is not giving me the expected result.Status 0xde
    Not Busy
    Ack high
    Paper
    Printer is online
    No errors

    The printer info:
    HP LaserJet 6L .

    Any help would be appreciated,

    Regards,
    Archana
    The output is always



    -- 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 : Thu Nov 15 2001 - 05:36:54 EST