[PARPORT] EPP and ECP mode programming

From: Syed, Hassan (ETD) (Hassan.Syed@compaq.com)
Date: Thu May 24 2001 - 16:54:37 EDT

  • Next message: Jes?s Miguel Torres Jorge: "[PARPORT] Low ECP speed"

    Hi,

    I wanted to write to a certain channel address in ECP and
    EPP mode. Here is what I wrote. Needless to say, it doesn't
    work. Would appreciate your help in figuring out where I went
    wrong.

    regards,
    Hassan

    char WriteAddr[10];
    char ReadAddr[10];
    unsigned char SendBuffer[100];
    unsigned char RecvBuffer[100];

       mode = IEEE1284_MODE_ECP | IEEE1284_ADDR;
       if (ioctl (fd, PPNEGOT, &mode)) {
          return 1;
       }

       // Writing to channel address 7. There can be 128 channel
       // addresses
       strcpy (WriteAddr, "7")
       strcpy (ReadAddr, "255");

       Result = write (fd, WriteAddr, 3);
       if (Result == -1)
          return 1;
       
    // THE FOLLOWING READ FAILS. THE VALUE Result IS 1 AND
    // ReadAddr DOES NOT MATCH WHAT I WROTE (WriteAddr)
       Result = read (fd, ReadAddr, 3);
       if (Result == -1) {
          return 1;
       }

       if (strncmp (WriteAddr, ReadAddr, 3))
       {
          return 1;
       }

       // Now to write data to the channel address, negotiate
       // to ECP again but without the IEEE1284_ADDR flag
       mode = IEEE1284_MODE_ECP;
       if (ioctl (fd, PPNEGOT, &mode)) {
          return 1;
       }

       Result = write (fd, SendBuffer, size);
       if (Result != size) {
          return 1;
       }
       
       Result = read (fd, RecvBuffer, size);
       if (Result == -1) {
          return 1;
       }

    -- 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 May 24 2001 - 16:57:23 EDT