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

Lauri Pirttiaho lauri.pirttiaho at luukku.com
Fri May 26 19:52:29 UTC 2006


Hello,

I have encountered a problem with bulk read that might
benefit from some change in sanei_usb. This problem
becomes visible in a fast machine like AMD64 and seems
to have been seen in Avision backend and now in cs3200f.

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.

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.

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.

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.

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




More information about the sane-devel mailing list