[sane-devel] Re: Fujitsu USB patches
Will do. Thanks! Ron Oliver Schirrmeister wrote: >Your patch is in the CVS now. >I had to do your patch by hand because I've changed the backend after >March 3. I hope I didn't mess up your code. Please test. > >Oliver > > >Am Die, 2003-03-11 um 22.26 schrieb Ron Cemer: > > >>The attached patch fixes the broken "ADF empty" detection on the Fujitsu >>scanners when connected via USB. It also fixes a sense-request issues, >>which were required in order to determine whether the ADF is empty. It >>also eliminates some duplicate code blocks. >> >>The patch is against the March 3, 2003, CVS snapshot. >> >>Can you apply this to the latest CVS? >> >>Thanks! >>Ron >> >> >> > > > > >
[sane-devel] Fujitsu USB patches
This is a multi-part message in MIME format. --050501080703020005050807 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit The attached patch fixes the broken "ADF empty" detection on the Fujitsu scanners when connected via USB. It also fixes a sense-request issues, which were required in order to determine whether the ADF is empty. It also eliminates some duplicate code blocks. The patch is against the March 3, 2003, CVS snapshot. Can you apply this to the latest CVS? Thanks! Ron --050501080703020005050807 Content-Type: text/plain; name="fujitsuPatch20030311.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fujitsuPatch20030311.diff" --- backend/fujitsu.c.ORIG 2003-03-02 18:11:10.0 -0800 +++ backend/fujitsu.c 2003-03-07 14:12:32.0 -0800 @@ -339,7 +339,7 @@ * required for compressed data transfer. sense_handler has to tell * the caller the number of scanned bytes. */ -static struct fujitsu *current_scanner; +static struct fujitsu *current_scanner = NULL; /* * used by sane_get_devices @@ -1985,28 +1985,14 @@ if ((ret = fujitsu_send(scanner))) { DBG (5, "sane_start: ERROR: failed to start send command\n"); - freeScanner (scanner); - if (scanner->connection == SANE_FUJITSU_USB) { - sanei_usb_close (scanner->sfd); - } else if (scanner->connection == SANE_FUJITSU_SCSI) { - sanei_scsi_close (scanner->sfd); - } - scanner->object_count = 0; - scanner->sfd = -1; + doCancel(scanner); return ret; } #if 0 if ((ret = imprinter(scanner))) { DBG (5, "sane_start: ERROR: failed to start imprinter command\n"); - freeScanner (scanner); - if (scanner->connection == SANE_FUJITSU_USB) { - sanei_usb_close (scanner->sfd); - } else if (scanner->connection == SANE_FUJITSU_SCSI) { - sanei_scsi_close (scanner->sfd); - } - scanner->object_count = 0; - scanner->sfd = -1; + doCancel(scanner); return ret; } #endif @@ -2015,14 +2001,7 @@ (ret = object_position (scanner, SANE_TRUE))) { DBG (5, "sane_start: WARNING: ADF empty\n"); - freeScanner (scanner); - if (scanner->connection == SANE_FUJITSU_USB) { - sanei_usb_close (scanner->sfd); - } else if (scanner->connection == SANE_FUJITSU_SCSI) { - sanei_scsi_close (scanner->sfd); - } - scanner->object_count = 0; - scanner->sfd = -1; + doCancel(scanner); return ret; } @@ -2032,14 +2011,7 @@ if ((ret = setWindowParam (scanner))) { DBG (5, "sane_start: ERROR: failed to set window\n"); - freeScanner (scanner); - if (scanner->connection == SANE_FUJITSU_USB) { - sanei_usb_close (scanner->sfd); - } else if (scanner->connection == SANE_FUJITSU_SCSI) { - sanei_scsi_close (scanner->sfd); - } - scanner->object_count = 0; - scanner->sfd = -1; + doCancel(scanner); return ret; } @@ -2059,13 +2031,7 @@ { DBG (MSG_ERR, "ERROR: could not create pipe\n"); scanner->object_count = 0; - freeScanner (scanner); - if (scanner->connection == SANE_FUJITSU_USB) { - sanei_usb_close (scanner->sfd); - } else if (scanner->connection == SANE_FUJITSU_SCSI) { - sanei_scsi_close (scanner->sfd); - } - scanner->sfd = -1; + doCancel(scanner); return SANE_STATUS_IO_ERROR; } @@ -2078,13 +2044,7 @@ { DBG (MSG_ERR, "ERROR: could not create temporary file.\n"); scanner->object_count = 0; - freeScanner (scanner); - if (scanner->connection == SANE_FUJITSU_USB) { - sanei_usb_close (scanner->sfd); - } else if (scanner->connection == SANE_FUJITSU_SCSI) { - sanei_scsi_close (scanner->sfd); - } - scanner->sfd = -1; + doCancel(scanner); return SANE_STATUS_IO_ERROR; } } @@ -2094,13 +2054,7 @@ { DBG (MSG_ERR, "ERROR: could not create duplex pipe.\n"); scanner->object_count = 0; - freeScanner (scanner); - if (scanner->connection == SANE_FUJITSU_USB) { - sanei_usb_close (scanner->sfd); - } else if (scanner->connection == SANE_FUJITSU_SCSI) { - sanei_scsi_close (scanner->sfd); - } - scanner->sfd = -1; + doCancel(scanner); return SANE_STATUS_IO_ERROR; } } @@ -2518,11 +2472,10 @@ { case 0x0: /* No Sense */ DBG (5, "\t%d/%d/%d: Scanner ready\n", sense, asc, ascq); - if (get_RS_EOM (sensed_data)) -{ + if ( (current_scanner != NULL) && (get_RS_EOM (sensed_data)) ) { cur
[sane-devel] Windows
Has anyone done any work toward getting sane-backends working under windoze? Maybe by compiling under cygwin? Does cygwin even provide direct access to SCSI, USB, or parallel port devices? Maybe we're stuck with TWAIN and ISIS on that anti-platform? Thanks! Ron
[sane-devel] Bugfix in Epson USB config
Henning Meier-Geinitz wrote: >Hi, > >On Fri, Feb 14, 2003 at 07:11:02AM -0500, Karl Heinz Kremer wrote: > > >>Ron Cemer said: >> >> >>>The attached patch fixes a bug in the Epson driver when parsing >>>hexadecimal vendor and product ids from the epson.conf file. The sscanf >>> was using %d (which only accepts decimal arguments), so I changed it to >>> %i (which also accepts hexadecimal arguments). >>> >>>Thanks! >>>Ron >>> >>> >>Thanks, I'll apply this patch tonight. >> >> > >By the way: Does automatic detection of Epson USB devices work? >Currently the usb part in epson.conf is commented out. So with a fresh >SANE installation, does the user need to put "usb" in epson.conf or >does the epson backend scan for Epson USB scanners automatically when >e.g. scanimage -L is run? > > It requires a line in the format "usb" or "usb ". When I comment that line out here, it does not find my epson scanner. >Bye, > Henning >___ >Sane-devel mailing list >sane-de...@www.mostang.com >http://www.mostang.com/mailman/listinfo/sane-devel > > >
[sane-devel] Fujitsu USB patches
This is a multi-part message in MIME format. --030703000607030909030808 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I've fixed the patchfile based on your feedback below. I'm using a newer version of gcc which allows you to declare variables inline with local scope, instead of at the top of the function. I just moved the setwinB declaration to the top of the function. And you're right, the fujitsu.man patch is reversed. I fixed that also. I'll re-send this patch to the fujitsu maintaner. No response from him yet. Thanks! Ron Henning Meier-Geinitz wrote: >Hi, > >On Thu, Feb 13, 2003 at 03:40:44PM -0800, Ron Cemer wrote: > > >>Here are updated patches that get the Fujitsu fi-4220C scanner working, >>and add USB support for Fujitsu scanners. >> >>It now supports libusb or regular usb scanner devices, as described in >>the sane-usb man page. >> >>It uses SCSI commands over USB, using a non-standard implementation of >>the USB mass storage protocol. >> >>Thanks to Henning for various suggestions to get it in line with the >>SANE standards! :-) >> >>I'm sending this to both the sane-devel mailing list and the current >>Fujitsu backend maintaner, in hopes that the changes will be implemented >>as quickly as possible. >> >> > >If you don't get a response from the maintainer (say in 3 weeks), >please contact us again. Just in case he isn't active any longer. > > > >>--- ./backend/fujitsu.c.orig 2002-09-16 05:19:52.0 -0700 >>+++ ./backend/fujitsu.c 2003-02-13 15:03:17.0 -0800 >> >> > >[...] > > > >>@@ -4352,18 +4609,26 @@ >>* follows without a header of its own. >>*/ >> >>+ >>+scsiblk *setwinB; >> >> > >gcc complains: > >fujitsu.c: In function setWindowParam': >fujitsu.c:4613: parse error before *' >fujitsu.c:4615: setwinB' undeclared (first use in this function) > >setwinB doesn't seem to be defined anywhere. > > > >>+++ ./doc/descriptions/fujitsu.desc 2003-02-13 15:04:51.0 -0800 >>@@ -37,6 +37,8 @@ >> :interface "SCSI" >> :model "M4097" >> :interface "SCSI" >>+:model "fi-4220C" >>+:interface "SCSI USB" >> :model "fi-4340C" >>-:interface "SCSI" >>+:interface "SCSI USB" >> >> > >That's ok if you (or someone else) have tested these models with both >USB and SCSI and they work. > >If you think other models may also work but you can't test (because >you don't have a scanner), you can use entries like that: > >:model "whatever" >:interface "SCSI" >:status :untested >:comment "Looks similar to foo, please test" > > > >>--- ./doc/sane-fujitsu.man.orig 2003-02-13 15:13:15.0 -0800 >>+++ ./doc/sane-fujitsu.man2002-11-29 12:15:30.0 -0800 >>@@ -4,13 +4,13 @@ >> .IX sane-m3096g >> >> .SH NAME >>-sane-fujitsu \- SANE backend for Fujitsu flatbed and ADF scanners >>+sane-fujitsu \- SANE backend for Fujitsu flatbed scanners >> >> > >That patch is reversed (the other way round)! > >Bye, > Henning >___ >Sane-devel mailing list >sane-de...@www.mostang.com >http://www.mostang.com/mailman/listinfo/sane-devel > > > --030703000607030909030808 Content-Type: text/plain; name="fi-4220C-USB.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fi-4220C-USB.diff" --- backend/Makefile.in.orig2003-01-13 11:49:46.0 -0800 +++ backend/Makefile.in 2003-02-12 14:00:17.0 -0800 @@ -302,6 +302,7 @@ libsane-fujitsu.la: ../sanei/sanei_config2.lo libsane-fujitsu.la: ../sanei/sanei_constrain_value.lo libsane-fujitsu.la: ../sanei/sanei_scsi.lo +libsane-fujitsu.la: ../sanei/sanei_usb.lo libsane-gphoto2.la: ../sanei/sanei_constrain_value.lo djpeg.lo libsane-gt68xx.la: ../sanei/sanei_constrain_value.lo libsane-gt68xx.la: ../sanei/sanei_usb.lo --- backend/fujitsu-scsi.h.orig 2002-09-16 05:19:52.0 -0700 +++ backend/fujitsu-scsi.h 2003-02-12 14:00:17.0 -0800 @@ -230,6 +230,16 @@ static scsiblk set_windowB = { set_windowC, sizeof (set_windowC) }; #define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) + /* With the fi-series scanners, we have to use a 12-byte command +* instead of a 10-byte command when communicating via USB. This +* may be a firmware bug. */ +static unsig
[sane-devel] Fujitsu USB scanner support working!
This is a multi-part message in MIME format. --030807050104050404010400 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sure. Here is the Epson patch. It makes epson.conf work properly with lines formatted like "usb 0x04b8 0x011e" (where 0x04b8 is the vendor and 0x011e is the product). Henning, can you put this into the latest version? The fujitsu patches are huge, since they also add USB support, and support for the fi-4220C scanner. I've posted them before, and they are in the process of being reviewed. Thanks! Ron Till Kamppeter wrote: > Can you post a patch which fixes both the "fujitsu" and the "epson" > backend? > >Till > --030807050104050404010400 Content-Type: text/plain; name="epson_usb_vendor_device.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="epson_usb_vendor_device.diff" --- backend/epson.c.orig2002-12-31 13:20:33.0 -0800 +++ backend/epson.c 2003-02-15 10:22:52.0 -0800 @@ -1709,16 +1709,6 @@ */ /* -* if the config file contains a line "usb /dev/usbscanner", then handle -* this here and use the USB device from now on. -*/ - if (s->hw->connection == SANE_EPSON_USB) - { - /* we have a match for the USB string and adjust the device name */ - sanei_usb_init(); - } - - /* * if interface is SCSI do an inquiry. */ @@ -2215,6 +2205,8 @@ if( version_code != NULL) *version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, SANE_EPSON_BUILD); + sanei_usb_init(); + /* default to /dev/scanner instead of insisting on config file */ if( (fp = sanei_config_open (EPSON_CONFIG_FILE))) { @@ -2231,7 +2223,7 @@ if( !len) continue; /* ignore empty lines */ - if (sscanf(line, "usb %d %d", &vendor, &product) == 2) + if (sscanf(line, "usb %i %i", &vendor, &product) == 2) { sanei_usb_attach_matching_devices(line, attach_one_usb); } --030807050104050404010400--
[sane-devel] Fujitsu USB scanner support working!
It's definitely a bug. And you're right, it's still not working in the epson module, even when you change the sscanf from %d to %i, so there's probably another bug somewhere. However, when I copied the same code into fujitsu.c, changed the sscanf from %d to %i, and on success (sscanf returns 2) I call sanei_usb_attach_matching_devices(...) [instead of sanei_config_attach_matching_devices], I can now configure my fujitsu scanner using "usb 0x04c5 0x1042", and scanimage recognizes the scanner and I am able to scan just fine. My guess is that either sanei_config_attach_matching_devices has a bug, or possibly more likely, it's more appropriate to call sanei_usb_attach_matching_devices, since we know for sure that we're trying to attach a USB device. Till Kamppeter wrote: > Henning Meier-Geinitz wrote: > >> >> I think it's ok. The epson backend checks for "usb vendor product" and >> calls sanei_usb_attach_matching_devices if it find such a line. >> Otherwise it checks for "usb" and calls attach for the device name. If >> it's not "usb", it calls sanei_config_attach_matching_devices(line, >> attach_one); >> >> > > Are you sure that the "epson" backend understands something other than > fixed devices? I have tried > > usb 0x04b8 0x0112 > > for my Epson Perfection 2450 and the "epson" backend did not find it. > The only way to get this scanner working is to use a fixed address as > > usb /dev/usb/scanner1 > >Till > > > ___ > Sane-devel mailing list > sane-de...@www.mostang.com > http://www.mostang.com/mailman/listinfo/sane-devel >
[sane-devel] Fujitsu USB patches
This is a multi-part message in MIME format. --040803030607030006060400 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Here are updated patches that get the Fujitsu fi-4220C scanner working, and add USB support for Fujitsu scanners. It now supports libusb or regular usb scanner devices, as described in the sane-usb man page. It uses SCSI commands over USB, using a non-standard implementation of the USB mass storage protocol. Thanks to Henning for various suggestions to get it in line with the SANE standards! :-) I'm sending this to both the sane-devel mailing list and the current Fujitsu backend maintaner, in hopes that the changes will be implemented as quickly as possible. Code formatting may not be exactly as you would expect, so please feel free to use indent to correct it if you like. Thanks! Ron Cemer --040803030607030006060400 Content-Type: text/plain; name="fi-4220C-USB.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fi-4220C-USB.diff" --- ./backend/Makefile.in.orig 2003-01-13 11:49:46.0 -0800 +++ ./backend/Makefile.in 2003-02-12 14:00:17.0 -0800 @@ -302,6 +302,7 @@ libsane-fujitsu.la: ../sanei/sanei_config2.lo libsane-fujitsu.la: ../sanei/sanei_constrain_value.lo libsane-fujitsu.la: ../sanei/sanei_scsi.lo +libsane-fujitsu.la: ../sanei/sanei_usb.lo libsane-gphoto2.la: ../sanei/sanei_constrain_value.lo djpeg.lo libsane-gt68xx.la: ../sanei/sanei_constrain_value.lo libsane-gt68xx.la: ../sanei/sanei_usb.lo --- ./backend/fujitsu-scsi.h.orig 2002-09-16 05:19:52.0 -0700 +++ ./backend/fujitsu-scsi.h2003-02-12 14:00:17.0 -0800 @@ -230,6 +230,16 @@ static scsiblk set_windowB = { set_windowC, sizeof (set_windowC) }; #define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) + /* With the fi-series scanners, we have to use a 12-byte command +* instead of a 10-byte command when communicating via USB. This +* may be a firmware bug. */ +static unsigned char set_usb_windowC[] = + { SET_WINDOW, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00 }; +/* opcode, lun, _4 X reserved, transfer length, control byte */ +static scsiblk set_usb_windowB = { set_usb_windowC, sizeof (set_usb_windowC) }; +#define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) + /* */ static unsigned char object_positionC[] = @@ -378,6 +388,17 @@ }; + /* With the fi-series scanners, we have to use a 10-byte header +* instead of a 4-byte header when communicating via USB. This +* may be a firmware bug. */ +static unsigned char mode_select_usb_headerC[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +static scsiblk mode_select_usb_headerB = { + mode_select_usb_headerC, sizeof (mode_select_usb_headerC) +}; + + static unsigned char mode_select_parameter_blockC[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, --- ./backend/fujitsu.c.orig2002-09-16 05:19:52.0 -0700 +++ ./backend/fujitsu.c 2003-02-13 15:03:17.0 -0800 @@ -77,6 +77,10 @@ - 3092 support (mgopp...@tbz-pariv.de) - tested 4097 support - changed some functions to receive compressed data + V 1.4, 13-Feb-2003 + - fi-4220C support (r...@roncemer.com) + - USB support for scanners which send SCSI commands over usb + (r...@roncemer.com) SANE FLOW DIAGRAM @@ -124,6 +128,7 @@ #include "sane/sanei_backend.h" #include "sane/sanei_scsi.h" +#include "sane/sanei_usb.h" #include "sane/saneopts.h" #include "sane/sanei_config.h" @@ -338,6 +343,11 @@ static const SANE_Device **devlist = 0; /* + * used by attachScanner and attachOne + */ +static Fujitsu_Connection_Type mostRecentConfigConnectionType = SANE_FUJITSU_SCSI; + +/* * @@ Section 2 - SANE Interface */ @@ -364,11 +374,14 @@ size_t len; FILE *fp; + mostRecentConfigConnectionType = SANE_FUJITSU_SCSI; authorize = authorize;/* get rid of compiler warning */ DBG_INIT (); DBG (10, "sane_init\n"); + sanei_usb_init(); + if (version_code) *version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, 0); fp = sanei_config_open (FUJITSU_CONFIG_FILE); @@ -393,6 +406,7 @@ while (sanei_config_read (line, PATH_MAX, fp)) { + int vendor, product; /* ignore comments */ if (line[0] == '#') @@ -457,11 +471,23 @@ lp); } } - else /* must be a device name if it's not an option */ +else if (sscanf(lp, "usb %i %i", &vendor, &product) == 2) { + mostRecentConfigConnectionType = SANE_FUJITSU_USB; + sanei_usb_attach_mat
[sane-devel] Bugfix in Epson USB config
This is a multi-part message in MIME format. --030902090002010806050503 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit The attached patch fixes a bug in the Epson driver when parsing hexadecimal vendor and product ids from the epson.conf file. The sscanf was using %d (which only accepts decimal arguments), so I changed it to %i (which also accepts hexadecimal arguments). Thanks! Ron --030902090002010806050503 Content-Type: text/plain; name="epson_usb_vendor_device.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="epson_usb_vendor_device.diff" --- backend/epson.c.orig2002-12-31 13:20:33.0 -0800 +++ backend/epson.c 2003-02-13 14:50:15.0 -0800 @@ -2231,7 +2231,7 @@ if( !len) continue; /* ignore empty lines */ - if (sscanf(line, "usb %d %d", &vendor, &product) == 2) + if (sscanf(line, "usb %i %i", &vendor, &product) == 2) { sanei_usb_attach_matching_devices(line, attach_one_usb); } --030902090002010806050503--
[sane-devel] Fujitsu USB scanner support working!
Thanks for your comments. I'm absolutely new to SANE, so I expected that there would be some mistakes in my code. (see below) Henning Meier-Geinitz wrote: >Hi, > >On Wed, Feb 12, 2003 at 02:19:39PM -0800, Ron Cemer wrote: > > >>Attached is a patch file which can be applied to sane-backends-1.0.11. >>It adds support for the Fujitsu fi-4220C flatbed/ADF scanner, over USB. >> >> > >That's cool. > > > >>I don't have access to any other Fujitsu scanners, but I would venture >>to guess that this is likely to work with any SCSI/USB Fujitsu scanner. >> >> > > > >>The majority of the patches are to add USB support for Fujitsu >>scanners. Fujitsu uses a SCSI/USB chip, an Espon S1R72105. When >>talking USB, they wrap the SCSI commands using a non-standard variation >>of the USB mass storage protocol. That's what I've implemented in order >>to get USB support working. >> >> > >Ok. So it's better to keep the SCSI-over-USB stuff in the fujitsu >backend instead of making a sanei file. > > > >>For the /etc/sane.d/fujitsu.conf config file, comment out everything and >>just add a line like this: >> usb /dev/usb/scanner0 >> >> > >That's not really "standard" but I'll comment on this later. > > I was trying to do it the way that the epson does it (e.g. "usb /dev/usb/scanner0" in the .conf file). Not sure whether that's the best approach, but that got me going initially. > > >>Could these patches be applied to the current development version of >>sane-backends, so that others can benefit from them? >> >> > >Did you talk to the fujitsu backend maintainer Oliver Schirrmeister >? It's up to him to decide. > > Not yet, but I will now. I didn't really know who to get in touch with. Thanks for letting me know! >Some comments (I don't have a Fujitsu scanner, just from looking >through the patch): > > > >> else /* must be a device name if it's not an >> option */ >> { >>+ if ((strncmp ("usb", lp, 3) == 0) && isspace (lp[3])) { >>+ lp += 3; >>+ lp = sanei_config_skip_whitespace (lp); >>+ mostRecentConfigConnectionType = SANE_FUJITSU_USB; >>+ } >> strncpy (devName, lp, sizeof (devName)); >> devName[sizeof (devName) - 1] = '\0'; >> sanei_config_attach_matching_devices (devName, attachOne); >>+ mostRecentConfigConnectionType = SANE_FUJITSU_SCSI; >> } >> } >> >> > >That won't work with the "usb vendor product" lines. You're opening a >fixed USB device name without checking for vendor and product ids if I >didn't miss anything. > Here I'm just looking for something like "usb /dev/usb/scanner0" (or any device name prefixed with the word "usb" and a space), and if I find it, I'm making the decision to try to attach this scanner as a USB scanner instead of a SCSI scanner. >So you don't know which scanner you are talking >too. This may freeze SANE if it's not a Fujitsu scanner. And it means >you must adjust the file name, e.g. it would be /dev/uscanner0 on >FreeBSD. For some systems, there is no kernel scanner driver at all >and even on Linux, the user may want to use libusb. So I wouldn't use >this manual way of detecting USB scanners. Use the standard "usb >vendor product" detection scheme (with >sanei_usb_attach_matching_devices) and check for vendor and product >ids. If you want to also support fixed device names (e.g. >/dev/usb/scanner0), you could check for "usb /" and run attach with >the device name manually. > > I'll give this technique a try. I'll have a look at the epson driver to see how it's being done there, and I'll try to more closely match that. > > >>+/// >> >> Oops: left-over from debugging. I use three slashes to mark debug statements I want to remove later, as well as hacks that I'm testing. I'll get rid of this. >Please don't use C++-style comments, they are not supported by all >compilers. > >Please also have a look at the coding style, indent should be able to >"fix" that. > > Do you have a list of args you like to run indent with? >A manpage update and an updated doc/descriptions/fujitsu.desc file >would be also nice. But I guess the maintainer can du that :-) > > I'm not sure how to update the manpage, but I can surely update the doc/descriptions/fujitsu.desc file. >Until it's included, I'll update the entries in our scanner list to >point to this patch. > >Don't you want to add your copyright to the top of the file(s)? > > I guess so. Hadn't thought of that. > >Thanks for your work, > > Welcome! Hopefully this will help lots of Fujitsu scanner users. > Henning >___ >Sane-devel mailing list >sane-de...@www.mostang.com >http://www.mostang.com/mailman/listinfo/sane-devel > > >
[sane-devel] Fujitsu USB scanner support working!
This is a multi-part message in MIME format. --060806010404040009080508 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Attached is a patch file which can be applied to sane-backends-1.0.11. It adds support for the Fujitsu fi-4220C flatbed/ADF scanner, over USB. I don't have access to any other Fujitsu scanners, but I would venture to guess that this is likely to work with any SCSI/USB Fujitsu scanner. The majority of the patches are to add USB support for Fujitsu scanners. Fujitsu uses a SCSI/USB chip, an Espon S1R72105. When talking USB, they wrap the SCSI commands using a non-standard variation of the USB mass storage protocol. That's what I've implemented in order to get USB support working. The remainder of the patches were not done by myself, but include workarounds for differences between the fi-4340 and the fi-4220C. Without those minor workarounds, the fi-4220C will not scan. To install these patches, copy the file into your sane-backends-1.0.11 directory, then enter "patch -p0 < fi-4220C-USB.diff". Then run your configure, make, and make install as normal. For the /etc/sane.d/fujitsu.conf config file, comment out everything and just add a line like this: usb /dev/usb/scanner0 Then in /etc/modules.conf, add the following lines: # Vendor and product ids for Fujitsu fi-4220C scanner: options scanner vendor=0x04c5 product=0x1042 Then hook the scanner's USB port to the computer. Run lsusb to be sure it's there. Then do "rmmod scanner" followed by "modprobe scanner". You may want to add the "modprobe scanner" command to /etc/rc.d/rc.local to be sure the scanner module is loaded on bootup. Now scanimage should be able to see the scanner. Use "scanimage -L" to verify this. Now you're ready to scan! Could these patches be applied to the current development version of sane-backends, so that others can benefit from them? Thanks! Ron --060806010404040009080508 Content-Type: text/plain; name="fi-4220C-USB.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fi-4220C-USB.diff" --- backend/Makefile.in 2003-01-13 11:49:46.0 -0800 +++ backend/Makefile.in 2003-02-12 13:04:47.0 -0800 @@ -302,6 +302,7 @@ libsane-fujitsu.la: ../sanei/sanei_config2.lo libsane-fujitsu.la: ../sanei/sanei_constrain_value.lo libsane-fujitsu.la: ../sanei/sanei_scsi.lo +libsane-fujitsu.la: ../sanei/sanei_usb.lo libsane-gphoto2.la: ../sanei/sanei_constrain_value.lo djpeg.lo libsane-gt68xx.la: ../sanei/sanei_constrain_value.lo libsane-gt68xx.la: ../sanei/sanei_usb.lo --- backend/fujitsu-scsi.h 2002-09-16 05:19:52.0 -0700 +++ backend/fujitsu-scsi.h 2003-02-11 16:11:36.0 -0800 @@ -230,6 +230,16 @@ static scsiblk set_windowB = { set_windowC, sizeof (set_windowC) }; #define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) + /* With the fi-series scanners, we have to use a 12-byte command +* instead of a 10-byte command when communicating via USB. This +* may be a firmware bug. */ +static unsigned char set_usb_windowC[] = + { SET_WINDOW, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00 }; +/* opcode, lun, _4 X reserved, transfer length, control byte */ +static scsiblk set_usb_windowB = { set_usb_windowC, sizeof (set_usb_windowC) }; +#define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) + /* */ static unsigned char object_positionC[] = @@ -378,6 +388,17 @@ }; + /* With the fi-series scanners, we have to use a 10-byte header +* instead of a 4-byte header when communicating via USB. This +* may be a firmware bug. */ +static unsigned char mode_select_usb_headerC[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +static scsiblk mode_select_usb_headerB = { + mode_select_usb_headerC, sizeof (mode_select_usb_headerC) +}; + + static unsigned char mode_select_parameter_blockC[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, --- backend/fujitsu.c 2002-09-16 05:19:52.0 -0700 +++ backend/fujitsu.c 2003-02-12 13:47:41.0 -0800 @@ -124,6 +124,7 @@ #include "sane/sanei_backend.h" #include "sane/sanei_scsi.h" +#include "sane/sanei_usb.h" #include "sane/saneopts.h" #include "sane/sanei_config.h" @@ -338,6 +339,11 @@ static const SANE_Device **devlist = 0; /* + * used by attachScanner and attachOne + */ +static Fujitsu_Connection_Type mostRecentConfigConnectionType = SANE_FUJITSU_SCSI; + +/* * @@ Section 2 - SANE Interface */ @@ -364,11 +370,14 @@ size_t len; FILE *fp; + mostRecentConfigConnectionType = SANE_FUJITSU_SCSI; authorize = authorize;/* get rid of compiler warning */ DBG_INIT (); DBG (10, "sane_init\n"); + sanei_usb_init(); + if (version_code) *version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, 0);
[sane-devel] OS/2 device driver for HP7450C
Ok, I just got this Fujitsu fi-4220C scanner working via USB. I've been doing the work on the 1.0.9 version of sane-backends, since that's the version that we've been using so far, and that's where our changes have been implemented to make this scanner work via SCSI. So I need to port the changes forward into the latest version (I guess from CVS). I'll get that done soon. There were two commands that are different between USB and SCSI for this scanner. They are MODE_SELECT and SET_WINDOW. So I put some code in to detect when we're using an fi-series scanner over usb connection, and step around that problem by using properly formatted commands for USB. I found the differences using USB Snoopy and a Windoze ME box. As far as the rest of it is concerned, I just added a do_usb_cmd function, and then added a new do_cmd function to dispatch the commands to either do_usb_cmd or do_scsi_cmd. Then I changed all do_scsi_cmd calls into do_cmd calls. Then I modified the config file reader to recognize "usb" prefix before device name, as with the epson scanner, and to set a flag bit in the fujitsu scanner structure (which I also added) to indicate that the scanner is connected via USB. Also, wherever the sanei_scsi_open and sanei_scsi_close functions were being called, I test this USB connection flag, and if it's turned on, I call sanei_usb_open or sanei_usb_close instead sanei_scsi_open or sanei_scsi_close. All in all, the changes are really simple, and when you see them, you may decide it's not worth doing a separate module to handle my changes. One reason I say this is because the Fujitsu scanner uses an Epson S1R72105 SCSI/USB interface chip. When communicating via USB, the USB mass storage spec is implemented to "wrap" the SCSI commands, but it is implemented in a non-standard way (some things don't match up to the spec), so you may find that the protocol deviates from the standard so much that it's an exception rather than the rule. Anyway, let me make the changes to the latest version from CVS, and once those are done and tested, I'll send you the output of "diff -u". There are four files affected: backend/fujitsu.h backend/fujitsu-scsi.h backend/fujitsu.c backend/Makefile.in So in the mean time, maybe you don't want to make lots of changes to these files. It will only take me a day or two to get this re-implemented into the latest version from CVS. Thanks! Ron Rene Rebe wrote: >On: Tue, 11 Feb 2003 19:27:35 +0100, > Henning Meier-Geinitz wrote: > > >>Hi, >> >>On Tue, Feb 11, 2003 at 10:13:20AM -0800, Ron Cemer wrote: >>[SCSI-over-USB] >> >> >>>I'm already working on this in the fujitsu driver. I've almost gotten >>>it working. Fujitsu is supposed to get back to me with the specs on the >>>chip that they're using to do the USB and SCSI interface. After I get >>>it working, you can probably use the same technique for any other >>>scanners which have both a SCSI and a USB interface. >>> >>> >>If it's really the same scheme for all scanners, I propose to write a >>sanei/sanei_uos.c (usb ober scsi) file and provide an interface >>similar to sanei_scsi.c. So SANE backends can use SCSI and USB >>scanners without much change. >> >> > >Interesting - I'll also take a look into the hpusbscsi driver - since >the hpusbscsi is rather touchy it would be nice to have a user-space >only solution. > > > >>Bye, >> Henning >> >> > >- René > >-- >René Rebe - Europe/Germany/Berlin >e-mail: rene.r...@gmx.net, r...@rocklinux.org >web: www.rocklinux.org, drocklinux.dyndns.org/rene/ > >Anyone sending unwanted advertising e-mail to this address will be >charged $25 for network traffic and computing time. By extracting my >address from this message or its header, you agree to these terms. >___ >Sane-devel mailing list >sane-de...@www.mostang.com >http://www.mostang.com/mailman/listinfo/sane-devel > > >
[sane-devel] OS/2 device driver for HP7450C
> > >>I'm already working on this in the fujitsu driver. I've almost gotten >>it working. Fujitsu is supposed to get back to me with the specs on the >>chip that they're using to do the USB and SCSI interface. After I get >>it working, you can probably use the same technique for any other >>scanners which have both a SCSI and a USB interface. >> >> > >If it's really the same scheme for all scanners, I propose to write a >sanei/sanei_uos.c (usb ober scsi) file and provide an interface >similar to sanei_scsi.c. So SANE backends can use SCSI and USB >scanners without much change. > > I think that's a great idea. Just to get it working quickly, I'm doing most of the changes inside of fujitsu.c. But...if someone would like to adapt my changes into a sanei_uos.c file, I think that would be great.
[sane-devel] OS/2 device driver for HP7450C
Henning Meier-Geinitz wrote: >Hi, > >On Tue, Feb 11, 2003 at 12:51:00AM +0100, Rene Rebe wrote: > > >>But using USB is not that easy - I guess writing a kernel driver for >>OS/2 is not that easy (we would need s.th. like the hpusbscsi) - maybe >>I should "convert" my driver to do the scsi-emulation in user-space? >>Via libusb or so? >> >>Any hints (I never did any low-level usb prgramming - the hpusbscsi >>luckily just appeared ;-) >> >> > >I have no idea how complicated the SCSI-over-USB protocol is. Maybe >the only thing you must do is to send the command + data buffers you >usually send to the SCSI layer through sanei_scsi through sanei_usb. > >If you use sanei_usb, you don't need to worry if it uses libusb or the >kernel scanner driver. > > I'm already working on this in the fujitsu driver. I've almost gotten it working. Fujitsu is supposed to get back to me with the specs on the chip that they're using to do the USB and SCSI interface. After I get it working, you can probably use the same technique for any other scanners which have both a SCSI and a USB interface.