2010/5/26 K?re S?rs <kare.sars at iki.fi>: > Hi, > > I have a couple of somewhat related problems regarding ?sane_get_devices(), > sane_init() and SANE_Authorization_Callback(). > > 1) sane_get_devices() does not update the available devices list without > calling sane_init(). I asked about this some time ago and got the answer that > it was a bug. With the version in (K)Ubuntu Lucid and the pashazz-sane PPA, I > still have the problem that the scanner is not found if turned on after > sane_init(). I use the epson2 and v4l backends. With epson2 I get a crash if > the scanner is on the first time but is turned off before the second > sane_get_devices(). > > Do you have any hints on where to start digging?
Many backends do not properly re-scan for devices. Those backends should be fixed. Which version of sane-backends is this? > 2) With ?sane_get_devices() I can get the vendor, model, type and backend > names for the available scanners. Is there a way to get the same information > about the currently opened device? I do not find an API for that. ?Have I > missed something? The problem is that I can specify a backend like "test" and > sane_open() will open either "test:0" or "test:1", but I do not know which one > and I do not get the vendor, model and type strings. Correct. This is a deficiency in the sane API. You have to keep the device list, and open a device by the given name. If you ask a backend for the NULL device, it is impossible to know which one you will get. > 3) libksane can be used in multi threaded applications and at the moment I'm > making sure that sane_exit() is only called when the last instance exits, as > sane_exit() will invalidate the other running instances. Should I do the same > for sane_init()?. So far it has not resulted in problems, but when I tried a > workaround for the ?sane_get_devices() problem I noticed that I got unwanted > behavior. sane-backends is not designed to be thread safe, as only one function (sane_cancel) is explicitly required to be reentrant. So, arrange your app to only call sane from one thread. But, more to your question- you should only call sane_init once. If you call it again (particularly without calling sane_exit first), I would not be surprised to hear of bad things happening. > 4) Again in a multi threaded application there might be two scanners that > require authentication. The resource string that is provided to > SANE_Authorization_Callback() contains the backend name and a md5 hash, but it > does not contain the same ":libusb:001:004" extra info type of sting that > sane_get_devices() returns for the backend. Which backend? > How should I identify the different scanners with the same backend? Or is the > authorization restricted to the backend with the same authentication for all > the scanners with the same backend? Personally, I'd probably skip the auth callback... allan -- "The truth is an offense, but not a sin"
