[sane-devel] New hardware report, patches: Canon PIXMA MX920/MX922, pixma_mp150.c

Rolf Bensch rolf at bensch-online.de
Fri Nov 8 21:38:55 UTC 2013


Am 06.11.2013 02:50, schrieb human2013odd at icebubble.org:
> Rolf Bensch <rolf at bensch-online.de> writes:
> 
>> Please check scanner's raw data with this patch:
> 
> <snip />
> 
> With that patch applied, the raw data exhibits the same color shifting.
> See attached PNM.
> 

Please check color shifting for all resolutions. By now the scanners
don't need any color shifting @ 75dpi. It seems that your scanner needs
different color shift handling.

>> There is a well known bug for ADF scans. If you like I can send you some
>> test code so that we can fix this issue. I have no ADF scanner to test
>> this by myself.
> 
> Sure, I'd be happy to test it.
>

I attached patch files for pixma.c and for pixma_mp150.c.

The problem seems to be inside pixma.c or pixma_common.c. Pixma backend
uses two independent processes for scanner control:
(1) send scan parameters and start / stop around reader_loop() in
pixma.c and pixma_common.c which call functions in pixma_mp150.c.
(2) read image data using sane_read() in pixma.c.

Until last summer pthread support was disabled by default. This avoided
data exchange between both processes. Now we have 2 threads which can
use e.g. the struct ss for data exchange.

You can see functional behaviour with enabled debug messages: 'export
SANE_DEBUG_PIXMA=4'. You can use macro PDBG (pixma_dbg (4, ...)) to add
additional debug info.

After the last page the scanner is programmed to scan an empty page and
detect paper empty.

At the first page the scanner is initialised with start_session(s) and
after the last page the scanner is closed with abort_session(s), both in
pixma_mp150.c. Between scanning single pages the scanner stays idle. You
can find all scanner related functions in pixma_mp150.c.

An interesting value is the no. of scanned ADF pages which is controlled
with the parameters sp->adf_pageid or s->param->adf_pageid and
ss->page_count.

>> Your scanner should also button controlled. Please test this patch:
> 
> <snip />
> 
> With that patch applied, the button status is correctly reflected by
> "scanimage -A", and the buttons can be used in --button-controlled=yes
> mode.  However, button control is buggy:
> 
>  1. If you press Gray to cancel, scanimage exits as expected, but the
>     scanner sits there (waiting for something) and can't be used.  After
>     about 30 seconds, it times out, and the scanner can be used again.
> 
>  2. If you press one of the buttons before scanimage has a chance to
>     poll button status, the scanner does the same thing (just wait).
>     After the scanner times out and comes back to reality, a subsequent
>     button press is received and processed by scanimage correctly.
> 

Please check if you can see any differences in the USB protocols in both
cases. You can enable debug output for USB protocols with 'export
SANE_DEBUG_PIXMA=11'.

I'm using scanbd for button controlled scanning. I attached my config files.

Cheers,
Rolf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pixma.c.patch
Type: text/x-patch
Size: 415 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/sane-devel/attachments/20131108/9477e033/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pixma_mp150.c.patch
Type: text/x-patch
Size: 2774 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/sane-devel/attachments/20131108/9477e033/attachment-0004.bin>
-------------- next part --------------
/*
 * $Id: scanbd.conf 157 2013-01-06 07:42:46Z wimalopaan $
 *
 *  scanbd - KMUX scanner button daemon
 *
 *  Copyright (C) 2008 - 2013  Wilhelm Meier (wilhelm.meier at fh-kl.de)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */


