Transmits the command APDU stored in the command ByteBuffer and receives
the reponse APDU in the response ByteBuffer.
The command buffer must contain valid command APDU data starting
at command.position()
and the APDU must be
command.remaining()
bytes long.
Upon return, the command buffer's position will be equal
to its limit; its limit will not have changed. The output buffer
will have received the response APDU bytes. Its position will have
advanced by the number of bytes received, which is also the return
value of this method.
The CLA byte of the command APDU is automatically adjusted to
match the channel number of this CardChannel.
Note that this method cannot be used to transmit
MANAGE CHANNEL
APDUs. Logical channels should be managed
using the Card.openLogicalChannel() and CardChannel.close() methods.
See transmit() for a discussion of the handling
of response APDUs with the SW1 values 61
or 6C
.
Returns:
the length of the received response APDU
Parameters:
- command - the buffer containing the command APDU
- response - the buffer that shall receive the response APDU from
the card
Throws:
- IllegalStateException - if this channel has been
{@linkplain #close closed} or if the corresponding Card has been
{@linkplain Card#disconnect disconnected}.
- NullPointerException - if command or response is null
- ReadOnlyBufferException - if the response buffer is read-only
- IllegalArgumentException - if command and response are the
same object, if response
may not have
sufficient space to receive the response APDU
or if the APDU encodes a MANAGE CHANNEL
command
- CardException - if the card operation failed