java - JNA wrong structure field values -
i'm dancing around jna adapter "twain.h" - did it, still have problems getting scanner capabilities. there original enity:
typedef unsigned short tw_uint16, far *ptw_uint16; typedef unsigned long tw_uint32, far *ptw_uint32; typedef struct { tw_uint16 itemtype; tw_uint32 minvalue; /* starting value in range. */ tw_uint32 maxvalue; /* final value in range. */ tw_uint32 stepsize; /* increment minvalue maxvalue. */ tw_uint32 defaultvalue; /* power-up value. */ tw_uint32 currentvalue; /* value in effect. */ } tw_range, far * ptw_range;
this mapping (thnx jnaerator)
public static class tw_range extends structure { /** c type : tw_uint16 */ public short itemtype; /** c type : tw_uint32 */ public nativelong minvalue; /** c type : tw_uint32 */ public nativelong maxvalue; /** c type : tw_uint32 */ public nativelong stepsize; /** c type : tw_uint32 */ public nativelong defaultvalue; /** c type : tw_uint32 */ public nativelong currentvalue; public tw_range() { super(); } protected list<? > getfieldorder() { return arrays.aslist("itemtype", "minvalue", "maxvalue", "stepsize", "defaultvalue", "currentvalue"); } }
when i'm asking scanner entity, scanner sends me filled object, when create through
new tw_range(pointer)
it returns me wired stuff
twaindsmlibrary$tw_range(native@0x157c000c) (22 bytes) { short itemtype@0=870 nativelong minvalue@2=1572916 nativelong maxvalue@6=5500 nativelong stepsize@a=2097152 nativelong defaultvalue@e=5500 nativelong currentvalue@12=2621440 }
- how can interpret values?
- can dump native structure , analyze tool? have seen pointer.dump, requires size of dumped value, how can size of structure under pointer?
structure.read()
must called in order copy native memory jna structure
fields.
the easiest way ensure structure.read()
called tw_range(pointer)
constructor last statement.
jna calls structure.read()/write()
automatically when making function calls. intentionally not in structure
constructors, leaving programmer decide best point @ perform synchronization (if @ all).
Comments
Post a Comment