[sane-devel] sanei_usb_read_bulk: problem in handling of NAK

m. allan noah anoah at pfeiffer.edu
Sun May 28 19:32:44 UTC 2006


On Fri, 26 May 2006, Lauri Pirttiaho wrote:
> When using libusb method in sanei_usb the behavior of
> sanei_usb_read bulk seems to be that in responese to
> NAK (errno -ETIMEDOUT, strerror saying "Resource
> temporarily unavailable", which means the device
> can not temporarily provide more data)
> the sanei_usb_read_bulk calls usb_clear_halt
> and then returns SANEI_STATUS_IO_ERROR.

certain fujitsu scanners have trouble resetting the data0/1 usb toggle 
properly, generally at the first command after the scanner is opened. 
libusb returns to sane -ETIMEDOUT, and errno is EAGAIN (Resource 
temporarily unavailable).

the clear_halt does not help, i have tried both ways.

>
> Now because of the usb_clear_halt there is no longer access
> to the errno so this particular reason for the IO error
> can not be distinguished from others after sanei_usb_read
> bulk returns.

i do not understand this- errno still exists on my system, even after the 
clear call? are you saying that you want the negative read_size error 
returned?

>
> The solution in Avision backend seems to be that the
> errors from sanei_usb_read bulk are completely ignored and
> the function is called repeatedly until all data has been
> read. A temporary solution but maybe not the best one.
>

for some scanners, perhaps the only method that works.

> I would propose changing the behavior of sanei_usb_read bulk
> so that in the case of NAK (resource temporarily unavailable)
> the size is returned as 0 and the return value is set
> either to SANE_STATUS_GOOD (read OK, just no data
> at this moment) or SANE_STATUS_BUSY (device can not
> respond right now). Both will work even though probably
> the latter one is more in line with the meaning of USB NAK
> in this case.

what about all the other possible error codes that might be returned? what 
about using a callback mechanism like sanei_scsi does for sense data? then 
the backend can tell exactly what sane status it wants returned. 
unfortunately, i am not sure about the returns from non-libusb libs.

allan

>
> With best regards,
>
> Lauri Pirttiaho
> Oulu
> Finland
>
> ...................................................................
> Luukku Plus paketilla pääset eroon tila- ja turvallisuusongelmista.
> Hanki Luukku Plus ja helpotat elämääsi. http://www.mtv3.fi/luukku
>
>
> --
> sane-devel mailing list: sane-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/sane-devel
> Unsubscribe: Send mail with subject "unsubscribe your_password"
>             to sane-devel-request at lists.alioth.debian.org
>

-- 
"so don't tell us it can't be done, putting down what you don't know.
money isn't our god, integrity will free our souls" - Max Cavalera


More information about the sane-devel mailing list