[sane-devel] Canon MX430 / MX510 / MX925 - does not recover when ADF out of paper

Rolf Bensch rolf at bensch-online.de
Thu Apr 3 18:47:29 UTC 2014


Hi All,

It seems that ADF out of paper issue is fixed now.

Please test attached final patch, which is based on latest git sources.

Please confirm that this patch fixes ADF out of paper issue for your
particular scanner.

I'll commit this patch and some document updates after your confirmation.

Many thanks for your help.

Cheers,
Rolf



Am 02.04.2014 20:54, schrieb Matthias Peter Walther:
> Hello Rolf,
> 
> here the requested logfile.
> 
> Bye
> Matthias
> 
> On 26.03.2014 17:22, Rolf Bensch wrote:
>> Hi Matthias,
>>
>> I prepared a patch for the "stopped the 2nd paper by hand" issue. The
>> patch is based on patch4.
>>
>> Please revert this patch: pixma_common.c.patch4. With this patch my
>> system has too fast timeouts, and without this patch the timeouts take 1
>> sec. Please try to fix this by yourself. On the other hand there are no
>> timeouts when everything is working as expected.
>>
>> Cheers,
>> Rolf
>>
>>
>> Am 23.03.2014 14:54, schrieb Matthias Peter Walther:
>>> Hello Rolf,
>>>
>>> I created three more logs.
>>>
>>> And the timeouts are not fixed. In fact it's gotten even worse,
>>> scanimage is captured in an (infinite(?)) loop of timeouts of which each
>>> loop takes several minuites. Watch log "3rd_try".
>>>
>>> Bye
>>> Matthias
>>>
>>> On 21.03.2014 18:21, Rolf Bensch wrote:
>>>> Hi Matthias,
>>>>
>>>> I need a new log file for this issue:
>>>>
>>>>>>> And in the debug level 11 Iog I stopped the 2nd paper by hand.
>>>>>>> Scanner and sane aborts. But after removing the paper and pressing
>>>>>>> ok on the device, nothing happens anymore.
>>>> and the 2nd patch is for this issue:
>>>>
>>>>>>> By the way. The timeouts in the sane logs are still rediculous.
>>>>>>> When it counts down, between each line it waits up the 40 seconds
>>>>>>> and not the amount of seconds it says in the log.
>>>> and please test normal ADF scanning again.
>>>>
>>>> Cheers,
>>>> Rolf
>>>>
>>>>
>>>> Am 21.03.2014 00:16, schrieb Matthias Peter Walther:
>>>>> Hello,
>>>>>
>>>>> I'm not sure if I did this right. I installed the two patches shipped
>>>>> with your last email and used this command:
>>>>>
>>>>> $ export SANE_DEBUG_PIXMA=11
>>>>> $ scanimage -x 100 -y 100 > test.png 2>
>>>>> Scanimage_Debug_11_patch1+2+3new+4+Pressed_cancel_after_device_started.txt
>>>>>
>>>>> After the scanner started, I pressed cancel on the device. Is this what
>>>>> you need?
>>>>>
>>>>> Bye
>>>>> Matthias
>>>>>
>>>>>
>>>>> Am 20.03.2014 18:05, schrieb Rolf Bensch:
>>>>>> Hi Matthias,
>>>>>>
>>>>>> Please don't mix different testings in one log file and at the same
>>>>>> time. Please keep them in mind and let us go step by step.
>>>>>>
>>>>>> I assume that "normal" ADF scanning works with new patch 3.
>>>>>>
>>>>>> Am 19.03.2014 19:46, schrieb Matthias Peter Walther:
>>>>>>> Standard debug level 4 scan, the last 1 mm is still missing. As this
>>>>>>> seems to be firmware related, I think sane won't be able to change this.
>>>>>>> The linux binary has the same problem. And I tested it in windows with
>>>>>>> IrfanView. The last mm is still missing under windows, too. I think this
>>>>>>> is a firmware issue?
>>>>>>>
>>>>>> I guess the ADF hardware needs the last 1mm for the paper detector.
>>>>>>
>>>>>>> Maybe you just set the maximum height of an adf page to that last line
>>>>>>> it scans. That is 870 pixels @75 dpi.
>>>>>>>
>>>>>> I won't do so. What's when you want to scan a 14" sheet or A5 format?
>>>>>> Please set the used paper size in the frontend. Then you can also crop
>>>>>> left and right ADF frame.
>>>>>>
>>>>>>> And in the debug level 11 Iog I stopped the 2nd paper by hand. Scanner
>>>>>>> and sane aborts. But after removing the paper and pressing ok on the
>>>>>>> device, nothing happens anymore.
>>>>>>>
>>>>>> I see this error in the log file: "cancelled by hardware". The problem
>>>>>> is that the scan process has not been closed and the scanner cannot be
>>>>>> initialised for a new scan session because the previous is still active
>>>>>> in the scanner.
>>>>>>
>>>>>> To fix this I need the exact position in the code where "cancelled by
>>>>>> hardware" is detected. Please create a new log file with usb messages
>>>>>> with attached patch "pixma_mp150.c.patch4".
>>>>>>
>>>>>> And please scan a small area @ 75 dpi, not a whole page. This reduces
>>>>>> log file size.
>>>>>>
>>>>>>> The same bug comes, if you interrupt the scan with ctrl + C (scanimage).
>>>>>>> The printer continues pulling pages, but does not recover after it has
>>>>>>> finished. That works correctly with the binary. If I recover the scanner
>>>>>>> with the binary driver, that requires up to three attempts. During the
>>>>>>> first and often the second, it searches the scanner for 2 minuites and
>>>>>>> aborts then. After that the second failure the scanner works prefectly
>>>>>>> again. Maybe it's just a timeout in the devices firmware?
>>>>>>>
>>>>>> I assume that this is the same problem as above.
>>>>>>
>>>>>>> By the way. The timeouts in the sane logs are still rediculous. When it
>>>>>>> counts down, between each line it waits up the 40 seconds and not the
>>>>>>> amount of seconds it says in the log.
>>>>>>>
>>>>>> Maybe "pixma_common.c.patch4" will fix this.
>>>>>>
>>>>>>> I had to zip the logs, cause they are larger than 100 KB and the mailing
>>>>>>> list server doesn't accept that.
>>>>>>>
>>>>>>> Last question: Is it possible to autodetect if adf has paper and
>>>>>>> autoswitch the input method? Some scanner are able to do that.
>>>>>>>
>>>>>> Please keep this in mind.
>>>>>>
>>>>>> Cheers,
>>>>>> Rolf
> 
-------------- next part --------------
--- ./pixma_mp150.c	2014-04-03 20:28:21.000000000 +0200
+++ ../sane-backends/backend/pixma_mp150.c	2014-04-03 20:36:51.000000000 +0200
@@ -284,6 +284,7 @@
   unsigned stripe_shift;
   uint8_t tpu_datalen;
   uint8_t tpu_data[0x40];
