JNA调用dll出现乱码,怎么解决啊

tufeiCC 2011-10-15 03:00:43
传输网络貌似是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那边是无法再改的.人家厂商提供的!
...全文
527 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
tufeiCC 2011-10-15
  • 打赏
  • 举报
回复
IMSI=[B@1f66cff strIMSI=6澿K^�
IMSI=[B@1f66cff strIMSI=6澿K^�

51,397

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