I want to call dll to write/read from hardware.However, I get the error below:
dll method:
int NewKey(char *room,char *gate,char *stime,char *guestname,char *guestid, int overflag, int Breakfast, long *cardno,char * track1,char * track2);
java method:
int NewKey(String room, String gate,String time,String guestname,String guestid, int overflag, int Breakfast, NativeLongByReference cardno, String track1, String track2);
The api document shows cardno as a out parameter and track1,track2 could be null.
NativeLongByReference cardNo = new NativeLongByReference ();
int res = CLibrary.INSTANCE.NewKey("010001", "00", "201712021200201712031200", "Guest Name","Account No.", 0, 1, cardNo, null, null);
It don t work. So I use a simple method:
dll method :
int EraseCard (long cardno,char * track1,char * track2);
java method:
int EraseCard(NativeLong cardno, String track1, String track2);
NativeLong a = new NativeLong(0L);
int res = CLibrary.INSTANCE.EraseCard (a, null, null);
It gets the same error again:
Exception in thread "main" java.lang.Error: Invalid memory access
at com.sun.jna.Native.invokeInt(Native Method)
at com.sun.jna.Function.invoke(Function.java:383)
at com.sun.jna.Function.invoke(Function.java:315)
at com.sun.jna.Library$Handler.invoke(Library.java:212)
at A90PmsInterface.main(A90PmsInterface.java:104)
It seems like the error only occurs when I try to use the dll methods to read/write from/to hardware.
How can I solve the problem?
details: win7 64 bite, jre1.8 32bite, jna4.1