+  uint8_t adf_state;            /* handle adf scanning */
 } mp150_t;
 
 /*
@@ -454,6 +455,7 @@
 abort_session (pixma_t * s)
 {
   mp150_t *mp = (mp150_t *) s->subdriver;
+  mp->adf_state = state_idle;           /* reset adf scanning */
   return pixma_exec_short_cmd (s, &mp->cb, cmd_abort_session);
 }
 
@@ -1191,6 +1193,9 @@
   /* TPU info data setup */
   mp->tpu_datalen = 0;
 
+  /* adf scanning */
+  mp->adf_state = state_idle;
+
   if (mp->generation < 4)
     {
       query_status (s);
@@ -1269,23 +1274,8 @@
     
   /* Some exceptions here for particular devices */
   /* Those devices can scan up to 14" with ADF, but A4 11.7" in flatbed */
-  if (( s->cfg->pid == MX850_PID ||
-        s->cfg->pid == MX860_PID ||
-        s->cfg->pid == MX870_PID ||
-        s->cfg->pid == MX880_PID ||
-        s->cfg->pid == MX320_PID ||
-        s->cfg->pid == MX330_PID ||
-        s->cfg->pid == MX340_PID ||
-        s->cfg->pid == MX350_PID ||
-        s->cfg->pid == MX360_PID ||
-        s->cfg->pid == MX410_PID ||
-        s->cfg->pid == MX420_PID ||
-        s->cfg->pid == MX510_PID ||
-        s->cfg->pid == MX520_PID ||
-        s->cfg->pid == MX920_PID ||
-        s->cfg->pid == MX7600_PID )
-       &&
-        sp->source == PIXMA_SOURCE_FLATBED)
+  /* PIXMA_CAP_ADF also works for PIXMA_CAP_ADFDUP */
+  if ((s->cfg->cap & PIXMA_CAP_ADF) && sp->source == PIXMA_SOURCE_FLATBED)
     sp->h = MIN (sp->h, 877 * sp->xdpi / 75);
     
   if (sp->source == PIXMA_SOURCE_TPU)
@@ -1339,7 +1329,8 @@
     return PIXMA_EBUSY;
 
   /* Generation 4: send XML dialog */
-  if (mp->generation == 4 && s->param->adf_pageid == 0)
+  /* adf: first page or idle */
+  if (mp->generation == 4 && mp->adf_state == state_idle)
     {
       if (!send_xml_dialog (s, XML_START_1))
         return PIXMA_EPROTO;
@@ -1396,8 +1387,10 @@
     }
 
   tmo = 10;
-  if (s->param->adf_pageid == 0 || mp->generation <= 2)
-    {
+  /* adf: first page or idle */
+  if (mp->generation <= 2 || mp->adf_state == state_idle)
+    { /* single sheet or first sheet from ADF */
+      PDBG (pixma_dbg (4, "*mp150_scan***** start scanning *****\n"));
       error = start_session (s);
       while (error == PIXMA_EBUSY && --tmo >= 0)
         {
@@ -1438,7 +1431,11 @@
         error = send_set_tpu_info (s);
     }
   else   /* ADF pageid != 0 and gen3 or above */
+  { /* next sheet from ADF */
+    PDBG (pixma_dbg (4, "*mp150_scan***** scan next sheet from ADF  *****\n"));
     pixma_sleep (1000000);
+  }
+
 
   if ((error >= 0) || (mp->generation >= 3))
     mp->state = state_warmup;
@@ -1452,6 +1449,10 @@
       mp150_finish_scan (s);
       return error;
     }
+
+  /* ADF scanning active */
+  if (is_scanning_from_adf (s))
+    mp->adf_state = state_scanning;
   return 0;
 }
 
@@ -1485,9 +1486,13 @@
   do
     {
       if (s->cancel)
+      {
+        PDBG (pixma_dbg (4, "*mp150_fill_buffer***** s->cancel  *****\n"));
         return PIXMA_ECANCELED;
+      }
       if ((mp->last_block & 0x28) == 0x28)
-        {       /* end of image */
+        {  /* end of image */
+           PDBG (pixma_dbg (4, "*mp150_fill_buffer***** end of image  *****\n"));
            mp->state = state_finished;
            return 0;
         }
@@ -1496,6 +1501,8 @@
       error = read_image_block (s, header, mp->imgbuf + mp->data_left_len);
       if (error < 0)
         {
+          PDBG (pixma_dbg (4, "*mp150_fill_buffer***** scanner error (%d): end scan  *****\n", error));
+          mp->last_block = 0x38;        /* end scan in mp150_finish_scan() */
           if (error == PIXMA_ECANCELED)
             {
                /* NOTE: I see this in traffic logs but I don't know its meaning. */
@@ -1559,6 +1566,7 @@
        * abort_session and start_session between pages (last_block=0x28) */
       if (mp->generation <= 2 || !is_scanning_from_adf (s) || mp->last_block == 0x38)
         {
+          PDBG (pixma_dbg (4, "*mp150_finish_scan***** abort session  *****\n"));
           error = abort_session (s);  /* FIXME: it probably doesn't work in duplex mode! */
           if (error < 0)
             PDBG (pixma_dbg (1, "WARNING:abort_session() failed %d\n", error));
@@ -1570,6 +1578,9 @@
                 PDBG (pixma_dbg (1, "WARNING:XML_END dialog failed \n"));
             }
         }
+      else
+        PDBG (pixma_dbg (4, "*mp150_finish_scan***** wait for next page from ADF  *****\n"));
+
         mp->state = state_idle;
       /* fall through */
     case state_idle:
@@ -1659,8 +1670,8 @@
   DEVICE ("Canon PIXMA MP610", "MP610", MP610_PID, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS),
 
   DEVICE ("Canon PIXMA MX300", "MX300", MX300_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS),
-  DEVICE ("Canon PIXMA MX310", "MX310", MX310_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
-  DEVICE ("Canon PIXMA MX700", "MX700", MX700_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
+  DEVICE ("Canon PIXMA MX310", "MX310", MX310_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
+  DEVICE ("Canon PIXMA MX700", "MX700", MX700_PID, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
   DEVICE ("Canon PIXMA MX850", "MX850", MX850_PID, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),
   DEVICE ("Canon PIXMA MX7600", "MX7600", MX7600_PID, 4800, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),
 
@@ -1689,7 +1700,7 @@
   DEVICE ("Canon PIXMA MX360", "MX360", MX360_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
   DEVICE ("Canon PIXMA MX410", "MX410", MX410_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
   DEVICE ("Canon PIXMA MX420", "MX420", MX420_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
-  DEVICE ("Canon PIXMA MX880 Series", "MX880", MX880_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),
+  DEVICE ("Canon PIXMA MX880 Series", "MX880", MX880_PID, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),
 
   /* Generation 4: CIS */
   DEVICE ("Canon PIXMA MP640", "MP640", MP640_PID, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS),
@@ -1716,27 +1727,27 @@
   DEVICE ("Canon PIXMA E500",   "E500",   E500_PID,   1200, 0, 0, 638, 877, PIXMA_CAP_CIS),
 
   /* Latest devices (2012) Generation 4 CIS */
-  DEVICE ("Canon PIXMA MX370 Series", "MX370", MX370_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
-  DEVICE ("Canon PIXMA MX430 Series", "MX430", MX430_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
+  DEVICE ("Canon PIXMA MX370 Series", "MX370", MX370_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
+  DEVICE ("Canon PIXMA MX430 Series", "MX430", MX430_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
   DEVICE ("Canon PIXMA MX510 Series", "MX510", MX510_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
-  DEVICE ("Canon PIXMA MX710 Series", "MX710", MX710_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),
-  DEVICE ("Canon PIXMA MX890 Series", "MX890", MX890_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),
-  DEVICE ("Canon PIXMA E600 Series",  "E600",  E600_PID,  1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
+  DEVICE ("Canon PIXMA MX710 Series", "MX710", MX710_PID, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),
+  DEVICE ("Canon PIXMA MX890 Series", "MX890", MX890_PID, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),
+  DEVICE ("Canon PIXMA E600 Series",  "E600",  E600_PID,  1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
   DEVICE ("Canon PIXMA MG4200", "MG4200", MG4200_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS),
 
   /* Latest devices (2013) Generation 4 CIS */
   DEVICE ("Canon PIXMA E510",  "E510",  E510_PID,  1200, 0, 0, 638, 877, PIXMA_CAP_CIS),
-  DEVICE ("Canon PIXMA E610",  "E610",  E610_PID,  1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
+  DEVICE ("Canon PIXMA E610",  "E610",  E610_PID,  1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
   DEVICE ("Canon PIXMA MP230", "MP230", MP230_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS),
   DEVICE ("Canon PIXMA MG2200 Series", "MG2200", MG2200_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS),
   DEVICE ("Canon PIXMA MG3200 Series", "MG3200", MG3200_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS),
   DEVICE ("Canon PIXMA MG5400 Series", "MG5400", MG5400_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS),
   DEVICE ("Canon PIXMA MG6300 Series", "MG6300", MG6300_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS),
-  DEVICE ("Canon PIXMA MX390 Series", "MX390", MX390_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
-  DEVICE ("Canon PIXMA MX450 Series", "MX450", MX450_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
+  DEVICE ("Canon PIXMA MX390 Series", "MX390", MX390_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
+  DEVICE ("Canon PIXMA MX450 Series", "MX450", MX450_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
   DEVICE ("Canon PIXMA MX520 Series", "MX520", MX520_PID, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
-  DEVICE ("Canon PIXMA MX720 Series", "MX720", MX720_PID, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
-  DEVICE ("Canon PIXMA MX920 Series", "MX920", MX920_PID, 2400, 0, 600, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),
+  DEVICE ("Canon PIXMA MX720 Series", "MX720", MX720_PID, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF),
+  DEVICE ("Canon PIXMA MX920 Series", "MX920", MX920_PID, 2400, 0, 600, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),
   DEVICE ("Canon PIXMA MG2400 Series", "MG2400", MG2400_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS),
   DEVICE ("Canon PIXMA MG2500 Series", "MG2500", MG2500_PID, 600, 0, 0, 638, 877, PIXMA_CAP_CIS),
   DEVICE ("Canon PIXMA MG3500 Series", "MG3500", MG3500_PID, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS),


More information about the sane-devel mailing list