JNA を使用して、コンピューターに接続された USB デバイスを介して通信しようとしています。Java と提供された .dll を使用します。書き込み機能に問題があります:
C コード:
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:
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);
開閉できることを確認しております。閉じるには NativeLong ハンドルが必要なので、ここでは CANMsg メッセージが問題であると想定しています。また、C のみのコードでテストした場合、デバイスが動作することも確認しています。
私はJNAのドキュメントを徹底的に読みました...と思います。任意のポインター。皆さんありがとう。