0

我有一个问题让我困惑了几天。我想从智能卡发送一个大于 255 字节的数据到主机应用程序。我在某个网站上看到了一段代码。这段代码如下:

private void sendData(APDU apdu) {
        // work out how many bytes to send this time and how many will be left
        BUF_IN_OFFSET[0] = 0;

        short remain = (short) ((short)372 - BUF_IN_OFFSET[0]);
        boolean chain = remain > MAX_APDU;
        short sendLen = chain ? MAX_APDU : remain;
        Util.arrayCopy(data, (short) 0, apdu.getBuffer(), (short) 0, sendLen);
        // Get ready to send
        apdu.setOutgoing();
        apdu.setOutgoingLength((short)sendLen);
        apdu.sendBytesLong(apdu.getBuffer(), BUF_IN_OFFSET[0], sendLen);

         // Check to see if there are more APDU's to send
        if (chain) {
            BUF_IN_OFFSET[0] += sendLen; // count the bytes sent
            remain -=sendLen;
            ISOException.throwIt((short)((ISO7816.SW_BYTES_REMAINING_00) + remain));

        } else {
            BUF_IN_OFFSET[0] = 0; // no more bytes to send
        }


    }

当我将 apdu 发送到 netbeans 模拟器中的卡时,它会正确发送 6100。但是当我将它发送到真实卡(smartcafe 3.2)卡时。它寄给我9000。这意味着在模拟器中它可以工作,但通过真卡它不起作用。我猜它与协议 T=0 或 T=1 有关。我没有找到任何 T=1 的代码。上面的代码适用于 T=0。

提前致谢。

4

1 回答 1

0

'6100' sounds like a contradiction in the terms. It tells the reader to fetch some data, with lengh available being naught. I believe the real card will actually turn this into a 9000 which is the proper execution status code when no data is available.

于 2013-10-22T12:57:47.187 回答