send(ins:p1:p2:data:le:)
Synchronously transmits an APDU command to the card and returns the response.
Declaration
func send(ins: UInt8, p1: UInt8, p2: UInt8, data: Data? = nil, le: Int? = nil) throws -> (sw: UInt16, response: Data)Parameters
- ins:
The instruction code.
- p1:
The first parameter.
- p2:
The second parameter.
- data:
The data field of the APDU, or
nilif no input data field should be present—for example, acase1orcase2APDU.The length of the data serves as
Lcfield of the APDU. - le:
The expected number of bytes to be returned, or nil if no output data are expected—for example, a
case1orcase3APDU. Pass0to accept as many bytes as the card provides.
Return Value
A tuple containing the result code as contained in the first two bytes (SW1SW2) of the returned data, and the returned data excluding the first two bytes.