I have a big byte array (it\'s 320 bytes) on my Java Card and I want to send its data in one APDU response.
So, I implemented ExtendedLength
An unhandled exception was thrown by your applet because you called sendBytes() without calling setOutgoing() and setOutgoingLength() first.
Also, I haven't really counted the length of longData but make sure that its length is a multiple of 32 bytes otherwise Util.arrayCopyNonAtomic() will throw an ArrayIndexOutOfBoundsException and will make your applet throw 6F00.
Maybe you can try it this way:
apdu.setOutgoing(); apdu.setOutgoingLength(toSend); while (toSend > 0) { Util.arrayCopyNonAtomic(longData, (short) (counter * 32), buffer, (short) 0, (short) 32); apdu.sendBytes((short) 0, (short) 32); toSend = (short) (toSend - 32); counter = (byte) (counter + 1); }
Or much better, instead of doing a while loop:
apdu.setOutgoing(); apdu.setOutgoingLength(toSend); apdu.sendBytesLong(longData, (short)0, toSend);