JNA Passing Structure By Reference Help
Posted
by tyeh26
on Stack Overflow
See other posts from Stack Overflow
or by tyeh26
Published on 2009-06-01T13:49:49Z
Indexed on
2010/06/10
13:23 UTC
Read the original article
Hit count: 217
Hi all, I'm trying to use JNA to talk over a USB device plugged into the computer. Using Java and a .dll that was provided to me. I am having trouble with the Write function:
C code:
typedef struct {
unsigned int id;
unsigned int timestamp;
unsigned char flags;
unsigned char len;
unsigned char data[16];
} CANMsg;
CAN_STATUS canplus_Write(
CANHANDLE handle, //long
CANMsg *msg
);
Java Equivalent:
public class CANMsg extends Structure{
public int id = 0;
public int timestamp = 0;
public byte flags = 0;
public byte len = 8;
public byte data[] = new byte[16];
}
int canplus_Write(NativeLong handle, CANMsg msg);
I have confirmed that I can open and close the device. The close requires the NativeLong handle, so i am assuming that the CANMsg msg is the issue here. I have also confirmed that the device works when tested with C only code.
I have read the the JNA documentation thoroughly... I think. Any pointers. Thanks all.
© Stack Overflow or respective owner