Re: FIX: color scanning problems with snapscans in sane 1.0.3

From: Lawrence Glaister (lg@jfm.bc.ca)
Date: Thu Sep 28 2000 - 17:34:52 PDT

  • Next message: kwlee: "SANE 2.0"

    Hi Richard,
    I have my code full of debug entries, so a patch is not is not too practical
    at
    this time. I have included the 2 routines you need to change... cut and
    paste should get you there. Sorry if my mailer trashed the formatting.

    /*
    * replace 2 routines in backend/snapscan-sources.c with
    * the following code. You can remove some of the debug code
    * if you like... it is still in use here.
    * Lawrence Glaister VE7IT lg@jfm.bc.ca
    */

    static SANE_Status
    FDSource_get (Source * pself, SANE_Byte * pbuf, SANE_Int * plen)
    {
       SANE_Status status = SANE_STATUS_GOOD;
       FDSource *ps = (FDSource *) pself;
       SANE_Int remaining = *plen;
       SANE_Int plen_in = *plen;

       while (remaining > 0
       && pself->remaining (pself) > 0 && status == SANE_STATUS_GOOD)
        {
           SANE_Int bytes_read = read(ps->fd, pbuf, remaining);
           if (bytes_read == -1)
      {
         if (errno == EAGAIN)
          {
             /* No data currently available */
          DBG (1, "FDSource_get EAGAIN break requested=%d
    remaining=%d\n",plen_in,remaining);
        usleep(10000); // give the usb driver a 10ms to get more data
        continue;
    /*============> break; ===replaced by 2 lines above*/
          }
         /* It's an IO error */
         DBG (1,
              "%s: read failed: %s\n", __FUNCTION__, strerror (errno));
         status = SANE_STATUS_IO_ERROR;
      }
           else if (bytes_read == 0)
      {
         break;
      }
           ps->pss->bytes_remaining -= bytes_read;
           remaining -= bytes_read;
           pbuf += bytes_read;
        }

       *plen -= remaining;

       DBG (1, "FDSource_get plen_in=%d plen_out=%d\n", plen_in,*plen);
       return status;
    }

    static SANE_Int
    RGBRouter_remaining (Source * pself)
    {
      RGBRouter *ps = (RGBRouter *) pself;
      static char me[] = "RGBRouter_remaining";
      SANE_Int remaining1 =
        (TxSource_remaining (pself) - ps->cb_size + ps->cb_line_size);
      SANE_Int remaining2 =
        (TxSource_remaining (pself) + ps->cb_line_size - ps->pos);
      SANE_Int remaining;

      if (ps->cb_start < 0)
        remaining = remaining1;
      else
        remaining = remaining2;

      DBG (1,
           "%s TxSource_remaining()= %d, pos= %d, cb_size =%d, cb_line_size=%d,
    cb_start=%d ch_offset[]=%d %d %d\n",
           me, TxSource_remaining (pself), ps->pos, ps->cb_size,
    ps->cb_line_size,
           ps->cb_start, ps->ch_offset[0], ps->ch_offset[1], ps->ch_offset[2]);

      DBG (1, "%s %d %d ret=%d\n", me, remaining1, remaining2, remaining);
      if ( remaining < 0 )
      {
        usleep(100000);
      remaining = 1;
      DBG(1,"%s, ERROR -- setting remaining to 1 to save our ass\n",me);
      }
      return remaining;
    }

    =======================================================
    Lawrence Glaister VE7IT email: lg@jfm.bc.ca
    1462 Madrona Drive http://jfm.bc.ca
    Nanoose Bay BC Canada
    V9P 9C9
    =======================================================
    ----- Original Message -----
    From: Richard B. Kreckel <kreckel@ginac.de>
    To: Lawrence Glaister <lg@jfm.bc.ca>
    Cc: <sane-devel@mostang.com>
    Sent: Thursday, September 28, 2000 10:53 AM
    Subject: Re: FIX: color scanning problems with snapscans in sane 1.0.3

    > On Thu, 28 Sep 2000, Lawrence Glaister wrote:
    > > thankyou for the feedback on the change.... I am surprised you see the
    same
    > > problems with the 1236s as I thought the problem was only related to usb
    > > connected scanners. I did end up removing the change below and modifying
    the
    > > code in two other places.
    > > In backend/snapscan-sources.c RGBRouter_remaining(), I added a check for
    > > a -ve return code and if negative, I returned 1. This is a really gross
    hack
    > > but was required to get my scanner working at 600dpi. I know the reason
    for
    > > the problem (scan would hang forever without moving the scanhead) and
    have
    > > discussed it with Steve Underwood, but have not come up with a cleaner
    fix
    > > yet. The second change was in backend/snapscan-sources.c FDSource_get().
    > > At the bottom of the if (errno==EAGAIN) code, remove the break and add 2
    > > lines: usleep(10000); and continue;
    > > This will clear up the problem that the resulted in corrupted color
    images
    > > or missing scanner data. You can return the code in RGBRouter_get() to
    > > normal as the problem is fixed by the EAGAIN patch above.
    > > I would like a little more feedback from snapscan users and some more
    > > testing by myself before proposing the fixes as patches.
    >
    > Err, can you send me a patch file? Can I get this from CVS? Or from
    > elsewhere? I am absolutely new to the sane code and the description above
    > is beyond me but I would be glad to help testing things. (Sorry for being
    > a bit dense...)
    >
    > Regards
    > -richy.
    > --
    > Richard Kreckel
    > <Richard.Kreckel@Uni-Mainz.DE>
    > <http://wwwthep.physik.uni-mainz.de/~kreckel/>
    >
    >
    >

    --
    Source code, list archive, and docs: http://www.mostang.com/sane/
    To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com
    



    This archive was generated by hypermail 2b29 : Thu Sep 28 2000 - 17:21:58 PDT