ACR122u直接通讯无反应 [英] ACR122u direct communication no response

查看:125
本文介绍了ACR122u直接通讯无反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过发送直接命令来使用Java访问我的ACR122u.奇怪的是我没有任何响应,也没有错误.这是我的代码:

I'm trying to access my ACR122u with java by sending direct command. The weird thing is i don't get any response and no errors.. This is my code:

final static int IOCTL_SMARTCARD_ACR122_ESCAPE_COMMAND = 0x003136B0;

.....

List<CardTerminal>  terminals   = null; 
TerminalFactory factory         = TerminalFactory.getDefault();
terminals                       = factory.terminals().list();

CardTerminal terminal   = terminals.get(0);
Card card               = terminal.connect("direct");

CardChannel channel     = card.getBasicChannel();

byte[] commandAPDU      = {(byte) 0xD4, 0x06, 0x63, 0x05, 0x63, 0x0D, 0x63, 0x38 }; 
byte[] responseAPDU     = card.transmitControlCommand(IOCTL_SMARTCARD_ACR122_ESCAPE_COMMAND, commandAPDU );             

System.out.println(bytesToHex(responseAPDU) + "...");

有人知道这种情况的原因吗?

Is there anyone who knows the cause of this situation?

非常感谢!

推荐答案

最后,我有了解决方案.如果有其他人也有同样的问题,我会回答我自己的问题.

Finally, i have the solution. I will answer my own question in case there are other people with the same problem.

错误是我只在这里发送消息.使用new CommandAPDU(),您已经定义了类,INS,P1,P2.除此之外,您不需要定义Lc 因为javac会为我们完成此操作.对于transmitControlCommand,您确实需要定义Lc.因此,有了这些知识,新的(有效的)代码就是:

The fault was that i only send the message here. With new CommandAPDU() you already define the Class,INS, P1, P2. Besides that you don't need to define the Lc because javac will do this for us. With transmitControlCommand you do need to define the Lc. So with this knowledge the new (working) code is:

List<CardTerminal>  terminals   = null; 
TerminalFactory factory         = TerminalFactory.getDefault();
terminals                       = factory.terminals().list();

CardTerminal terminal   = terminals.get(0);
Card card               = terminal.connect("direct");

CardChannel channel     = card.getBasicChannel();

//Read register
byte[] commandAPDU1     = {(byte)0xFF,0x00,0x00,0x00,0x08,  (byte)0xD4, 0x06, 0x63, 0x05, 0x63, 0x0D, 0x63, 0x38 }; 
byte[] responseAPDU1    = card.transmitControlCommand(IOCTL_SMARTCARD_ACR122_ESCAPE_COMMAND, commandAPDU1 );                

System.out.println(bytesToHex(responseAPDU1) + "...");
//Response: D5070707059000...

这篇关于ACR122u直接通讯无反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