[PARPORT] can't read EPP data

From: Scholz Maik (K7/EEM15) * (Maik.Scholz@de.bosch.com)
Date: Wed Jun 28 2000 - 03:25:23 EDT

  • Next message: Tim Waugh: "Re: [PARPORT] Problems with COMPAQ-Presario 5536 and Brother HL 760"

    Hi,
    has anybody some ideas why the following program
    dosn't work?

    System:
    * linux 2.2.14 with epp patch.
    * EPP is supportted "/proc/parport/..."

    Problem:
    If i start the program, it dosn't read in data from
    out EPP hardware (timeout). Under Windows
    everything is ok.

    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/ioctl.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <linux/ppdev.h>
    #include <sys/time.h>
    #include <signal.h> /* sigemptyset */ /* us_sleep() */

    void epp_sig_io_handler(int signo)
    {
      printf("sig\n");
    }

    int main(int argc, char* argv[])
    {
      if(argc != 3)
        {
          printf("uase: eppread /dev/parport0 40000\n");
        }
      else
        {
          printf("eppread ...\n");
          {
            int fd;
            int mode;
            /*
             * open ...
             */
            fd = open(argv[1], O_RDWR);
            if(fd == -1)
              {
                perror("open");
                return 1;
              }
            /*
             * PPCLAIM ...
             */
            if(ioctl(fd,PPCLAIM))
              {
                perror("PPCLAIM");
                close(fd);
                return 1;
              }
            /*
             * PPSETMODE ...
             */
            mode = IEEE1284_MODE_EPP;
            if(ioctl (fd, PPSETMODE, &mode))
              {
                perror("PPSETMODE");
                close(fd);
                return 1;
              }
            /*
             * PPNEGOT ...
             */
            mode = IEEE1284_MODE_EPP;
            if(ioctl (fd, PPNEGOT, &mode))
              {
                perror("PPNEGOT");
                close(fd);
                return 1;
              }
            /*
             * read ...
             */
            while(1)
              {
                fd_set rset;
                int ret;
                struct timeval tv;
                
                FD_ZERO(&rset);
                FD_SET(fd, &rset);
                
                tv.tv_sec = 5;
                tv.tv_usec = 0;
                
                if(!select(fd+1, &rset, NULL, NULL, &tv))
                  {
                    printf("timeout\n");
                    break;
                  }
                
                {
                  unsigned char b;
                  if(read(fd,&b,1) > 0)
                    {
                      printf("read: %02x\n",b);
                    }
                }
              }
            /*
             * PPRELEASE ...
             */
            if(ioctl(fd,PPRELEASE,NULL))
              {
                perror("PPRELEASE");
                close(fd);
                return 1;
              }
            close(fd);
          }
          printf("eppread ... done\n");
        }
    }

    -- 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 : Wed Jun 28 2000 - 03:30:34 EDT