[sane-devel] Pure java sane interface

andy andy at hazlorealidad.com
Thu Nov 16 23:58:23 CET 2006


Hello

I have been looking for a lgpl interface to sane from java.

I have seen jsane and scanlite but I cant use them as they are not lgpl.

So yesterday I started writing a pure java sane interface, I have
already got it to scan a document and save it as a png file, cool, sane
is quite simple!

My plan is to call it sane4j and release it on sourceforge as lgpl,
unless anyone knows of an existing lgpl java-sane interface.

I connect to saned, Init, open, start, close and exit are working.

However I have some problems with the protocol for commands like
getDevices and getOptionDescriptor. I think it maybe something to do
with my string decode routine (below).

The other thing I dont understand is the way pointers are transmitted.

Can someone explain how **ptr would be sent please.

Thanks in advance

Andy Bailey


public String readString() throws IOException
	{
		String s=null;
		int len=in.readInt();
		System.out.println("String of length "+len);
		if (len==0)
		{
			return null;
		}
		else if (len==1)
		{
			s="";			
		}
		else
		{
			byte buf[]=new byte[len-1];
			in.readFully(buf);
			s=new String(buf);
			
		}
		byte nul = in.readByte();
		//assert nul==0;
		return s;
	}




More information about the sane-devel mailing list