Making Sane Work for DS-620

I recently purchaset a Brother DS-620. Plugging it into my arch linux resulted in not being able to find it with sane-find-scanner.

TLDR;

Check the current user is in the scanner group
groups | grep scanner
if it is not the case run the following command
gpasswd -a root scanner

Check also the sg module is loaded
lsmod | grep sg
if it is not the case run the following command
sudo modprobe sg
To load the sg module at startup, create a file named « /etc/modules-load.d/
onf » and add the following content inside
sg

Long Story

The scanner requires a sane lib, for arch you can get it from AUR:

Which will install the following files:

$ pacman -Ql libsane-dsseries
libsane-dsseries /etc/
libsane-dsseries /etc/sane.d/
libsane-dsseries /etc/sane.d/dll.d/
libsane-dsseries /etc/sane.d/dll.d/dsseries.conf
libsane-dsseries /etc/sane.d/dsseries.conf
libsane-dsseries /etc/udev/
libsane-dsseries /etc/udev/rules.d/
libsane-dsseries /etc/udev/rules.d/50-Brother_DSScanner.rules
libsane-dsseries /usr/
libsane-dsseries /usr/lib/
libsane-dsseries /usr/lib/sane/
libsane-dsseries /usr/lib/sane/NvUSBScan_x64.so
libsane-dsseries /usr/lib/sane/dsdrv_x64.so
libsane-dsseries /usr/lib/sane/libsane-dsseries.so
libsane-dsseries /usr/lib/sane/libsane-dsseries.so.1
libsane-dsseries /usr/lib/sane/libsane-dsseries.so.1.0.17
libsane-dsseries /usr/lib/udev/
libsane-dsseries /usr/lib/udev/rules.d/
libsane-dsseries /usr/lib/udev/rules.d/50-Brother_DSScanner.rules
libsane-dsseries /usr/share/
libsane-dsseries /usr/share/licenses/
libsane-dsseries /usr/share/licenses/libsane-dsseries/
libsane-dsseries /usr/share/licenses/libsane-dsseries/LICENSE.html

When plugging in the scanner I see the following in dmesg:

[36466.749347] usb 2-1.4: New USB device found, idVendor=04f9, idProduct=60e0, bcdDevice= 1.00

Let's see if the udev rule caught it:

$ cat /etc/udev/rules.d/50-Brother_DSScanner.rules
KERNEL=="sg[0-9]*", ATTRS{type}=="0", ATTRS{vendor}=="Brother", ATTRS{model}=="DS-620", MODE="0666", GROUP="users"
KERNEL=="sg[0-9]*", ATTRS{type}=="0", ATTRS{vendor}=="Brother", ATTRS{model}=="DS-720D", MODE="0666", GROUP="users"
KERNEL=="sg[0-9]*", ATTRS{type}=="0", ATTRS{vendor}=="Brother", ATTRS{model}=="DS-820W", MODE="0666", GROUP="users"
KERNEL=="sg[0-9]*", ATTRS{type}=="0", ATTRS{vendor}=="Brother", ATTRS{model}=="DS-920DW", MODE="0666", GROUP="users"

and the same is visible in /usr/lib/udev/rules.d/50-Brother_DSScanner.rules

Reloading udev rules to see if it might help:

$ sudo udevadm control --reload-rules

Still, sane-find-scanner does not find anything. However xsane recognised the device.

# sane-find-scanner

  # sane-find-scanner will now attempt to detect your scanner. If the
  # result is different from what you expected, first make sure your
  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that
  # you have loaded a kernel SCSI driver for your SCSI adapter.

could not fetch string descriptor: Pipe error
could not fetch string descriptor: Pipe error
  # No USB scanners found. If you expected something different, make sure that
  # you have loaded a kernel driver for your USB host controller and have setup
  # the USB system correctly. See man sane-usb for details.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports
  # can't be detected by this program.

Seems scanimage reports that it has found the scanner:

# scanimage -L
device `dsseries:usb:0x04F9:0x60E0' is a BROTHER DS-620 sheetfed scanner
...

I decided to install some other frontends:

# pacman -S sane-frontends

I found the command line tool scanadf. To list what are the options available for my device, I used:

$ scanadf --help -d "dsseries:usb:0x04F9:0x60E0"
Usage: scanadf [OPTION]...

Start image acquisition on a scanner device and write image data to
output files.

   [ -d | --device-name <device> ]   use a given scanner device.
   [ -h | --help ]                   display this help message and exit.
   [ -L | --list-devices ]           show available scanner devices.
   [ -v | --verbose ]                give even more status messages.
   [ -V | --version ]                print version information.
   [ -N | --no-overwrite ]           don't overwrite existing files.

   [ -o | --output-file <name> ]     name of file to write image data
                                     (%d replacement in output file name).
   [ -S | --scan-script <name> ]     name of script to run after every scan.
   [ --script-wait ]                 wait for scripts to finish before exit
   [ -s | --start-count <num> ]      page count of first scanned image.
   [ -e | --end-count <num> ]        last page number to scan.
   [ -r | --raw ]                    write raw image data to file.

Options specific to device `dsseries:usb:0x04F9:0x60E0':
  Scan mode:
    --mode LineArt|Gray|Color [Gray]
        Selects the scan mode (e.g., lineart, monochrome, or color).
    --resolution 75..600dpi (in steps of 1) [300]
        Sets the resolution of the scanned image.
    --preview[=(yes|no)] [no]
        Request a preview-quality scan.
    --source ADF [ADF]
        Selects the scan source (such as a document-feeder).
  Geometry:
    -l 0..215.9mm [0]
        Top-left x position of scan area.
    -t 0..355.6mm [0]
        Top-left y position of scan area.
    -x 0..215.9mm [215.9]
        Width of scan-area.
    -y 0..355.6mm [355.6]
        Height of scan-area.
  MultiFeed Detection:
    --ultrasonic Disable [Disable]
        Use ultrasonic sensor to detect multifeed
  Enhancement:
    --brightness -100..100% (in steps of 1) [0]
        Controls the brightness of the acquired image.
    --contrast -100..100% (in steps of 1) [0]
        Controls the contrast of the acquired image.
    --gamma-table 0..255,... [1321576864]
        Gamma-correction table.  In color mode this option equally affects the
        red, green, and blue channels simultaneously (i.e., it is an intensity
        gamma table).
    --red-gamma-table 0..255,... [1321577888]
        Gamma-correction table for the red band.
    --green-gamma-table 0..255,... [1321578912]
        Gamma-correction table for the green band.
    --blue-gamma-table 0..255,... [1321579936]
        Gamma-correction table for the blue band.

I ended up using this command to scan multiple images:

$ scanadf -d "dsseries:usb:0x04F9:0x60E0" --resolution 150 --mode Gray -x 210 -y 297 -o scan-%d.jpg

Which does not work as you'll need to configure an additional conversion script:

scanadf \
    -d "dsseries:usb:0x04F9:0x60E0" \
    --resolution 200 \
    --mode Gray \
    -x 210 \
    -y 297 \
    -o scan-%04d.jpg \
    --scan-script $(readlink -f scanscript.sh)

You can download scancript.sh from here

I also added a bit more timeout in :

$ cat /etc/sane.d/dsseries.conf
ADFWaitingTime 20

Adding SG module to be loaded at boot

$ cat /etc/modules-load.d/sg.conf
sg