Package com.dalsemi.onewire.container
Class ResponseAPDU
java.lang.Object
com.dalsemi.onewire.container.ResponseAPDU
A
According to ISO 7816-4, a
ResponseAPDU
represents an Application Protocol Data Unit
(APDU) received from the smart card in response to a previous
CommandAPDU
. A ResponseAPDU
consists of an optional
body and a mandatory Status Word (SW). According to ISO 7816-4, a
ResponseAPDU
has the following
format:
DATA | STATUS WORD [data] | SW1 SW2where
data
is an optional byte array of data received from the smart card.SW1
is the status byte 1 containing command processing status.SW2
is the status byte 2 containing command processing qualifier.
Usage
byte[] buffer = {(byte)0x01, (byte)0x02, (byte)0x90, (byte)0x00}; ResponseAPDU rapdu = new ResponseAPDU(buffer);
OneWireContainer16 owc16 = new OneWireContainer16(adapter, address); byte[] buffer = {(byte)0x90, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03}; CommandAPDU capdu = new CommandAPDU(buffer); ResponseAPDU rapdu = owc16.sendAPDU(capdu, runTime);
Additional information
- See Also:
-
CommandAPDU
com.dalsemi.onewire.container.OneWireContainer16
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
byte array containing the entireResponseAPDU
protected int
length of thisResponseAPDU
currently in theapduBuffer
-
Constructor Summary
ConstructorsConstructorDescriptionResponseAPDU
(byte[] buffer) Constructs a newResponseAPDU
with the given buffer byte array. -
Method Summary
Modifier and TypeMethodDescriptionfinal byte
getByte
(int index) Gets the byte value at the specified offset inapduBuffer
.final byte[]
getBytes()
Gets a byte array holding thisResponseAPDU
apduBuffer
.byte[]
getData()
Gets the data field of thisResponseAPDU
.final int
Gets the length ofapduBuffer
.final int
getSW()
Gets the value of SW1 and SW2 as an integer.final byte
getSW1()
Gets the value of SW1.final byte
getSW2()
Gets the value of SW2.toString()
Gets a string representation of thisResponseAPDU
.
-
Field Details
-
apduBuffer
protected byte[] apduBufferbyte array containing the entireResponseAPDU
-
apduLength
protected int apduLengthlength of thisResponseAPDU
currently in theapduBuffer
-
-
Constructor Details
-
ResponseAPDU
public ResponseAPDU(byte[] buffer) Constructs a newResponseAPDU
with the given buffer byte array. The internalapduLength
is set to the length of the buffer passed.- Parameters:
buffer
- the byte array with data for the internalapduBuffer
- Throws:
RuntimeException
- thrown whenbuffer
length <2
.- See Also:
-
-
Method Details
-
getData
public byte[] getData()Gets the data field of thisResponseAPDU
.- Returns:
- a byte array containing this
ResponseAPDU
data field
-
getSW
public final int getSW()Gets the value of SW1 and SW2 as an integer. It is computed as:
(((SW1 << 8) & 0xFF00) | (SW2 & 0xFF))
- Returns:
(((SW1 << 8) & 0xFF00) | (SW2 & 0xFF))
as an integer
-
getSW1
public final byte getSW1()Gets the value of SW1.- Returns:
- value of SW1 as a byte
-
getSW2
public final byte getSW2()Gets the value of SW2.- Returns:
- value of SW2 as a byte
-
getByte
public final byte getByte(int index) Gets the byte value at the specified offset inapduBuffer
.- Parameters:
index
- the offset in theapduBuffer
- Returns:
- the value at the given offset, or
-1
if the offset is invalid - See Also:
-
getBytes
public final byte[] getBytes()Gets a byte array holding thisResponseAPDU
apduBuffer
.- Returns:
apduBuffer
copied into a new array- See Also:
-
getLength
public final int getLength()Gets the length ofapduBuffer
.- Returns:
apduLength
the length of theapduBuffer
currently stored
-
toString
Gets a string representation of thisResponseAPDU
.
-