[PARPORT] problem accessing EPP in address mode for a custom device

From: Christophe DELAERE (delaere@fynu.ucl.ac.be)
Date: Mon Nov 26 2001 - 13:10:42 EST

  • Next message: Paul Brandariz x6546: "[PARPORT] HP 7200 and cdda2wav & cdrecord (1.9) Linux 7.1 2.4.9-12 kernel"

    Hi,

    I'm trying to access a custom device on the parallel port.
    This Data Acquisition card implement the EPP protocol and has been fully
    tested under win98 (yeah, I know...) .
    I already succeed accessing and using the card logged as root, accessing
    directly the registers base+3 and base+4 to read/write respectively in
    address and data mode from the port (after setting it to EPP).

    I now want to use parport to be more flexible and so on.
    I must precise that it is my firts attempt to use parport...

    Here is my problem:

    The first test code I've written (here after) doesn't succeed accessing
    the port in address mode.
    When I set the mode to EPP,
    The output of read/write is always -1, even for data.
    When I set the mode to EPPSWE,
    The output of read/write is always 0 . In data mode, it works fine (I
    see it on the device).

    I'm surprised the EPP mode doen't work, since it seems to be available
    when parport initialise.
    It is even listed in the /proc file with the available modes.

    Do I do sth wrong?

    Thanks a lot,
    Christophe Delaere.

    int main(int argc, char *argv[])
    {
    // initialisation
            int fd = open("/dev/parport0", O_RDWR);
            if (fd==-1)
                    {
                            perror ("open");
                            return 1;
                    }
            if (ioctl(fd, PPCLAIM))
                    {
                            perror("PPCLAIM");
                            close(fd);
                            return 1;
                    }
    // first transaction: reset and read the CSR
            int mode = IEEE1284_MODE_EPPSWE|IEEE1284_ADDR;
            if (ioctl(fd,PPSETMODE,&mode))
                    {
                            perror("PPSETMODE");
                            close(fd);
                            return 1;
                    }
            char reset = 6;
            char* resetbyte = &reset;
            char csr = 9;
            char* csrbyte = &csr;
            cout << "reset: " << write(fd, resetbyte, 1) << endl;
            cout << "send CSR address: " << write(fd, csrbyte,1)<< endl;
            mode = IEEE1284_MODE_EPPSWE|IEEE1284_DATA;
            cout << "start of procedure" << endl;
            if (ioctl(fd,PPSETMODE,&mode))
                    {
                            perror("PPSETMODE");
                            close(fd);
                            return 1;
                    }
            char internal = 0;
            char* internalbyte=&internal;
            cout << "send CSR " << write(fd,internalbyte,1)<< endl;
            mode = IEEE1284_MODE_EPPSWE|IEEE1284_ADDR;
            if (ioctl(fd,PPSETMODE,&mode))
                    {
                            perror("PPSETMODE");
                            close(fd);
                            return 1;
                    }
            cout << "send CSR address: " << write(fd, csrbyte,1)<< endl;
            mode = IEEE1284_MODE_EPPSWE|IEEE1284_DATA;
            if (ioctl(fd,PPSETMODE,&mode))
                    {
                            perror("PPSETMODE");
                            close(fd);
                            return 1;
                    }
            char buffer[10];
            cout << "read CSR contents: " << read(fd, buffer, 1)<< endl;
            cout << "CSR is : " << (unsigned int)buffer[0] << endl;
    // terminate
            if (ioctl(fd, PPRELEASE))
                    {
                            perror("PPRELEASE");
                            close(fd);
                            return 1;
                    }
            close(fd);

      return EXIT_SUCCESS;
    }

    --
    +-----------------------------------------------------------\|/---+
    | Christophe DELAERE            office: e253               !o o!  |
    | UCL - FYNU                    phone : 32-(0)10-473234    ! i !  |
    | chemin du cyclotron, 2        fax   : 32-(0)10-452183     `-'   |
    | 1348 Louvain-la-Neuve BELGIUM e-mail: delaere@fynu.ucl.ac.be    |
    +-----------------------------------------------------------------+
    

    -- 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 Nov 26 2001 - 13:17:02 EST