JNA调用dll出现乱码,怎么解决啊
传输网络貌似是GPRS无限网络
提供的函数是: Int __stdcall Ast_RTGD_Receive(__int64* v1,int* v2,char* v3,int* v4,char* v5);
说明: 该方法的所有参数都是为Out输出参数
JNA接口封装:
public interface RtuService extends StdCallLibrary{
RtuService rtuService = (RtuService)Native.loadLibrary("Ascend_RTGD", RtuService.class);
public int Ast_RTGD_Receive(byte[] IMSI,byte[] remainedNum,byte[] time,byte[] msgLenth,byte[] content);
}
调用: 在线程里面 关键代码...
byte[] IMSI=new byte[64];
byte[] remainedNum=new byte[64];
byte[] time=new byte[20];
byte[] msgLength=new byte[64];
byte[] content=new byte[1024];
int result = RtuService.rtuService.Ast_RTGD_Receive(IMSI, remainedNum, time, msgLength, content);
if(result>=0){
System.out.println("--有数据收到--");
String strIMSI=new String(IMSI);
String strNum=new String(remainedNum);
String strTime=new String(time);
String strMsg=new String(msgLength);
String strContent=new String(content);
System.out.println("IMSI="+IMSI+"\tstrIMSI="+strIMSI);
System.out.println("remainedNum="+remainedNum+"\tstrNum="+strNum);
System.out.println("time="+time+"\tstrTime="+strTime);
System.out.println("msgLength="+msgLength+"\tstrMsg="+strMsg);
System.out.println("content:"+content+"\tstrContent="+strContent);
}
------------------------割---割---割---割---割---割---割---割---割---割-----------------------
我开始用的是Jnative,也是这样的情况,后来想就用JNA,貌似也是这样的情况,网络上还有说用指针,但是jna的指针,貌似不怎么理解,忘高手们指点指点,或者来个实际点的案例!
当有值收到的的时候,就出现乱码:如图--图片怎么发...???乱码复制上来不跟原来的不对了啊[哭][哭][哭][哭]
反正就是乱码一通...求高手指点,怎么解决! dll那边是无法再改的.人家厂商提供的!