[sane-devel] Re: maxlen

Dave Neary david@phenix.fr
Mon, 20 Sep 2004 16:06:06 +0200


sane-devel-request@lists.alioth.debian.org wrote:
> Send sane-devel mailing list submissions to
> 	sane-devel@lists.alioth.debian.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.alioth.debian.org/mailman/listinfo/sane-devel
> or, via email, send a message with subject or body 'help' to
> 	sane-devel-request@lists.alioth.debian.org
> 
> You can reach the person managing the list at
> 	sane-devel-admin@lists.alioth.debian.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of sane-devel digest..."
> 
> 
> Today's Topics:
> 
>    1. Re: XSANE ... hotplug & 'mail image' probs. (Henning Meier-Geinitz)
>    2. Re: HP C5100A with Mac PowerBook (OSX 10.3) via scsi/usb or scsi/firewire adapter (Henning Meier-Geinitz)
>    3. Re: Problems with scsi filmscanner canon2700 (Henning Meier-Geinitz)
>    4. Why I can't use scan and preview in the Xsane? (=?big5?q?=20=20=20?=)
>    5. Re: Problems with scsi filmscanner canon2700 (mitsuru okaniwa)
>    6. Re: XSANE ... hotplug & 'mail image' probs. (Bertrik Sikken)
>    7. Calculating maxlen (Paul)
>    8. Re: Calculating maxlen (Oliver Rauch)
>    9. Re: Calculating maxlen (Paul)
>   10. Re: Calculating maxlen (abel deuring)
> 
> --__--__--
> 
> Message: 1
> Date: Sun, 19 Sep 2004 15:38:30 +0200
> From: Henning Meier-Geinitz <henning@meier-geinitz.de>
> To: sane-devel@lists.alioth.debian.org
> Subject: Re: [sane-devel] XSANE ... hotplug & 'mail image' probs.
> 
> Hi,
> 
> On Thu, Sep 16, 2004 at 08:48:26AM +0200, Bertrik Sikken wrote:
> 
>>In the 2.6.x range of kernels there is a weird issue (=bug?), i.e.
>>there is a race between the hotplug event and the creation of the
>>libusb 'device file' (in /proc/bus/usb).
> 
> 
> Uh, really? That makes the whole idea of hot-plug void. It hasn't
> happened for me, as far as I remember?
> 
> 
>>The libusbscanner hotplug script does not take this into account
>>so it may happen sometimes that the script tries to update permission
>>for a file that doesn't exist yet.
>>As far as I know, this race will be looked at in the next kernel
>>series,
> 
> 
> So the fix will be there in 2 or three years? Strange.
> 
> 
>>but for now you can use a dirty hack like a 'sleep 1' at the top of
>>the hotplug script.
> 
> 
> Should we use that? Or is there a less ugly way e.g. by checking if
> the device file is already there?
> 
> Bye,
>   Henning
> 
> 
> --__--__--
> 
> Message: 2
> Date: Sun, 19 Sep 2004 15:51:53 +0200
> From: Henning Meier-Geinitz <henning@meier-geinitz.de>
> To: sane-devel@lists.alioth.debian.org
> Subject: Re: [sane-devel] HP C5100A with Mac PowerBook (OSX 10.3) via scsi/usb or scsi/firewire adapter
> 
> Hi,
> 
> On Thu, Sep 16, 2004 at 04:01:50PM -0500, Albert Everett wrote:
> 
>>I would like to use an HP PhotoSmart Photo Scanner (C5100A, SCSI) with a Mac 
>>PowerBook G4.
>>
>>Does anyone know how I might get drivers for it that are compatible with OSX 
>>10.3.5?
> 
> 
> Have you tried SANE? At least our list seems to indicate that the
> scanner is supported by the HP backend.
> 
> Bye,
>   Henning
> 
> 
> --__--__--
> 
> Message: 3
> Date: Sun, 19 Sep 2004 15:54:01 +0200
> From: Henning Meier-Geinitz <henning@meier-geinitz.de>
> To: sane-devel@lists.alioth.debian.org
> Subject: Re: [sane-devel] Problems with scsi filmscanner canon2700
> 
> Hi,
> 
> On Fri, Sep 17, 2004 at 11:10:51PM +0200, Thomas Loescher wrote:
> 
>>did something went wrong with the kernel?
>>
>>In may this year, I'm very sure sane worked for me I had installed
>>sane-backend 1.0.13 and kernel 2.4.22, now I'm using 2.4.26. The scsi
>>controller is an tekram dc390 running with ncr53c8xx.
> 
> 
> Try if it still works with the older kernel.
> 
> Bye,
>   Henning
> 
> 
> --__--__--
> 
> Message: 4
> Date: Fri, 17 Sep 2004 17:31:29 +0800 (CST)
> From: =?big5?q?=20=20=20?= <sean035@yahoo.com.tw>
> To: sane-devel@lists.alioth.debian.org
> Subject: [sane-devel] Why I can't use scan and preview in the Xsane?
> 
> Dear All,
> I have a problem about sane. Why I can not use scan
> and preview these two capailities when I log in other
> user mode??? The Xsane always say "operation cancel".
> Can you give me a hand??? Thanks a lot,
> Walker
> 
> -----------------------------------------------------------------
> Yahoo!奇摩造型精靈
> 最新的造型精靈簽名檔,讓信件獨具個人色彩!
> http://tw.messenger.yahoo.com/
> 
> 
> --__--__--
> 
> Message: 5
> Date: Sun, 19 Sep 2004 23:43:28 +0900
> From: "mitsuru okaniwa" <m-okaniwa@bea.hi-ho.ne.jp>
> To: sane-devel@lists.alioth.debian.org
> Subject: Re: [sane-devel] Problems with scsi filmscanner canon2700
> 
> Hi Thomas,
> Would you try the canon-backend for canoscanFB620S in the web of Manuel
> Panea.
> Or the canon-backend (dated 1999.11.14, 70540 bytes) in Manuel Panea's web.
> His web is as follows;
> http://www.rzg.mpg.de/~mpd/sane/
> 
> The canon-backend (dated 1999.11.14, 70540 bytes) is an original version for
> canoscan2700F.
> Best regards,
> 
> mitsuru okaniwa
> ----- Original Message ----- 
> From: "Thomas Loescher" <mailgrab@gmx.de>
> To: <sane-devel@lists.alioth.debian.org>
> Sent: Saturday, September 18, 2004 6:10 AM
> Subject: Re: [sane-devel] Problems with scsi filmscanner canon2700
> 
> 
> 
>>Hi,
>>really strange....
>>I'm very sure, that my filmscanner worked with sane-backend 1.0.13, but it
> 
> doesn't work anymore.
> 
>>I also tested version version 1.0.12 and 1.0.13
>>Alway the same error message
>>scanimage: sane_start: Invalid argument
>>some debug output needed?
>>
>>did something went wrong with the kernel?
>>
>>In may this year, I'm very sure sane worked for me I had installed
> 
> sane-backend 1.0.13 and kernel 2.4.22, now I'm using 2.4.26. The scsi
> controller is an tekram dc390 running with ncr53c8xx.
> 
>>hm... really strange.
>>Any suggestions?
>>
>>best regards
>>
>>Thomas
> 
> 
> 
> 
> --__--__--
> 
> Message: 6
> Date: Sun, 19 Sep 2004 17:04:31 +0200
> From: Bertrik Sikken <bertrik@zonnet.nl>
> To: sane-devel@lists.alioth.debian.org
> Subject: Re: [sane-devel] XSANE ... hotplug & 'mail image' probs.
> 
> Henning Meier-Geinitz wrote:
> 
>>Hi,
>>
>>On Thu, Sep 16, 2004 at 08:48:26AM +0200, Bertrik Sikken wrote:
>>
>>
>>>In the 2.6.x range of kernels there is a weird issue (=bug?), i.e.
>>>there is a race between the hotplug event and the creation of the
>>>libusb 'device file' (in /proc/bus/usb).
>>
>>
>>Uh, really? That makes the whole idea of hot-plug void. It hasn't
>>happened for me, as far as I remember?
>>
>>
>>
>>>The libusbscanner hotplug script does not take this into account
>>>so it may happen sometimes that the script tries to update permission
>>>for a file that doesn't exist yet.
>>>As far as I know, this race will be looked at in the next kernel
>>>series,
>>
>>
>>So the fix will be there in 2 or three years? Strange.
> 
> 
> Yes, there really is a problem, but it may have been fixed in the
> some of the 'generic' hotplug scripts already (I noticed a couple
> of sleeps here and there in usb.agent and usb.rc on my MDK10.1
> system).
> I definitely had this problem earlier (with just about every USB
> device, scanner/minidisc/pendrive), but when I tried to reproduce
> it a moment ago but I didn't run into it anymore. So maybe I was
> a little paranoid.
> 
> Here's a thread from linux-hotplug-devel that discusses the problem:
> http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m=108034761409426&w=2
> (cut and paste it together if the link wraps)
> 
> 
>>>but for now you can use a dirty hack like a 'sleep 1' at the top of
>>>the hotplug script.
>>
>>
>>Should we use that? Or is there a less ugly way e.g. by checking if
>>the device file is already there?
> 
> 
> I'm not sure. Maybe it has really been 'fixed' in the latest hotplug
> package, in which case I think we need to know the exact version in
> which it was fixed.
> Instead of a sleep we could also use a loop to wait for the device
> (even uglier?).
> 
> BTW I noticed that the cvs version of sane now has a work-around
> (by Jochen Eisinger) claiming
> "# latest hotplug doesn't set DEVICE on 2.6.x kernels"
> I think this observation is also caused by a hotplug race.
> 
> Regards,
> Bertrik
> 
> 
> --__--__--
> 
> Message: 7
> From: Paul <paul@all-the-johnsons.co.uk>
> To: Sane <sane-devel@lists.alioth.debian.org>
> Organization: At home.
> Date: Sun, 19 Sep 2004 20:38:42 +0100
> Subject: [sane-devel] Calculating maxlen
> 
> 
> --=-EyBgZc7L2eK+2KbXNi9a
> Content-Type: text/plain
> Content-Transfer-Encoding: quoted-printable
> 
> Hi,
> 
> Just a small one here.
> 
> I'm using sane_read. handle is fine, but I need to pass a buffer the
> size of maxlen for *data. How do I work out maxlen? Is it simply the
> bytes per line * pixels per line or is it found from sane_get_parameters
> (SANE_Params *params->size)?
> 
> TTFN
> 
> Paul
> --=20
> Homer: Donut?=20
> Lisa: No, thanks. Do you have any fruit?=20
> Homer: This has purple stuff inside. Purple is a fruit.
> 
> --=-EyBgZc7L2eK+2KbXNi9a
> Content-Type: application/pgp-signature; name=signature.asc
> Content-Description: This is a digitally signed message part
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.6 (GNU/Linux)
> 
> iD8DBQBBTeBBusSVe5EZv3wRAlnwAJ9qLZVZYGqE56DYOdyJG9YgNVYIgQCdHVSK
> ZUchrle5CKU2yI8TRJNy8KQ=
> =37Y5
> -----END PGP SIGNATURE-----
> 
> --=-EyBgZc7L2eK+2KbXNi9a--
> 
> 
> 
> --__--__--
> 
> Message: 8
> From: Oliver Rauch <Oliver.Rauch@Rauch-Domain.DE>
> To: Paul <paul@all-the-johnsons.co.uk>
> Cc: Sane <sane-devel@lists.alioth.debian.org>
> Organization: 
> Date: 19 Sep 2004 21:52:14 +0200
> Subject: Re: [sane-devel] Calculating maxlen
> 
> Hello Paul.
> 
> max_len is set by the frontend. The buffer is allocated by the frontend
> and the size of the buffer must be at least max_len bytes.
> 
> max_len and the size of the buffer are arbitary. The backend must be
> able to handle each size from max_len=1 to max_len > size of the image.
> 
> Best regards
> Oliver
> 
> Am Son, 2004-09-19 um 21.38 schrieb Paul:
> 
>>Hi,
>>
>>Just a small one here.
>>
>>I'm using sane_read. handle is fine, but I need to pass a buffer the
>>size of maxlen for *data. How do I work out maxlen? Is it simply the
>>bytes per line * pixels per line or is it found from sane_get_parameters
>>(SANE_Params *params->size)?
>>
>>TTFN
>>
>>Paul
> 
> 
> 
> 
> --__--__--
> 


