我對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);
在java中,
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,但我不到貨具有值在Java中設置C中的函數...
你能幫助解決這個問題嗎?請 :)。
對不起,我的說明。
謝謝。