Microtek ScanMaker 3600 driver SourceForge Logo

Home | Technical Drawings

Hotplugging for the scanner

The problem

Since we use the usblib for communication with the scanner, it is exposed by means of the USB file system within /proc/bus/usb. The numbered files there provide access to the respective device.

These devices are normally READONLY. So only Ruth can access the device. Waht we need, is simply to

Solution: USB hotplugging

The kernel (2.4.x) provide for a solution, called "support for hout-pluggable devices" (found in the General Setup).

The kernel calls a magic script, /sbin/hotplug, whenever it detects a new USB device. This script, called with a bunch of useful parameters, does the fancy things You want.

There is a hotplugging framework available here, that does most of the stuff. It has the hotplug program, that does the further magic with some configuration files and scripts installed to /etc/hotplug. You simply have to edit one file and to add another, and You are fine.

How to to it

Well, installing the hotplug package is beyond the scope of this page. Your distribution should have one ready made. Or You will like to build Your own, it is *fairly* simple.

The trick is to tell the hotplugging about Your scanner. This is done with the /etc/hostplug/usb.usermap. In this case, we need the vendor-ID and the product-ID and the name of our own script doing the trick.

# usb module         match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceC
sm3600  0x0003  0x05da  0x40b3  0x0000  0x0000  0x00    0x00    0x00    0x00    0x00    0x00    0x000000000
sm3600  0x0003  0x05da  0x40ca  0x0000  0x0000  0x00    0x00    0x00    0x00    0x00    0x00    0x000000000
sm3600  0x0003  0x05da  0x40ff  0x0000  0x0000  0x00    0x00    0x00    0x00    0x00    0x00    0x000000000
sm3600  0x0003  0x05da  0x40b8  0x0000  0x0000  0x00    0x00    0x00    0x00    0x00    0x00    0x000000000
sm3600  0x0003  0x05da  0x40cb  0x0000  0x0000  0x00    0x00    0x00    0x00    0x00    0x00    0x000000000

The flags 0x0003 tell the usb.agent to check for exactly the vendor and the product id. You only need the line for Your scanner, but more lines don't harm.

The script sm3600 sits in /etc/hotplug/usb (alone, You have probably to create the directory first) and looks like:

#!/bin/sh
cd /etc/hotplug
. hotplug.functions
mesg setting permissions of $DEVICE
chown myaccount $DEVICE

When You hook Your scanner up (with working usb core, of course), the magic file should belong to You.

Debugging

If the things don't work out of the box, You'd like to check some log file entries.

On scanner hookup, the dmesg should tell You about the new device. If not, Your USB core is not working properly.

The Syslog (e.g. in /var/log/messages) should tell something like this:

Jan 12 16:19:21 buffy /sbin/hotplug: arguments (usb) env (PWD=/etc/hotplug HOSTNAME=buffy DEVICE=/proc/bus/usb/001/003 ACTION=add DEBUG=kernel MACHTYPE=i386-suse-linux OLDPWD=/ DEVFS=/proc/bus/usb TYPE=255/255/255 SHLVL=1 SHELL=/bin/bash HOSTTYPE=i386 OSTYPE=linux HOME=/ TERM=dumb PATH=/bin:/sbin:/usr/sbin:/usr/bin PRODUCT=5da/40b3/0 _=/usr/bin/env)
Jan 12 16:19:21 buffy /sbin/hotplug: invoke /etc/hotplug/usb.agent ()
Jan 12 16:19:21 buffy /etc/hotplug/usb.agent: Modprobe and setup sm3600 for USB product 5da/40b3/0
Jan 12 16:19:21 buffy /etc/hotplug/usb.agent: Module setup sm3600 for USB product 5da/40b3/0
Jan 12 16:19:21 buffy /etc/hotplug/usb/sm3600: setting permissions of /proc/bus/usb/001/003

You see the complete chain of script calls? If not, something in the middle is broken, like permissions (hotplug,sm3600), product IDs or so.

Good luck, mate!