Hi Paul,

Paul said:
>>max_len is set by the frontend. The buffer is allocated by the frontend
>>and the size of the buffer must be at least max_len bytes.
>>max_len and the size of the buffer are arbitary. The backend must be
>>able to handle each size from max_len=3D1 to max_len > size of the image.
> 
> max_len is some size large enough to scan something in. How do I know
> how big to make this to (say) scan an A4 picture at 8bpp resolution? To
> me, it looks like I multiply bytes_per_line * pixels_per_line * lines *
> depth to accomodate everything.

You set max_len to whatever value suits you. Let's say you want to deal 
with the image data in 16K blocks, you would allocate a buffer for 16K 
of data, call sane_read to fill it, check for Sane_EOF as the status, do 
what you want to do with that chunk of data, and the call sane_read 
again. Basically, you are reading scanlines (the width of the scanlines 
and the bytes per pixel are in the parameters for the scan), and you 
keep calling sane_read until you get to the end of the file. At which 
stage you have a choice to call sane_start again to go onto the next 
page in an ADF, or call sane_close() to close the scanner and free it up 
for other connections.

> I'm currently toying with the code so I know what has to be done when it
> comes to implementing the code for real.

There's one excellent page on the sane-project.org webpage which shows a 
typical code flow for a sane application frontend. Unfortunately, it 
seems like the site is down right now, so I don't have the URL.

Cheers,
Dave.

-- 
David Neary
Phenix Engineering
110 ave Jean Jaures, 69007 Lyon