~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/Documentation/usb/scanner.txt

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 Copyright (C) 1999, 2000 David E. Nelson
  2 
  3 April 26, 2000
  4 
  5 CHANGES
  6 
  7 - Amended for linux-2.3.99-pre6-3
  8 - Appended hp_scan.c to end of this README
  9 - Removed most references to HP
 10 - Updated uhci/ohci host controller info
 11 - Updated support for multiple scanner support
 12 - Updated supported scanners list
 13 - Updated usbdevfs info
 14 - Spellcheck
 15 
 16 OVERVIEW
 17 
 18 This README addresses issues regarding how to configure the kernel
 19 to access a USB scanner.  Although the driver was originally conceived
 20 for USB HP scanners, it's general enough so that it can be used with
 21 other scanners.  Also, one can now pass the USB Vendor and Product
 22 ID's using module parameters for unknown scanners.  Refer to the
 23 document scanner-hp-sane.txt for guidance on how to configure SANE to
 24 use a USB HP Scanner.
 25 
 26 
 27 ADDITIONAL INFORMATION
 28 
 29 http://www.linux-usb.org/
 30 
 31 
 32 REQUIREMENTS
 33 
 34 A host with a USB port.  Ideally, either a UHCI (Intel) or OHCI
 35 (Compaq and others) hardware port should work.  At the time of this
 36 writing, there are two UHCI drivers and one OHCI.
 37 
 38 A Linux development kernel (2.3.x) with USB support enabled or a
 39 backported version to linux-2.2.x.  See http://www.linux-usb.org for
 40 more information on accomplishing this.
 41 
 42 A Linux kernel with USB Scanner support enabled.
 43 
 44 'lspci' which is only needed to determine the type of USB hardware
 45 available/installed in your machine.
 46 
 47 CONFIGURATION
 48 
 49 Using `lspci -v`, determine the type of USB hardware available/installed.
 50 
 51   If you see something like:
 52 
 53     USB Controller: ......
 54     Flags: .....
 55     I/O ports at ....
 56 
 57   Then you have a UHCI based controller.
 58 
 59   If you see something like:
 60 
 61      USB Controller: .....
 62      Flags: ....
 63      Memory at .....
 64 
 65   Then you have a OHCI based controller.
 66 
 67 Using `make menuconfig` or your preferred method for configuring the
 68 kernel, select 'Support for USB', 'OHCI/UHCI' depending on your
 69 hardware (determined from the steps above), 'USB Scanner support', and
 70 'Preliminary USB device filesystem'.  Compile and install the modules
 71 (you may need to execute `depmod -a` to update the module
 72 dependencies). If any of the USB sections were compiled into the
 73 kernel, a reboot is necessary. NOTE: Updating the boot disk with
 74 'lilo' may also be required. Testing was performed only as modules,
 75 YMMV.
 76 
 77 Beginning with version 0.4 of the driver, up to 16 scanners can be
 78 connected/used simultaneously.  If you intend to use more than
 79 one scanner at a time:
 80 
 81    Add a device for the USB scanner:
 82         `mknod /dev/usbscanner0 c 180 48`
 83         `mknod /dev/usbscanner1 c 180 49`
 84                       . 
 85                       .
 86         `mknod /dev/usb/scanner15 180 63`
 87 
 88 
 89 If you foresee using only one scanner it is best to:
 90         `mknod /dev/usbscanner0 c 180 48`
 91         `ln -s /dev/usbscanner0 /dev/usbscanner`
 92 
 93 
 94 Set appropriate permissions for /dev/usbscanner[0-15] (don't forget
 95 about group and world permissions).  Both read and write permissions
 96 are required for proper operation. For example:
 97         `chmod 666 /dev/usbscanner0`
 98 
 99 Load the appropriate modules (if compiled as modules):
