[sane-devel] USB printer aliasing, SainTwain , epson2 and epkowa backend

hagar hagar at iinet.net.au
Thu Jan 21 17:13:18 UTC 2010


I have been trying to set up a Epson Stylus TX110 scanner/printer with 
sane with a connection from a windows vista box.

I have discovered that SainTwain does not like the epkowa backend :{ ( 
And the epkowa backend does not like SaneTwain )

But I have also discovered that the scanner works under the epson2 driver
Vendor - 04b8
Product - 084d

which also works with SainTwain :}

During this entire process I went to pains to set up the aliasing of the 
devices using udev.

These are the files that I now use to set up this aliasing. I wanted 
easy to modify settings.
You may do share/modify them as you wish

I thought they might be useful as I found the aliasing system to be very 
simplifying
(After getting it working)

Although I found only 1 of the 3 scanners that I tested had a serial number.
I thought this feature may come in handy for someone.

/etc/sane.d/alias.conf
#######################################################################
#
# Alias configuretion file for use by udev-sane-alias
#
#######################################################################
# Manufacturer   Device   Alias   Driver   Bus   Serial(optional)
#
# eg.
# Canon CanoScan D660
#04a9    2208    Canon-Canoscan-D660U    plustek    libusb
04a9    2208    Canon-Canoscan-D660U    plustek    libusb

#Epson Stylus TX110
#epkowa locks up SaneTwain (and then the scanner)
#04b8    084d    Epson-Stylus-TX110    epkowa    usb    XXXXXXXXXX
#ensure that /etc/sane.d/epson2.conf contains the line
#usb 04b8 084d
04b8    084d    Epson-Stylus-TX110    epson2    libusb    XXXXXXXXXX

#Mustek-1200-UB-Plus
05d8    4002    Mustek-1200-UB-Plus    gt68xx    libusb


/lib/udev/rules.d /40-sane-alias.rules
############################################################################
#
#  Checks usb device against /etc/sane.d/alias.conf and sets alias if found
#
#  Written by D. H. McKay
#
############################################################################
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", 
RUN+="/lib/udev/udev-sane-alias"


/lib/udev/udev-sane-alias
#!/bin/bash
#######################################################################
#
# Sane USB device alias file controlled by udev.
#
# Written by D. H. McKay
#
#######################################################################
SANE_ALIAS_CONF=/etc/sane.d/alias.conf
SANE_ALIASFILE=/etc/sane.d/dll.aliases
SANE_ALIASTEMP=/etc/sane.d/dll.aliases.temp

PROGNAME=${0##*/}
PID=$$
function logit ()
{
  logger -t ${PROGNAME}[$PID] $@
}

SANE_BUS=""
SANE_NUM=""
SANE_ALIAS=""
SANE_DVR=""
SANE_TYPE=""
SANE_SRL=""
SANE_FND=0
SANE_DEV=""

if ! test -e $SANE_ALIAS_CONF ; then
cat <<EOF > $SANE_ALIAS_CONF
#######################################################################
#
# Alias configuretion file for use by udev-sane-alias
#
#######################################################################
# Manufacturer Device Alias Driver Bus Serial (optional)
#
# eg.
# Canon CanoScan D660
#04a9   2208    Canon-Canoscan-D660U    plustek libusb
#
#Epson Stylus TX110
#epkowa locks up SaneTwain (and then the scanner)
#04b8   084d    Epson-Stylus-TX110      epkowa  usb     XXXXXXXXXX
#ensure that /etc/sane.d/epson2.conf contains the line
#usb 04b8 084d
#04b8   084d    Epson-Stylus-TX110      epson2  libusb  XXXXXXXXXX
EOF
fi

if ! test -e $SANE_ALIASFILE ; then
echo > $SANE_ALIASFILE
fi

while read T_BUS T_NUM T_ALIAS T_DVR T_BTYPE T_SRL ; do
  test x${T_BUS:1:1} == "x#" -o x${T_NUM:1:1} == x && continue
  if test x$ID_VENDOR_ID = x$T_BUS -a x$ID_MODEL_ID = x$T_NUM ; then
    if test x$T_SRL = x -o x$T_SRL = x$ID_SERIAL_SHORT ; then
      SANE_FND=1
      SANE_ALIAS="$T_ALIAS"
      SANE_DVR="$T_DVR"
      SANE_TYPE="$T_BTYPE"
      SANE_SRL="$T_SRL"
    fi
  fi
done <${SANE_ALIAS_CONF}

if test $SANE_FND -eq 1 ; then
  if test x$ACTION = xadd -o x$ACTION = xremove ; then
  logit $ACTION device $SANE_ALIAS
    if grep -q $SANE_ALIAS $SANE_ALIASFILE ; then
      logit removed old `grep $SANE_ALIAS $SANE_ALIASFILE`
      cat $SANE_ALIASFILE | grep -v $SANE_ALIAS > ${SANE_ALIASTEMP}
      rm $SANE_ALIASFILE
      mv ${SANE_ALIASTEMP} $SANE_ALIASFILE
    fi
  fi

  if test x$ACTION = xadd ; then
    if test x$BUSNUM != x ; then
      SANE_BUS=$BUSNUM
      SANE_NUM=$DEVNUM
    elif test x${DEVICE} != x ; then
      SANE_BUS=$(echo ${DEVICE} | sed 's:.*usb.\([0-9]*\).\([0-9]*\).*:\1:')
      SANE_NUM=$(echo ${DEVICE} | sed 's:.*usb.\([0-9]*\).\([0-9]*\).*:\2:')
    else
      SANE_BUS=$(echo ${DEVNAME} | sed 
's:.*usb.\([0-9]*\).\([0-9]*\).*:\1:')
      SANE_NUM=$(echo ${DEVNAME} | sed 
's:.*usb.\([0-9]*\).\([0-9]*\).*:\2:')
    fi
    SANE_DEV="${SANE_DVR}:${SANE_TYPE}:${SANE_BUS}:${SANE_NUM}"
    logit alias $SANE_ALIAS $SANE_DEV
    echo "alias $SANE_ALIAS $SANE_DEV" >> $SANE_ALIASFILE
  fi
fi




More information about the sane-devel mailing list