22 messages in net.java.dev.jna.usersRe: [jna-users] Structure by value an...
FromSent OnAttachments
Edroaldo Lummertz da RochaNov 7, 2008 3:21 pm 
Timothy WallNov 7, 2008 4:44 pm 
Edroaldo Lummertz da RochaNov 10, 2008 6:07 am 
Timothy WallNov 10, 2008 6:34 am 
Edroaldo Lummertz da RochaNov 10, 2008 6:59 am 
Timothy WallNov 10, 2008 7:57 am 
Edroaldo Lummertz da RochaNov 10, 2008 8:38 am 
Timothy WallNov 10, 2008 10:40 am 
Edroaldo Lummertz da RochaNov 10, 2008 12:17 pm 
Timothy WallNov 10, 2008 1:46 pm 
Edroaldo Lummertz da RochaNov 10, 2008 1:57 pm 
Timothy WallNov 10, 2008 6:27 pm 
Edroaldo Lummertz da RochaNov 11, 2008 3:25 am 
Edroaldo Lummertz da RochaNov 11, 2008 3:40 am 
Edroaldo Lummertz da RochaNov 12, 2008 6:42 am 
Edroaldo Lummertz da RochaNov 14, 2008 3:46 am 
Timothy WallNov 14, 2008 4:37 am 
Edroaldo Lummertz da RochaNov 14, 2008 9:41 am 
Edroaldo Lummertz da RochaNov 14, 2008 10:05 am 
Timothy WallNov 14, 2008 11:31 am 
Edroaldo Lummertz da RochaNov 17, 2008 4:35 am 
Timothy WallNov 17, 2008 5:17 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Structure by value and referenceActions...
From:Edroaldo Lummertz da Rocha (edro@gmail.com)
Date:Nov 14, 2008 10:05:41 am
List:net.java.dev.jna.users

I think that it is strange, but in this method: rettem=K_Move_Data_HL(&hdev,FALSE,33,&AICp[0],-1,1,"_aicreg",Sym) The &AICp[0] is a pointer correct?

and, in my Java code I have:

ret = sranger.K_Move_Data_HL(hDev, 0, nbWords, AICp, dspAddress, 1, "_aicreg", Sym);

The AICp in not a pointer, is a copy of my array AICp correct?

How can I solve this problem? Is there any way to do it in JNA? Pass a pointer to a array and not the array to the function?

Thanks!!

I need to develop a code to the Signal Ranger Digital Signal Processing boad. The fabricant of these board provided a DLL (SRangel_HL.dll) for acess the DSP. * These DLL has the following methods:*

int Initialize_HL(PCHAR BoardID,void ** hDev);

int DriverClose_HL(void ** hDev);

int K_Move_Data_HL(void ** hDev,BOOL RW,unsigned short Nb_Words, unsigned short * Buffer,signed long DSPAddress, int MemSpace,char * Symbol,struct HSymTbl SymTable);

int LoadUser_HL(void ** hDev,char * FilePath,struct HSymTbl * pSymTable);

int ExecUser_HL(void ** hDev,signed long DSPAddress,char * Symbol, struct HSymTbl SymTable);

Find_Label_HL(char *label, struct HSymTbl ptrSymTbl);

There is two other functions, but I just need it. The fabricant provides a Visual C++ source code, where only these functions are present, so, for while, I just need that it works.

*My Java interface is:*

public interface SignalRangerInterface extends Library { public int Initialize_HL(String boardId, PointerByReference hDev);

public int LoadUser_HL(PointerByReference hDev, String filePath, SignalRanger.HSymTbl pSymTable);

public int K_Move_Data_HL(PointerByReference hDev, int rw, short nbWords, short[] buffer, NativeLong dSPAdrress, int memSpace, String symbol, SignalRanger.HSymTbl.ByValue symTable);

public int ExecUser_HL(PointerByReference hDev, NativeLong dSPAddress, String symbol, SignalRanger.HSymTbl.ByValue pSymTable);

public int Load_Kernel_HL(PointerByReference hDev);

public int DriverClose_HL(PointerByReference hDev);

public int Find_Label_HL(String label, SignalRanger.HSymTbl.ByValue symTable); }

All thes function returns 0, when everything is right, and negative values when somethig is wrong, for example, -1 when the Initizalize_HL() cannot find the board.

*I also need to use a struct, define in C++ as:*

struct HSymTbl { unsigned long pSymTbl; unsigned long length; };

This Structure is defined inside my main class. *The Java Structure is:*

public static class HSymTbl extends Structure { public static class ByValue extends HSymTbl implements Structure.ByValue{

} public NativeLong pSymTbl; public NativeLong length; }

*In Visual C++ code, the fabricant does it:*

void *hdev; struct HSymTbl Sym;

so, I call (in C++) Initialize_HL("Ranger0", &hdev);.

The next call is c++ is: unsigned short AICp[34];

AICp[0]=8;AICp[1]=25168;AICp[2]=16976;AICp[3]=8784;AICp[4]=592;AICp[5]=25168;

