I have a problem trying to map this c++ function with JNA.
https://www.inventcom.net/fanuc-focas-library/program/cnc_rdexecprog
FWLIBAPI short WINAPI cnc_rdexecprog(unsigned short FlibHndl, unsigned short *length, short *blknum, char *data);
I tried with these mappings in java but dont work:
short cnc_rdexecprog(short FlibHndl, ShortByReference length, ShortByReference blknum, String data);
short cnc_rdexecprog(short FlibHndl, ShortByReference length, ShortByReference blknum, Pointer data);
short cnc_rdexecprog(short FlibHndl, ShortByReference length, ShortByReference blknum, Memory data);
The first mapping works but return me the same String that I send, the second and third shows this error:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Invalid memory access
I was able to get similar functions working thanks to this thread: Use C++ DLL from Java with JNA
I think that the problem are in the output parameter "char *data". How to map this function?