Re: [sane-devel] Canon MP250, pixma backend

2015-12-04 Thread Rolf Bensch
Hi Andrey,

Your patch ist the right way to handle this issue.

Please open a bug report. I have no time for any support now and I don't
want to forget this issue.

Many thanks for your report and your help.

Cheers,
Rolf

Am 26.11.2015 um 09:22 schrieb Andrey Kovalev:
> Hi!
>
> I'm trying to run Canon MP250 scanner.
>
> It worked with sane-backend 1.0.23, and is broken since 1.0.24.
>
> I took sane from git. Below I attached a part of sane log. I added
> several "here we are" lines to see source file name and line of code.
>
> Problems started after "sane_control_option(handle=0x8080c00,option=17"
>
> option=17 is opt_button_1.
>
> In 1.0.24 these lines were added to pixma.c control_option() function:
>
> +  case opt_button_1:
> +  case opt_button_2:
> +  case opt_original:
> +  case opt_target:
> +  case opt_scan_resolution:
> +/* poll scanner if option is not cached */
> +if (! ss->button_option_is_cached[ BUTTON_GROUP_INDEX(n) ] )
> +  update_button_state (ss, info);
> +/* mark this option as read */
> +ss->button_option_is_cached[  BUTTON_GROUP_INDEX(n) ] = 0;
>
>
> control_option() form pixma.c call update_button_state(),
> then pixma_wait_event(),
> mp150_wait_event(),
> handle_interrupt() from pixma_mp150.c,
> send_time().
>
> Send a few bytes over USB and wait for device respond.
>
> Device never responds.
>
> If I comment out all these lines marked with '+' in pixma.c
> control_option() function my MP250 works.
>
>
>
>
> On the other hand with this patch to sane git and without any other
> changes:
>
>
> diff --git a/backend/pixma_mp150.c b/backend/pixma_mp150.c
> index 4f8b232..7ab9e0f 100644
> --- a/backend/pixma_mp150.c
> +++ b/backend/pixma_mp150.c
> @@ -967,8 +967,11 @@ handle_interrupt (pixma_t * s, int timeout)
> * target in buf[1] */
>{
>  /* More than one event can be reported at the same time. */
> -if (buf[3] & 1)
> -  send_time (s);
> +if (s->cfg->pid != MP250_PID)
> +{
> +  if (buf[3] & 1)
> +send_time (s);
> +}
>  if (buf[9] & 2)
>query_status (s);
>  if (buf[0] & 2)
>
>
>
> my MP250 works too.
>
>
> In pixma_mp810.c there is a comment:
>
> /* FIXME: some scanners hang here */
>
> near send_time() call. Perhaps, MP250 doesn't need send_time()?
>
>
>
> 
> [bjnp] sanei_bjnp_find_devices, pixma backend version: 0.17.24
> [bjnp] sanei_bjnp_find_devices: No devices specified in configuration
> file.
> [bjnp] sanei_bjnp_find_devices: Added all configured scanners, now do
> auto detection...
> [bjnp] prepare_socket: lo is not a valid IPv4 interface, skipping...
> [bjnp] prepare_socket: eth0 is IPv4 capable, sending broadcast, socket
> = 13
> [bjnp] sanei_find_devices: scanner discovery finished...
> [pixma] pixma_open(): Canon PIXMA MP250
> [sanei_usb] sanei_usb_open: trying to open device `libusb:001:002'
> [sanei_usb] sanei_usb_open: configuration nr: 0
> [sanei_usb] sanei_usb_open: interface nr: 0
> [sanei_usb] sanei_usb_open:   alt_setting nr: 0
> [sanei_usb] sanei_usb_open: endpoint nr: 0
> [sanei_usb] sanei_usb_open: direction: 0
> [sanei_usb] sanei_usb_open: address: 7 transfertype: 2
> [sanei_usb] sanei_usb_open: found bulk-out endpoint (address 0x07)
> [sanei_usb] sanei_usb_open: we already have a bulk-out endpoint
> (address: 0x07), ignoring the new one
> [sanei_usb] sanei_usb_open: endpoint nr: 1
> [sanei_usb] sanei_usb_open: direction: 128
> [sanei_usb] sanei_usb_open: address: 8 transfertype: 2
> [sanei_usb] sanei_usb_open: found bulk-in endpoint (address 0x08)
> [sanei_usb] sanei_usb_open: we already have a bulk-in endpoint
> (address: 0x88), ignoring the new one
> [sanei_usb] sanei_usb_open: endpoint nr: 2
> [sanei_usb] sanei_usb_open: direction: 128
> [sanei_usb] sanei_usb_open: address: 9 transfertype: 3
> [sanei_usb] sanei_usb_open: found interrupt-in endpoint (address 0x09)
> [sanei_usb] sanei_usb_open: we already have a int-in endpoint
> (address: 0x89), ignoring the new one
> [sanei_usb] sanei_usb_open: configuration nr: 0
> [sanei_usb] sanei_usb_open: interface nr: 1
> [sanei_usb] sanei_usb_open:   alt_setting nr: 0
> [sanei_usb] sanei_usb_open: interface 1 not detected as a scanner by
> sanei_usb_init, ignoring.
> [sanei_usb] sanei_usb_open: opened usb device `libusb:001:002' (*dn=0)
> [pixma] *mp150_open* This is a generation 4 scanner.  *
> [pixma] here we are pixma_mp150.c 1231
> [pixma] here we are pixma_mp150.c 1240
> [dll] sane_open: open successful
> [sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be
> flush()
> [sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be
> flush()
> [sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be
> flush()
> [dll] sane_get_parameters(handle=0x8080c00,params=0xbfd71cb4)
> [sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be
> flush()
> [sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be
> 

[sane-devel] Canon MP250, pixma backend

2015-11-26 Thread Andrey Kovalev

Hi!

I'm trying to run Canon MP250 scanner.

It worked with sane-backend 1.0.23, and is broken since 1.0.24.

I took sane from git. Below I attached a part of sane log. I added 
several "here we are" lines to see source file name and line of code.


Problems started after "sane_control_option(handle=0x8080c00,option=17"

option=17 is opt_button_1.

In 1.0.24 these lines were added to pixma.c control_option() function:

+  case opt_button_1:
+  case opt_button_2:
+  case opt_original:
+  case opt_target:
+  case opt_scan_resolution:
+/* poll scanner if option is not cached */
+if (! ss->button_option_is_cached[ BUTTON_GROUP_INDEX(n) ] )
+  update_button_state (ss, info);
+/* mark this option as read */
+ss->button_option_is_cached[  BUTTON_GROUP_INDEX(n) ] = 0;


control_option() form pixma.c call update_button_state(),
then pixma_wait_event(),
mp150_wait_event(),
handle_interrupt() from pixma_mp150.c,
send_time().

Send a few bytes over USB and wait for device respond.

Device never responds.

If I comment out all these lines marked with '+' in pixma.c 
control_option() function my MP250 works.





On the other hand with this patch to sane git and without any other changes:


diff --git a/backend/pixma_mp150.c b/backend/pixma_mp150.c
index 4f8b232..7ab9e0f 100644
--- a/backend/pixma_mp150.c
+++ b/backend/pixma_mp150.c
@@ -967,8 +967,11 @@ handle_interrupt (pixma_t * s, int timeout)
* target in buf[1] */
   {
 /* More than one event can be reported at the same time. */
-if (buf[3] & 1)
-  send_time (s);
+if (s->cfg->pid != MP250_PID)
+{
+  if (buf[3] & 1)
+send_time (s);
+}
 if (buf[9] & 2)
   query_status (s);
 if (buf[0] & 2)



my MP250 works too.


In pixma_mp810.c there is a comment:

/* FIXME: some scanners hang here */

near send_time() call. Perhaps, MP250 doesn't need send_time()?




[bjnp] sanei_bjnp_find_devices, pixma backend version: 0.17.24
[bjnp] sanei_bjnp_find_devices: No devices specified in configuration file.
[bjnp] sanei_bjnp_find_devices: Added all configured scanners, now do 
auto detection...

[bjnp] prepare_socket: lo is not a valid IPv4 interface, skipping...
[bjnp] prepare_socket: eth0 is IPv4 capable, sending broadcast, socket = 13
[bjnp] sanei_find_devices: scanner discovery finished...
[pixma] pixma_open(): Canon PIXMA MP250
[sanei_usb] sanei_usb_open: trying to open device `libusb:001:002'
[sanei_usb] sanei_usb_open: configuration nr: 0
[sanei_usb] sanei_usb_open: interface nr: 0
[sanei_usb] sanei_usb_open:   alt_setting nr: 0
[sanei_usb] sanei_usb_open: endpoint nr: 0
[sanei_usb] sanei_usb_open: direction: 0
[sanei_usb] sanei_usb_open: address: 7 transfertype: 2
[sanei_usb] sanei_usb_open: found bulk-out endpoint (address 0x07)
[sanei_usb] sanei_usb_open: we already have a bulk-out endpoint 
(address: 0x07), ignoring the new one

[sanei_usb] sanei_usb_open: endpoint nr: 1
[sanei_usb] sanei_usb_open: direction: 128
[sanei_usb] sanei_usb_open: address: 8 transfertype: 2
[sanei_usb] sanei_usb_open: found bulk-in endpoint (address 0x08)
[sanei_usb] sanei_usb_open: we already have a bulk-in endpoint (address: 
0x88), ignoring the new one

[sanei_usb] sanei_usb_open: endpoint nr: 2
[sanei_usb] sanei_usb_open: direction: 128
[sanei_usb] sanei_usb_open: address: 9 transfertype: 3
[sanei_usb] sanei_usb_open: found interrupt-in endpoint (address 0x09)
[sanei_usb] sanei_usb_open: we already have a int-in endpoint (address: 
0x89), ignoring the new one

[sanei_usb] sanei_usb_open: configuration nr: 0
[sanei_usb] sanei_usb_open: interface nr: 1
[sanei_usb] sanei_usb_open:   alt_setting nr: 0
[sanei_usb] sanei_usb_open: interface 1 not detected as a scanner by 
sanei_usb_init, ignoring.

[sanei_usb] sanei_usb_open: opened usb device `libusb:001:002' (*dn=0)
[pixma] *mp150_open* This is a generation 4 scanner.  *
[pixma] here we are pixma_mp150.c 1231
[pixma] here we are pixma_mp150.c 1240
[dll] sane_open: open successful
[sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be flush()
[sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be flush()
[sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be flush()
[dll] sane_get_parameters(handle=0x8080c00,params=0xbfd71cb4)
[sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be flush()
[sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be flush()
[sanei_wire] sanei_w_space: bigger than buffer (8192 bytes), may be flush()
[dll] 
sane_control_option(handle=0x8080c00,option=0,action=0,value=0xbfd71cb0,info=(nil))

[dll] sane_get_option_descriptor(handle=0x8080c00,option=0)
[dll] sane_get_option_descriptor(handle=0x8080c00,option=1)
[dll] sane_get_option_descriptor(handle=0x8080c00,option=2)
[dll] sane_get_option_descriptor(handle=0x8080c00,option=3)
[dll] sane_get_option_descriptor(handle=0x8080c00,option=4)
[dll]