AICp[6]=16976;AICp[7]=8784;AICp[8]=592;AICp[9]=25601;AICp[10]=17409;AICp[11]=9217; AICp[12]=1025;AICp[13]=25601;AICp[14]=17409;AICp[15]=9217;AICp[16]=1025;AICp[17]=26113; AICp[18]=17921;AICp[19]=9729;AICp[20]=1537;AICp[21]=26113;AICp[22]=17921;AICp[23]=9729; AICp[24]=1537;AICp[25]=26639;AICp[26]=18447;AICp[27]=10255;AICp[28]=2063;AICp[29]=26639; AICp[30]=18447;AICp[31]=10255;AICp[32]=2063;

char path[]="Demo2_sr.out";

ret=LoadUser_HL(&hdev,path,&Sym);

if LoadUser_HL is ok, I call the function:

rettem=K_Move_Data_HL(&hdev,FALSE,33,&AICp[0],-1,1,"_aicreg",Sym);

*In my Java code:*

PointerByReference hDev = new PointerByReference(); HSymTbl.ByValue Sym = new HSymTbl.ByValue(); Initialize_HL("Ranger0", hDev);

The return value is 0, indicating that is ok!

After, I need to load my DSP code inside the board. My dsp code is on the Demo2_sr.out. I se LoadUser_HL() for this;

short nbWords = 33; NativeLong dspAddress = -1; int ret = 0; String path = "Demo2_sr.out";

value = sranger.LoadUser_HL(hDev, path, Sym);

Here, the function needs to receive a pointer to HSymTable. The return value is 0, and it indicate the it is ok, but looks like the "by" (that represents my Structure) is not be initialized. I do not know what is happening here, because the function says the everything is correct. But, when I call the next method that I need, I have a negative return value and is not ok. This function is:

ret = sranger.K_Move_Data_HL(hDev, 0, nbWords, AICp, dspAddress, 1, "_aicreg", Sym);

where AICp is:

short AICp[] = new short[33];

AICp[0]=8;AICp[1]=25168;AICp[2]=16976;AICp[3]=8784;AICp[4]=592;AICp[5]=25168;

AICp[6]=16976;AICp[7]=8784;AICp[8]=592;AICp[9]=25601;AICp[10]=17409;AICp[11]=9217; AICp[12]=1025;AICp[13]=25601;AICp[14]=17409;AICp[15]=9217;AICp[16]=1025;AICp[17]=26113; AICp[18]=17921;AICp[19]=9729;AICp[20]=1537;AICp[21]=26113;AICp[22]=17921;AICp[23]=9729; AICp[24]=1537;AICp[25]=26639;AICp[26]=18447;AICp[27]=10255;AICp[28]=2063;AICp[29]=26639; AICp[30]=18447;AICp[31]=10255;AICp[32]=2063;

I think that it defines my problem.

I think that the problem is in the pointer refnum and Sym. Do use a void *hDev is the same that use PointerByReference hDev? In call in C++: Initialize_HL("Ranger0", &hdev); is equivalent to Java Initialize_HL("Ranger0", hDev); considering the previous initializations

The Visual C++ call

rettem=K_Move_Data_HL(&hdev,FALSE,33,&AICp[0],-1,1,"_aicreg",Sym) is same of Java call: ret = sranger.K_Move_Data_HL(hDev, 0, nbWords, AICp, dspAddress, 1, "_aicreg", Sym);

Of some way, looks like that the Sym Structure is not initialized when I call LoadUser_HL(), but I do not know why.

Thanks so much for help!!!

2008/11/14 Timothy Wall <twal@dev.java.net>

You might summarize what you've done so far and at what point you're

seeing failure. Include as much relevant details as possible. Pretend that you're asking the question for the first time, since readers of this list might not have quick access to something you posted a while ago.

You're a computer scientist. Posit some theories.

On Nov 14, 2008, at 6:47 AM, Edroaldo Lummertz da Rocha wrote:

Sorry, but I cannot do it works. I cannot find where is the problem. Does

somebody help me?

2008/11/12 Edroaldo Lummertz da Rocha <edro@gmail.com> Hello, is there any other problem? What can I do?

Thanks!!!

2008/11/11 Edroaldo Lummertz da Rocha <edro@gmail.com> Sorry, my new HSymTbl is:

public static class HSymTbl extends Structure { public static class ByValue extends HSymTbl implements Structure.ByValue{

} public NativeLong pSymTbl; public NativeLong length; } Is not working.

Thanks so much!!!

2008/11/11 Edroaldo Lummertz da Rocha <edro@gmail.com>

I did the alterations, but did not work. My new HSymTbl is:

public static class HSymTbl extends Structure { public static class ByValue extends HSymTbl implements Structure.ByValue{

} public long pSymTbl; public long length; }

this class is inside my main class.

Thanks!!

2008/11/11 Timothy Wall <twal@dev.java.net>

C unsigned long => Java NativeLong

On Nov 10, 2008, at 4:58 PM, Edroaldo Lummertz da Rocha wrote:

In C++

struct HSymTbl { unsigned long pSymTbl; unsigned long length; };

Java version

public static class HSymTbl extends Structure { public static class ByValue extends HSymTbl implements Structure.ByValue{

} public long pSymTbl; public long length; }