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

Gerard Klaver gerard at gkall.hobby.nl
Fri May 26 20:19:46 UTC 2006

On Fri, 2006-05-26 at 22:52 +0300, Lauri Pirttiaho wrote:
> 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
It seems i get for my sq930x SANE webcam backend (under development)
the same errors. But when i do a init and read images with the MS driver
and then a reboot (Linux) and start my sq930x backend i don't get that
sort of errors but can do bulk reads with no problems.
Gerard Klaver

More information about the sane-devel mailing list