私はJNAに少し問題があります。
私のコード:
ヘッダー c:
#ifndef IOPROTOCOL_H_INCLUDED
#define IOPROTOCOL_H_INCLUDED
typedef signed char INT8;
typedef short INT16;
typedef int INT32;
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
/* Types d'IO */
typedef enum { IOT_U1, IOT_U2, IOT_U8, IOT_I8, IOT_U16, IOT_I16, IOT_U32, IOT_I32, IOT_F32, IOT_STRING, IOT_MAX } IoTypeE;
typedef union {
INT32 i;
UINT32 u;
float f;
char * s;
} Value;
typedef struct {
int (*Read) (char *rxbuf, int rxlen, UINT8 interTo);
int (*Write) (char *txbuf,int txlen);
int (*FunctionResponse) (int address, Value value, IoTypeE type);
int (*SendTraceRoute) (char * trace);
} DeviceFuncT;
int readTrame( DeviceFuncT *deviceFunct, UINT32 function, UINT32 address, UINT32 countAddress, UINT32 slave, UINT32 type);
int writeTrame(DeviceFuncT *deviceFunct, UINT32 function, UINT32 address, Value value, UINT32 type, UINT32 slave);
#endif // IOPROTOCOL_H_INCLUDED
DeviceFuncT は Java で作成され、関数 readTrame または writeTrame のパラメーターで渡されます。
私は C で呼び出します(dll ^^) DeviceFuncT->(*Read) (char *rxbuf, int rxlen, UINT8 interTo);
ジャバでは、
public static interface ReadFunct extends com.sun.jna.Callback{
int invoke(String rxbuf, int rxlen, byte interto);
}
だからchar* rxbuf == String rxbu
f
関数を終了する前に Java で rxbuf を処理する必要があり、その後 rxbux en C を処理しますが、C の関数で Java に値が設定されていません...
この問題を解決できますか? お願いします :)。
私の説明で申し訳ありません。
ありがとうございました。