Found my mistake. setIncomingAndReceive()
returns the size of the transferred array (10 bytes in my case), i.e. instead of if ( ( numBytes != PayloadSize ) || (byteRead != 1) )
there should be if ( ( numBytes != PayloadSize ) || (byteRead != PayloadSize) )
. And in addition, I also specified the offset inside the buffer incorrectly (should be Util.arrayCopy(buf, ISO7816.OFFSET_CDATA, data, (short) 0, PayloadSize)
).