# Re: Connecting SANE and Java?

David Mosberger-Tang (davidm@azstarnet.com)
Mon, 21 Apr 1997 15:33:41 -0700

- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
- Next message: Gordon Matzigkeit: "Re: PINT driver patches"
- Previous message: Guido Muesch: "Connecting SANE and Java?"
- Maybe in reply to: Guido Muesch: "Connecting SANE and Java?"
- Next in thread: David Mosberger-Tang: "Re: Connecting SANE and Java?"

>>>>> On Tue, 22 Apr 1997 00:02:20 +0200 (MET DST), Guido Muesch <odiug@faho.rwth-aachen.de> said:

Guido> It seems to me that the netprotocol was designed to closely
Guido> resemble the C interface. It is RPC based and I do not know
Guido> how to use that from Java (especially the pointer to the
Guido> devicelist).

Not really. The netprotocol is _documented_ using a C-like
convention, but on the wire, there are of course no pointers
whatsoever. The sanei_net.h and sanei_wire.h routines are taking care
of converting C pointers etc into the linear wire format. In the
documentation, the mapping from C structure to the wire format is
documented in Sections 4.4.1-4.4.3. A small example might help:
assume we had the following C type:

typedef struct
{
char *name;
int cap;
}
*Simple;

Assume PTR is of type Simple and points to a structure whose NAME
member points to the string "This is an Example" and whose CAP member
has a value of 7. Then encoding PTR according to Sections 4.4.1-4.4.3
would give you the following values on the wire:

00000001 # PTR is not a NULL
# next follows the value that PTR points to
# a structure is represented by the sequence of it's members
# first, we have the NAME member, which is a pointer itself
00000001 # NAME is not a NULL pointer
00000013 # the string NAME points to is 19 bytes long
This is an Example\000 # the value of the string
# next, we have the value of the CAP member:
00000007
So, as you can see, no pointers at all. Now, there are a few places
where the SANE C API makes use of NULL pointers (e.g., to terminate
the device-list, for example). In Java, you'd not do this. Instead,
you'd probably create an array of device records whose length is
specified explicitly. I'm not familiar enough with Java to give you a
concrete type, but the point is that SANE does not depend on pointers
per se (the C API does, however).

Guido> Well I must admit that I do not know much about RPCs. And my
Guido> experience with Java is not much more than having written a
Guido> 'Hello World' program.

Don't pay too much attention to the RPC word. All that's really
needed for the SANE net protocol is the ability to write/read an
arbitrary byte-stream to/from TCP connections.

>> From what I see the netprotocol does not fit well into
>> Java. Maybe one

No, the net-protocol is language-independent. The description of it
is oriented to C and that may be what's confusing you. If the above
example doesn't clarify things, let me know and I'll try to do better.

Guido> Well, I have really not looked deeper into all of this, and
Guido> these are only suggestions. I don't know how many people on
Guido> the mailinglist are experienced in Java to give me a hint.

Can't help (much) with Java, but if there are any questions regarding
the net protocol, drop me a note (and yes, I do plan on finishing up
the docs and improving them soon).

--david

    --
    Source code, list archive, and docs: http://www.azstarnet.com/~axplinux/sane/
    To unsubscribe: mail -s unsubscribe sane-devel-request@listserv.azstarnet.com

- Next message: Gordon Matzigkeit: "Re: PINT driver patches"
- Previous message: Guido Muesch: "Connecting SANE and Java?"
- Maybe in reply to: Guido Muesch: "Connecting SANE and Java?"
- Next in thread: David Mosberger-Tang: "Re: Connecting SANE and Java?"