Re: [PARPORT] Reading from pin - help.

From: Nate (nate@uniwest.com)
Date: Thu Dec 19 2002 - 19:45:14 EST

  • Next message: Nate: "Re: [PARPORT] Reading from pin - help."

    adding to what "Uwe Bonnes" stated earlier, plus a little more...

    ///////////////////////////////////////////////////////////////
    // this assumes you have the appropriate parport modules loaded

    unsigned char ucStatus = 0;
    int nFD = -1;
    int nError = 0;

    nFD = open( "/dev/parport0", O_RDWR );
    if( nFD>0 )
    {
        nError = ioctl(nFD, PPCLAIM, 0 );
        if( !nError )
            nError = ioctl(nFD, PPRSTATUS, &ucStatus );
        if( !nError )
        {
            if( ucStatus & 0x40 ) // is the bit a 1?
                printf( "nAck or S6 or Pin 10 is 1\n " );
            else
                printf( "nAck or S6 or Pin 10 is 0\n " );
        }
        close( nFD );
    }

    ///////////////////////////////////////////////////////////////

    Other good references

    http://www.doc.ic.ac.uk/~ih/doc/par
    http://www.beyondlogic.org/spp/parallel.htm
    http://www.lvr.com/files/pppinout.pdf

    Nate

    ----- Original Message -----
    From: "Pawel Stochlinski" <int01h@sentinel.mj12.eu.org>
    Cc: <linux-parport@torque.net>
    Sent: Thursday, December 19, 2002 2:53 PM
    Subject: Re: [PARPORT] Reading from pin - help.

    > ----- Original Message -----
    > From: "Uwe Bonnes" <bon@elektron.ikp.physik.tu-darmstadt.de>
    > To: "Pawel Stochlinski" <int01h@sentinel.mj12.eu.org>
    > Cc: <linux-parport@torque.net>
    > Sent: Wednesday, December 18, 2002 10:14 PM
    > Subject: Re: [PARPORT] Reading from pin - help.
    >
    >
    > > >>>>> "Pawel" == Pawel Stochlinski <int01h@sentinel.mj12.eu.org> writes:
    > >
    > > Pawel> Please help me - i have a problem with reading a data from
    pin
    > > Pawel> #10 on LPT (its an ACK), what should i write in code, to read
    > it?
    > > Pawel> I am using x=inb(STATUSPORT); but that is not correct,
    please,
    > > Pawel> help me how to read from pin 10...
    > >
    > > Do something like
    > >
    > > int re;
    > >
    > > fd = open(portname,O_RDWR);
    > >
    > > ioctl(fd,PPRSTATUS,&res);
    > >
    > > Bye
    > > --
    > > Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de
    > >
    > > Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
    > > --------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
    > >
    > > -- To unsubscribe, send mail to: linux-parport-request@torque.net --
    > > -- with the single word "unsubscribe" in the body of the message. --
    >
    > Yep, but when i read from file descriptor the soft is 'blocked' waiting
    for
    > data.
    >
    > Isnt there anything easier? I just want to read from some pin a data,
    > not\hing more.
    >
    > Thanks
    >
    >
    > -- 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 : Thu Dec 19 2002 - 19:49:57 EST