Parallel port scanners

From openSUSE

This guide is intended as help to owners of scanners that use parallel port to connect to computer. There is no many left in use as no one makes them anymore, since USB is just as cheap, but technically superior to parallel port.

Contents

Background

"Parallel port scanners" is somewhat misleading term used to describe scanners that are attached to computer using parallel port, which was and still is a standard part of PC hardware. It was used mostly to connect printers, but also as a cheap alternative to SCSI interface for few other types of peripherals that require high data transfer rate like backup tapes, external disk drives, scanners, etc. It is today replaced with USB even for printers.

The actually scanner interface inside the scanner was SCSI, and parallel port was used as cheap (and slow) alternative. Looking in the list of supported scanners on Scanner Access Now Easy (SANE) web page you can see that many models that use parallel port to connect to computer are actually alternatives to those with real SCSI interface. What is the difference? SCSI is superior to parallel port, but it cost more.

So how they made SCSI to work over parallel port?

On scanner side there was a chip, SCSI to parallel port adapter, and on computer side, instead of hardware adapter, it was used program called scanner driver. The price for a trade off was lower transfer rate and higher CPU usage. While lower transfer rate might be acceptable, the higher CPU usage made computer to stop responding during the scan. Since drivers were developed when CPU were at 200-300 MHz clock and often not updated since then, you can expect that GUI will freeze, even today's computers are 10 times faster. The cure for this doesn't exist if you use precompiled drivers, like in windows. Those lucky that know how to edit driver source code can modify driver to use just a portion of CPU power.


Installation - Configuration

The parallel port scanners can be configured with YaST, but automatic recognition is not performed. There are many reasons for that:

  • development of drivers is stopped as there is no more new products that use parallel port
  • there is number of drivers that have to be loaded in order to find the scanner and this will take enormous long time.

This means that you have to try scanner installation using YaST as a very first step and if it doesn't work resort to other options described later. In many cases scanning will work right after installation, though sometimes it will be necessary additional tweaking to help scanner applications to work.

The YaST Scanner configuration is described in article YaST Scanner, for parallel scanners first step after YaST fails to find a scanner (as designed) is to click on Add button, which will open "Scanner Model and Driver Selection" screen where you can enter scanner model in a search box.

Image:yast-hardware-scanner-model-selection.png

If you are not sure or result of search is a blank page, enter the manufacturer name and it will present you with a list of models from that vendor. Choose exact model and see the comment, scanner may not be supported so any further effort with YaST is pointless. If it is supported highlight the entry and press Next. YaST will attempt to load a driver and if it succeeds you are on the lucky side. You will see something like this:

Image:yast-hardware-scanner-configuration.png

Click on finish and you can start using scanner. There is few applications that you can use to scan images:

Xsane seems to be the most complete at the moment.


Scanner is not supported

In the case that no scanner was found the image will be something like this:

Image:yast-hardware-scanner-configuration-nil.png

Now little background. The subsystem that makes scanning possible is SANE. If you look at Scanner_Introduction you can see block diagram that explains structure of SANE.

For the parallel port scanners USB part in diagram is replaced with drivers that will allow access to scanner:

  • ppscsi - SCSI to parallel port adapter
  • one of low level drivers that will communicate with adapter chip in the scanner.

The ppscsi and few low level drivers are included in:

ppscsi-beta2-20060424.tar.gz

archive that can be found on

http://penguin-breeder.org/kernel/download/

Don't forget to download MD5 sum and signature, and check file integrity as advised on web page.

It is source code that compiles and works fine with openSUSE 10.2 64 bit, kernel 2.6.18.8-0.3-default with all patches by June 21, 2007. Other platforms and versions are not tested, but usually there is no problems.


Prerequisites

To compile sources you have to install:

  • kernel sources
  • compiler gcc
  • program make

all available in distribution installation sources, so you can use YaST to install them.

After kernel sources installation we have to create configuration file

/usr/src/linux/.config

otherwise compilation will fail.

For that we need root user rights. In KDE open konsole, click on drop down menu Session, select New Root Shell, and give root password when prompted for. Now run:

 cd  /usr/src/linux
 make cloneconfig
 make prepare


Compiling and installing

  • 1) Create working directory. In KDE open konsole run commands:
 mkdir scanner
 cd scanner
  • 2) Use browser to download ppscsi-beta2-20060424.tar.gz to directory scanner.
  • 3) Extract archive with:
tar -xzf ppscsi-beta2-20060424.tar.gz

This will create new subdirectory ppscsi-beta2.

  • 4) Go in this directory and compile drivers:
 cd ppscsi-beta2
 make

After some time that depends on computer speed you will see your command prompt again.

  • 5) To see result of compiling run:
 ll 

Files ending with .ko are kernel object modules ie. your drivers.

  • 6) Copy .ko files where kernel expect to find them. To do this you have to be a root. In order not to change current directory run command:
 su

it will ask you for the Password:. Give a root password.

Note that it was not used su - , as we didn't want to be placed in root user home directory.
  • 7) Copy modules and run depmode so the kernel can find new modules:
 cp ./*.ko  /lib/modules/`uname -r`/kernel/drivers/scsi/ 
 depmode

The `uname -r` will be replaced with result of command uname -r and that is current kernel version.


Testing Modules

Now you can load driver modules to test do they work. This will be explained using as example Microtek Slimscan C6 scanner. That scanner has OnSpec 90C26 chip as SCSI to parallel port adapter. It is supported with onscsi module.

 modprobe onscsi

it will load that module and dependencies like ppscsi, parport, parport_pc, sg (SCSI Generic).

This module takes time to load as it has to talk to the scanner. The end result is created device /dev/sgX where X can be from 0 if you scanner is first sg device to max number of sg devices allowed by system. Let's take it is /dev/sg0 .

To test what SANE can see scanner is used:

scanimage -L

it will give us this:

device `microtek2:/dev/sg0' is a Microtek Phantom 636cx / C6 flatbed scanner


Usability Notes

For Microtek Slimscan C6 and compatible


  • To prevent "Out of memory" error add this:
 export SANE_SG_BUFFERSIZE=32768

otherwise any application that attempt to use scanner will fail with error "Out of memory". To make it permanent on each login it should be added to file .bashrc in your home directory.


  • To have bigger buffer:
 export SANE_SG_BUFFERSIZE=65536

but sg module has to be loaded with

 rmmod sg
 modprobe sg def_reserved_size=65536

The first line will remove module if it is already loaded, and second will load it with bigger buffer. This buffer will be used for all sg devices :-)



For all scanners using ppscsi.c


  • Preventing total freezing of mouse and desktop:

Before compiling look in ppscsi.c find:

 #define PPSC_DEF_NICE   0

and set nice level to 10:

 #define PPSC_DEF_NICE   10 

Result is much better than with original 0 that is probably fine for old computers, but unnecessary today. You can control nice level and few more parameters during module loading. See ppscsi.c for details.


  • Automatic driver loading on boot:

There is a few options. Recommended is to add modules to

/etc/modules.conf.local

but this was not tested yet.

Alternative is to put commands in:

/etc/init.d/boot.local

The simple form that doesn't test anything used for Slimscan C6 is:

 echo Loading scanner module onscsi;
 modprobe onscsi&

This will start scanner driver, but it will do the job in the background.


See also

Article YaST Scanner