I need to develop a Java program with a Delphi DLL, but a problem is:
I mapped in JNA as follows:
- Delphi function:
function send_command (const command : byte; var size : byte; var data : pbyte) : integer; stdcall external 'comunication.dll';
- Java function:
public int send_command(byte command, ByteByReference size, PointerByReference data);
The function returned 1 (Success result) but I can´t get the value in data variable.
How can I get the value in data ?
In Delphi Test Program, the function is called as follows:
const
cmdREAD_STATUS = $17;
procedure TForm1.ReadStatus1Click(Sender: TObject);
var
Data,
p : pbyte;
tam : byte;
i,
result: integer;
saux : string;
begin
getmem (Data, 40);
tam:= 0;
result:= send_comand (cmdREAD_STATUS, tam, Data);
if result= 1 then
begin
memo1.Lines.add ('Command OK');
i:= 0;
sAux:= '';
p:= Data;
while (i < Tam) do
begin
sAux:= sAux + inttohex (p^, 2)+' ';
if length (sAux) > 59 then
begin
memo1.Lines.add (SAux);
sAux:= '';
end;
inc (p);
inc (i);
end;
if sAux <> '' then
memo1.Lines.add (SAux);
end
else
memo1.Lines.add ('Result: '+inttostr(result)+' in command execution');
freemem (Data);
end;
data, or the Java code that tried to read fromdata? You need to be more specific. - Remy Lebeau