100 
101   OHCI:
102     modprobe usb-ohci
103     modprobe scanner
104 
105   UHCI:
106     modprobe usb-uhci
107     modprobe scanner
108 
109 That's it.  SANE should now be able to access the device.  
110 
111 There is a small test program (hp_scan.c -- appended below) that can
112 be used to test the scanner device if it's an HP scanner that supports
113 SCL (Scanner Control Language).  Known HP scanner that support SCL are
114 the 4100, 5200, 6200, the 6300 -- note that the 4200 is *not*
115 supported since it does not understand SCL; it's also strongly
116 suspected that the 3300 and the PhotoSmart S20 are not SCL compliant.
117 Hp_scan.c's purpose is to test the driver without having to
118 retrieve/configure SANE.  Hp_scan.c will scan the entire bed and put
119 the output into a file called 'out.dat' in the current directory.  The
120 data in the file is raw data so it's not very useful for imaging.
121 
122 MESSAGES
123 
124 On occasions the message 'usb_control/bulk_msg: timeout' or something
125 similar will appear in '/var/adm/messages' or on the console or both,
126 depending on how your system is configured.  This is a side effect
127 that scanners are sometimes very slow at warming up and/or
128 initializing.  In most cases, however, only several of these messages
129 should appear and is generally considered to be normal.  If you see
130 a message of the type 'excessive NAK's received' then this should
131 be considered abnormal and generally indicates that the USB system is
132 unable to communicate with the scanner for some particular reason.
133 
134 SUPPORTED SCANNERS
135 
136 NOTE: Just because a product is listed here does not mean that
137 applications exist that support the product.  It's in the hopes that
138 this will allow developers a means to produce applications that will
139 support the listed USB products.
140 
141 At the time of this writing, the following scanners were supported by
142 scanner.c:
143 
144  Acer
145          Prisa Acerscan 620U & 640U (!)
146          Prisa AcerScan 620U (!)
147  Agfa
148          SnapScan 1212U
149          Another SnapScan 1212U (?)
150          SnapScan Touch
151  Colorado -- See Primax/Colorado below
152  Epson -- See Seiko/Epson below
153  Genius
154          ColorPage-Vivid Pro
155  Hewlett Packard
156          3300C
157          4100C
158          4200C
159          PhotoSmart S20
160          5200C
161          6200C
162          6300C
163  Microtek
164          ScanMaker X6 - X6U
165          Phantom 336CX - C3
166          Phantom 336CX - C3 #2
167          Phantom C6
168          ScanMaker V6USL
169          ScanMaker V6USL #2
170          ScanMaker V6UL - SpicyU
171  Mustek
172          1200 CU
173  Primax/Colorado
174          G2-300 #1
175          G2-600 #1
176          G2E-300 #1
177          ReadyScan 636i
178          G2-300 #2
179          G2-600 #2
180          G2E-300 #2
181          G2E-600
182          Colorado USB 9600
183          Colorado USB 19200
184          Colorado 600u
185          Colorado 1200u
186  Seiko/Epson Corp.
187          Perfection 636U and 636Photo
188          Perfection 610
189          Perfection 1200U and 1200Photo
190  Umax
191          Astra 1220U
192          Astra 1236U
193          Astra 2000U
194          Astra 2200U
195  Visioneer
196          OneTouch 5300
197          OneTouch 7600 duplicate ID (!)
198          6100
199 
200 
201 MODULE PARAMETERS
202 
203 If you have a device that you wish to experiment with or try using
204 this driver with, but the Vendor and Product ID's are not coded in,
205 don't despair.  If the driver was compiled as a module, you can pass
206 options to the driver.  Simply add 
207 
208   options scanner vendor=0x#### product=0x****
209 
210 to the /etc/modules.conf file replacing the #'s and the *'s with the
211 correct ID's.  The ID's can be retrieved from the messages file or
212 using `cat /proc/bus/usb/devices`. Note that USB /proc support must be
213 enabled during kernel configuration.  If the 'scanner' module is
214 already loaded into memory, it must be reloaded for the module
215 parameters to take effect.  In essence, `rmmod scanner; modprobe
216 scanner` must be performed.
217 
218 **NOTE**: In later kernels (2.3.38+), a new filesystem was introduced,
219 usbdevfs.  To mount the filesystem, issue the command (as root):
220 
221   mount -t usbdevfs /proc/bus/usb /proc/bus/usb
222 
223 An alternative and more permanent method would be to add
224 
225   none  /proc/bus/usb  usbdevfs  defaults  0  0
226 
227 to /etc/fstab.  This will mount usbdevfs at each reboot.  You can then
228 issue `cat /proc/bus/usb/devices` to extract USB device information.
229 
230 
231 BUGS
232 
233 Just look at the list of fixes in the source files.  So, if you
234 encounter any problems feel free to drop me an email.
235 
236 David /\/elson
237 dnelson@jump.net
238 http://www.jump.net/~dnelson
239 
240 --------------- snip -- hp_scan.c -- snip ---------------
241 /*
242 
243 This is a really crude attempt at writing a short test program.  It's
244 mostly only to be used to test connectivity with USB HP scanners that
245 understand SCL.  Currently, the supported models are 4100C, 5200C,
246 6200C, and the 6300C.  Note that the 4200C is *NOT* acceptable.
247 
248 Copyright (C) David E. Nelson <dnelson@jump.net>, 1999
249 
250 This program is free software; you can redistribute it and/or modify
251 it under the terms of the GNU General Public License as published by
252 the Free Software Foundation; either version 2 of the License, or (at
253 your option) any later version.
254 
255 */
256 
257 #include <stdio.h>
258 #include <stdlib.h>
259 #include <error.h>
260 #include <unistd.h>
261 #include <fcntl.h>
262 
263 /*
264    Gray Output produces about a 8945400 byte file.
265    Color Output produces a 26836200 byte file. 
266    
267    To compile: gcc -o hp_scan hp_scan.c
268 */
269 
270 // #define COLOR /* Undef to scan GrayScale */
271 
272 int send_cmd(int, const char *, int);
273 int read_cmd(int, char *, int);
274 
275 int
276 main(void) {
277 
278         ssize_t cnt = 0, total_cnt = 0;
279 
280         FILE *fpout;
281 
282         int fp;
283         int data_size = 32768;
284 
285         char *data;
286 
287         static char reset_cmd[] = {'\x1b','E'};
288 
289 #ifdef COLOR
290         static char data_type_cmd[] = {'\x1b','*','a','5','T'}; /* Color */
291         static char data_width_cmd[] = {'\x1b','*','a','2','4','G'}; /* 24 Bit Color */
292 #else
293         static char data_type_cmd[] = {'\x1b','*','a','4','T'}; /* Gray */
294         static char data_width_cmd[] = {'\x1b','*','a','8','G'}; /* 8 Bit Gray */
295 #endif
296 
297         static char query_cmd[] = {'\x1b', '*', 's', '2', '5', '7', 'E'};
298         static char start_scan_cmd[] = {'\x1b','*','f','0','S'};
299         
300         if(!(data=malloc(data_size))) {
301                 perror("malloc failed");
302                 exit (1);
303         }
304         
305         if((fp=open("/dev/usbscanner", O_RDWR)) < 0) {
306                 perror("Unable to open scanner device");
307                 exit (1);
308         }
309 
310         if((fpout=fopen("out.dat", "w+")) == NULL) {
311                 perror("Unable to open ouput file");
312                 exit(1);
313         }
314 
315         send_cmd(fp, reset_cmd, sizeof(reset_cmd));
316         send_cmd(fp, data_type_cmd, sizeof(data_type_cmd));
317         send_cmd(fp, data_width_cmd, sizeof(data_width_cmd));
318         send_cmd(fp, start_scan_cmd, sizeof(start_scan_cmd));
319 
320         while ((cnt = read(fp, data, data_size)) > 0) {
321                 printf("Read: %u\n", cnt); 
322                 if(fwrite(data, sizeof(char), cnt, fpout) < 0) {
323                         perror("Write to output file failed");
324                         exit (1);
325                 }
326                 total_cnt += cnt;
327         }
328         if (cnt < 0) {
329                 perror("Read from scanner failed");
330                 exit (1);
331         }
332 
333         printf("\nRead %lu bytes.\n", total_cnt);
334 
335         send_cmd(fp, reset_cmd, sizeof(reset_cmd));
336 
337         close(fp);
338         fclose(fpout);
339         return (0);
340 }
341 
342 int
343 send_cmd(int fp, const char * cmd, int length) {
344 
345         int result;
346         int x;
347 
348         if((result = write(fp, cmd, length)) != length) {
349                 printf ("Write warning: %d bytes requested, %d written\n");
350         } else if (result < 0) {
351                 perror ("send_cmd failure");
352                 exit (1);
353         }
354         return (result);
355 }
356         
357 int
358 read_cmd(int fp, char * response, int length) {
359 
360         return read(fp, response, length);
361 
362 }

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.