How do i map this function with JNA:
Delphi Dll Function Code:
function send_command (const command : byte; var size : byte; var data : pbyte) : integer; stdcall external 'comunication.dll';
Use example in Delphi Example Program:
send_command (cmdCLOCK_ADJUST, tam, pb);
Where:
const
cmdCLOCK_ADJUST = $18;
var
tam : byte;
pb, p : pbyte;
begin
...
tam = 7;
p:= pb;
for i:= 1 to tam do
begin
p^:= Dados [i];
inc (p)
end;
send_command (cmdCLOCK_ADJUST, tam, pb);
freemem (pb);
...
end
The int value that is returned can be 0 for Error or 1 for right execution;
My suggestion is:
JNA Java Function Code:
int send_command(byte command, byte size, byte[] data);
The problem is that the function of the dll returns 0. I also tried other Datatypes, but it hasn't worked jet. I think the problem is that the dll function can't write to the parameter data.
dataparameter is the problem. the callee passes a pointer out? Really. Please show sample calling code in Pascal, or the documentation. - David Heffernandatais a var parameter of typepbyte, one assumes that the callee allocates the memory. Your code contradicts that. On the face of it, the problem is actually with the Delphi code which is wrong. - David Heffernan