import java.io.IOException;
import java.net.InetAddress;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import au.com.southsky.jfreesane.SaneDevice;
import au.com.southsky.jfreesane.SaneException;
import au.com.southsky.jfreesane.SaneSession;
import au.com.southsky.jfreesane.SaneStatus;
public class Test {
private static final Logger myLogger = Logger.getLogger("au.com.southsky.jfreesane");
public static void main(String[] args) throws IOException, SaneException {
// Turn up logging levels
for (Handler handler : Logger.getLogger("").getHandlers()) {
handler.setLevel(Level.FINE);
}
myLogger.setLevel(Level.FINE);
SaneSession session = null;
SaneDevice device = null;
try {
InetAddress address = InetAddress.getByName("localhost");
session = SaneSession.withRemoteSane(address);
device = session.getDevice("hpaio:/usb/Deskjet_4620_series?serial=CN582736YP47TN");
device.open();
device.getOption("source").setStringValue("ADF"); // [Flatbed], ADF
device.getOption("mode").setStringValue("Color"); // [Lineart], Gray, Color
device.getOption("resolution").setIntegerValue(200); // 100, 200, 300, 600 (75)
while (true) {
try {
device.acquireImage();
} 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;
}
}
}
} finally {
if (device != null) try { device.close(); } catch (IOException e) { e.printStackTrace(); }
if (session != null) try { session.close(); } catch (IOException e) { e.printStackTrace(); }
}
}
}
...
FINE: Reached end of records
Sep 29, 2014 2:38:50 PM au.com.southsky.jfreesane.FrameInputStream readFrame
WARNING: truncated read (got 11,674,368, expected 14,187,600 bytes)
Sep 29, 2014 2:38:50 PM au.com.southsky.jfreesane.FrameInputStream readFrame
WARNING: padded image with 2,513,232 null bytes
Exception in thread "main" au.com.southsky.jfreesane.SaneException: STATUS_DEVICE_BUSY
at au.com.southsky.jfreesane.SaneSession.acquireImage(SaneSession.java:134)
at au.com.southsky.jfreesane.SaneDevice.acquireImage(SaneDevice.java:91)
at Test.main(Test.java:39)
ABRT problem creation: 'success'
I suspect there may be a spurious call to cancel() in there, will take a look when I get home. I'm going to add better logging in the process!
sent from my phone
If I try to wait after the first image is acquired, the next pages are ejected.
--
You received this message because you are subscribed to the Google Groups "jfreesane-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jfreesane-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.