sjamesr/jfreesane

Touching a SaneOption while cycling

jurivrljicak opened this issue · 2 comments

Hi, I have a question.

Given

device.getOption("source").setStringValue("Automatic Document Feeder");

while (true) {
  try {
    BufferedImage image = device.acquireImage();
    process(image);
  } catch (SaneException e) {
    if (e.getStatus() == SaneStatus.STATUS_NO_DOCS) {
      // this is the out of paper condition that we expect
      break;
    } else {
      // some other exception that was not expected
      throw e;
    }
  }
}

I noticed that if process(image) involves touching a SaneOption (say a simple read stringValue) an exception in thrown (SaneStatus.STATUS_NO_DOCS).
Am I right? Is this a bug or is this a desired behavior?

thanks

jfreesane is a client to the SANE server, so we can only support what SANE itself supports. The code flow in the SANE specification shows that options are set in the "device setup" phase.

I'm not an expert, but from what I can tell, the sane daemon effectively leaves it to the backend driver to deal with option handling. I would say that modifying options in the middle of a scan is unexpected and different drivers are free to behave in a manner they choose (including returning STATUS_NO_DOCS).

great, thanks!