this is the first time I am using JNA. What I am trying to do is call a function in a DLL that takes (C code)->(unsigned long DeviceTypes, NeoDevice *pNeoDevice, int *pNumDevices)...(JNA form)-> (int, NeoDevice.getPointer(), int[] myInt) as params. The function should write to the fields of the struct and I want to view the updated fields.
here is my JNA struct 'NeoDevice'
import java.util.Arrays;
import java.util.List;
import com.sun.jna.*;
public class NeoDevice extends Structure {
public volatile int DeviceType;
public volatile int Handle;
public volatile int NumberOfClients;
public volatile int SerialNumber;
public volatile int MaxAllowedClients;
public NeoDevice() {
super();
}
protected List<? > getFieldOrder() {
return Arrays.asList("DeviceType", "Handle", "NumberOfClients", "SerialNumber", "MaxAllowedClients");
}
public NeoDevice(int DeviceType, int Handle, int NumberOfClients, int SerialNumber, int MaxAllowedClients) {
super();
this.DeviceType = DeviceType;
this.Handle = Handle;
this.NumberOfClients = NumberOfClients;
this.SerialNumber = SerialNumber;
this.MaxAllowedClients = MaxAllowedClients;
}
protected ByReference newByReference() { return new ByReference(); }
protected ByValue newByValue() { return new ByValue(); }
protected NeoDevice newInstance() { return new NeoDevice(); }
public static class ByReference extends NeoDevice implements Structure.ByReference {
};
public static class ByValue extends NeoDevice implements Structure.ByValue {
};
}
I am attempting to use 'updateStrucureByReference(class type, object, pointer to object)' to update the fields. I dont believe my 'class type' param is correct or is it? am i doing something else wronge? any input would be greatly appreciated.
when i try to println the fields they appear to all be zero still.
In my main class i have
NeoDevice.ByReference myDeviceByRef = new NeoDevice.ByReference();
NeoDevice.ByValue myDeviceByVal = new NeoDevice.ByValue();
NeoDevice myDevice = new NeoDevice();
int [] NumDevices;
NumDevices = new int [1];
NumDevices[0] = 1;
int iResult = n40.icsneoFindNeoDevices(65535, myDeviceByRef.getPointer(), NumDevices);
int icsneoGetDLLVersion = n40.icsneoGetDLLVersion();
Object serialN = myDeviceByRef.readField("SerialNumber");
NeoDevice.ByReference myDeviceBy = Structure.updateStructureByReference(NeoDevice.ByReference, myDeviceByRef, myDeviceByRef.getPointer());