# global settings
global {
        # turn on debugging
        
        # log to console
        debug   = true 

        # debug logging
        # 1=error, 2=warn, 3=info, 4-7=debug
        debug-level = 0
        
        # drop priviliges to this user
        #=============================
        # Linux: 
        # user    = saned # root
        # *BSD
        # user    = root
        user    = saned

        # Group to be used
        #=================
        # Linux (most distributions use the lp group to access scanners)
        # group   = lp
        # ArchLinux (ArchLinux uses the scanner group)
        # group = scanner
        #
        # *BSD (no group lp here, use daemon instead)
        # group   = daemon # root
        #
        group   = lp

        # the saned executable for manager-mode
        saned   = "/usr/sbin/saned"
        saned_opt  = {} # string-list
        saned_env  = { "SANE_CONFIG_DIR=/usr/local/etc/scanbd" } # list of environment vars for saned

        # Scriptdir specifies where scanbs normally looks for scripts.
        # The scriptdir option can be defined as: 
        #   - a path relative to the configuations (<path>/etc/scanbd) directory
        #   - an abosolute path
        # Examples:
        # scriptdir = scripts 
        # sets scriptdir to <path>/etc/scripts.
        # scriptdir = /some/path
        # sets scriptdir to the specified absolute path
        # Default scriptdir is <path>/etc/scanbd, this is normally appropriate
        # scriptdir = 
        
        # scanbuttond_backends_dir sets the path where scanbd looks for the scanbuttond backends 
	# It can be defined as relative path, starting from the scanbd config directory or
        # as an absolute path
        # Default is <libdir>/scanbd/scanbutond/backends
        # Example
	# scanbuttond_backends_dir = "/usr/local/lib/scanbd/scanbuttond/backends"

        # poll timeout in [ms]
        # (for polling the devices)
        timeout = 500 
        
        pidfile = "/var/run/scanbd.pid"
        
        # env-vars for the scripts
        environment {
                # pass the device label as below in this env-var
                device = "SCANBD_DEVICE"
                # pass the action label as below in this env-var
                action = "SCANBD_ACTION"
        }

        # function definitions
        # values of the options are simply passed via env-vars

        function function_knob {
                filter = "^message.*"
                desc   = "The value of the function knob / wheel / selector"
                env    = "SCANBD_FUNCTION" 
        }
        function function_mode {
                filter = "^mode.*"
                desc   = "Color mode"
                env    = "SCANBD_FUNCTION_MODE" 
        }

        multiple_actions = true # allow multiple actions per option (up to the total amount of options)

        # action definitions
        # if the filter matches and the value changes 
        # from from-value to to-value,
        # <script> is executed
        # <script> is the full pathname (do not include any parameters)
        # if parameters are needed, write a script
        
        # since we can have only a most one action for each option, the action-script 
        # can use the function definition (see above) to distinguish different tasks 
        # (e.g. use the env-var SCANBD_FUNCTION defined above)
        
        action scan {
                filter = "^scan.*"
                numerical-trigger {
                        from-value = 1
                        to-value   = 0
                }
                desc   = "Scan to file"
                # script must be an relative path starting from scriptdir (see above), 
                # or an absolute pathname. 
                # It must contain the path to the action script without arguments
                # Absolute path example: script = "/some/path/foo.script 
                script = "test.script"
        }
        action email {
                filter = "^email$"
                string-trigger {
                        from-value  = ""        
                        to-value    = "^email.*"
                }
                desc   = "Scan to email"
                # script must be an relative path starting from scriptdir (see above), 
                # or an absolute pathname. 
                # It must contain the path to the action script without arguments
                # Absolute path example: script = "/some/path/foo.script 
                script = "test.script"
        }
        action copy {
                filter = "^copy$"
                string-trigger {
                        from-value  = ""
                        to-value    = "^copy.*"
                }
                desc   = "Copy to printer"
                # script must be an relative path starting from scriptdir (see above), 
                # or an absolute pathname. 
                # It must contain the path to the action script without arguments
                # Absolute path example: script = "/some/path/foo.script 
                script = "test.script"
        }
        action preview {
                filter = "^preview$"
                numerical-trigger {
                        from-value = 1
                        to-value   = 0
                }
                desc   = "Preview"
                # script must be an relative path starting from scriptdir (see above), 
                # or an absolute pathname. 
                # It must contain the path to the action script without arguments
                # Absolute path example: script = "/some/path/foo.script 
                script = "test.script"
        }
        action globaltest {
                filter = "^message.*"
#                filter = "^button.*"
                desc   = "Test (print all env vars)"
                # script must be an relative path starting from scriptdir (see above), 
                # or an absolute pathname. 
                # It must contain the path to the action script without arguments
                # Absolute path example: script = "/some/path/foo.script 
                script = "test.script"
        }
}

# include
# include another file at this point. This may only occur outside general and devices blocks
# an include statement may be relative (to the direcory where scanbd.conf is located or aboslute
# include("scanner.d/myscanner.conf")
# include("/my/long/path/myscanner.conf")

# devices 
# each device can have actions and functions, you can disable not relevant devices
#include(scanner.d/avision.conf)
#include(scanner.d/fujitsu.conf)
#include(scanner.d/hp.conf)
include(scanner.d/pixma.conf)
#include(scanner.d/snapscan.conf)
-------------- next part --------------
/*
 * $Id: cs9000f.conf 157 2013-01-06 07:42:46Z wimalopaan $
 *
 *  scanbd - KMUX scanner button daemon
 *
 *  Copyright (C) 2008 - 2013  Wilhelm Meier (wilhelm.meier at fh-kl.de)
 *  Copyright (C) 2013  Rolf Bensch <rolf at bensch hyphen online dot de>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

device pixma {
       # the device matching string
       filter = "^pixma.*"

       # the device description
       desc = "Canon Scanner Device"

       function original {
                filter = "^original.*"
                desc   = "Type of original"
                env    = "SCANBD_ORIGINAL"
		# Values (size -> multi function devices):
		# 0 = not used
		# 1 = A4
		# 2 = Letter
		# 8 = 10x15
		# 9 = 13x18
		# b = auto
       }
       function target {
                filter = "^target.*"
                desc   = "Target of the operation"
                env    = "SCANBD_TARGET"
		# Values (buttons -> CanoScan devices):
		# 1 = Auto Scan
		# 2 = PDF Color
		# 3 = PDF Gray
		# 4 = PDF User
		# 5 = PDF End
		# 6 = Copy
		# 7 = Email
		# Values (format -> multi function devices):
		# 1 = JPEG
		# 2 = TIFF
		# 3 = PDF
		# 4 = compact-PDF
       }
       function scan-resolution {
                filter = "^scan-resolution.*"
                desc   = "Scan resolution"
                env    = "SCANBD_SCAN_RESOLUTION"
		# Values (scan-resolution -> multi function devices):
		# 0 = not used
		# 1 =  75 dpi
		# 2 = 150 dpi
		# 3 = 300 dpi
		# 4 = 600 dpi
       }

       # device specific actions (as above)
       # (if this matches a previous defined action, it overrides)
       action push_button {
              filter = "^button.*"
              numerical-trigger {
                        from-value = 0
                        to-value   = 1
              }
              desc   = "Button pushed"

              # script must be an absolute pathname to the action script without arguments
              script = "/usr/local/etc/scanbd/scanner.d/pixma.sh"
       }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pixma.sh
Type: application/x-shellscript
Size: 5462 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/sane-devel/attachments/20131108/9477e033/attachment-0005.bin>


More information about the sane-devel mailing list