Hello there,
I have some Shared Objects (.os files) to operate an equipment and I am having the following problem:
I am loading the library and executing a method that will return an int. It will change the values of the items in the Structure that is passed ByReference (it was passed the pointer in the native). Everything run just fine, but when I read the contents of the Structure, what I get are values like: "[B@1133F1D7" that looks to me like memory position. Or making some changes it returns strange values when all I wanted was some regular values that I've set in the equipment as 1550 for wavelength. I am guessing the problem that I am dealing is a problem of knowing how to use the JNA ByReference on Structures.

Following there are the codes that I used. I also have some example of the use of the libraries in C++, but I have to use java:


Java Code:
//Native C++
//Struct to be used. It's in a header file: struct.h
#pragma pack(push,1)
typedef struct ST_SCANPARMS    
{
	unsigned char iCommand; // 1 ?ò 2??
	int sortype;			// 1 :GR169 2 :SR4731
	int scanmode;			//average scan
	int scanrange;			//60KM
	int avgtime;			//6s
	int wavelength;			//wave length 1310
	int pulsewidth;			//3000ns
	int ior; 
	double sensitivity;		//low
	double filberendloss;
	unsigned char crcLow;
	unsigned char crcHigh;
}SCANPARMS,*PSCANPARMS;
#pragma pack(pop)

//Method's signature to use the .so, it is in a header file called nfosock.h and the .so is nfosock.so
int GetParms(SCANPARMS *tRetParms ,char sIP[],short nPort);

//Calling the method in the main fuction, nfo.cpp
int ret=-1;
SCANPARMS parms;
char arrIP[30] = {0};
short nPort = 0;
//...
//Values of IP and port are set in the code...
//...
ret = GetParms(&parms ,arrIP ,nPort);
Using the app in C++, it returns the values that I wish.
But using java it's different.
Follows tha java code:

Java Code:
public class SCANPARMS extends Structure{
		public static class ByReference extends SCANPARMS implements Structure.ByReference { }
		public char iCommand; // 1 ?ò 2??
		public int sortype;			// 1 :GR169 2 :SR4731
		public int scanmode;			//average scan
		public int scanrange;			//60KM
		public int avgtime;			//6s
		public int wavelength;			//wave length 1310
		public int pulsewidth;			//3000ns
		public int ior; 
		public double sensitivity;		//low
		public double filberendloss;
		public char crcLow;
		public char crcHigh;
	}

//the signature of the methods are weird, but this is what I found when i typed "nm //nfosock.so" 
public interface NFOSock extends Library{
	int _Z8GetParmsP12ST_SCANPARMSPcs(SCANPARMS.ByReference tRetParms,String sIP,short nPort);
	int _Z9GetDeviceP14ST_Device_Info(ST_Device_Info[] tDevice);
	String _Z13GetLibVersionv();	
}

//Main code
public static void main(String args[]){
	NFOSock nfosock = (NFOSock)Native.loadLibrary("/home/pedro.carvalho/workspace/WwRadiantech/lib/nfosock.so", NFOSock.class);
	SCANPARMS.ByReference parms = new SCANPARMS.ByReference();
	short nPort = 4997; //porta que estou utilizando para comunicacao com o equipamento
	int ret = 0;
	String IP = "192.168.1.57"; //ip no qual se encontra o equipamento
	ret = nfosock._Z8GetParmsP12ST_SCANPARMSPcs(parms, IP, nPort);
	System.out.println("sorType: "+parms.sortype); //Exemplo de parametro que ao ser comparado  obtido errado
}
What could I be doing wrong? Can someone help me with my problem?
Thanks in advance,

--
Pedro