C API for BALTECH SDK

§ brp_VHL_ExchangeLongAPDU()

brp_errcode brp_VHL_ExchangeLongAPDU ( brp_protocol  protocol,
brp_CardType  AssumedCardType,
bool  Reset,
bool  ContinueCmd,
brp_buf  Cmd,
size_t  Cmd_len,
bool *  ContinueResp,
brp_buf Resp,
size_t *  Resp_len,
brp_mempool mempool 
)

This command sends basic Inter-Industry commands to the currently selected card in accordance with the ISO/IEC 7816-4 standard. This command has the same functionality as VHL.ExchangeAPDU, but it allows the application to send commands and receive responses larger than the reader's internal protocol buffers by splitting the command. See the Sys.GetBufferSize command documentation for more details about the reader's internal buffers.

When splitting a command into multiple blocks, this command has to be repeated to transfer the APDU as Cmd parameter block by block. As long as the ContinueCmd parameter is set to true , the reader will wait for further output before transmitting the APDU. The last block of the APDU can be sent by setting ContinueCmd to false. The reader will only start transferring the response once the last block of the APDU command has been sent. If the response is bigger than one communication frame, it is split in the same manner as the command with the ContinueResp flag set to true as long as the response has not been completely received. The command is completely exchanged when the ContinueResp flag is set to false.

A command transfer can be broken if the reader returns an error status code or by starting a new VHL.ExchangeLongAPDU sequence. When starting a new APDU the Reset parameter of the first VHL.ExchangeLongAPDU call always has to be set to true (it does not matter if the command breaks a preceding VHL.ExchangeLongAPDU or not).

The splitting of a command into blocks is determined by the size of the reader's sending and receiving buffers. The size of these buffers can be obtained by the Sys.GetBufferSize command. A frame must not exceed MaxSendSize - 4 or TotalSize - 8.

The sum of the amount of data transmitted and received through Cmd and Resp has to be smaller than or equal to TotalSize .

The following example shows how a 1000 Byte APDU Command which returns a 500 Byte response is transferred to a reader having a buffer of 400 Bytes (i.e. for which Sys.GetBufferSize returns a 400 Byte MaxSendSize and a 400 Byte TotalSize ):

  1. ExchangeLongAPDU(Reset=True, ContinueCmd=True, Cmd=bytes 0..391) >= ContinueResp=True, Resp=empty
  2. ExchangeLongAPDU(Reset=False, ContinueCmd=True, Cmd=bytes 392..783) >= ContinueResp=True, Resp=empty
  3. ExchangeLongAPDU(Reset=False, ContinueCmd=False, Cmd=bytes 784..999) >= ContinueResp=True, Resp=0..175
  4. ExchangeLongAPDU(Reset=False, ContinueCmd=False, Cmd=empty) >= ContinueResp=False, Resp=176..499
Parameters
[in]protocolused to execute the command
[in]AssumedCardTypeForces the reader to assume a specified card type. By default (i.e. CardType = 0x00), the reader uses the card type detected by the VHL.Select command.
[in]ResetIf true , restart a new APDU.
[in]ContinueCmdIf true , the content of Cmd will be appended to the last command(s).
[in]CmdAPDU Command data.
[in]Cmd_len
[out]ContinueRespIf true , the content of Resp will be appended to the response of the last command(s)
[out]RespAPDU response data.
[out]Resp_len
[in]mempoolis used to store response data. Maybe NULL to use an internal mempool, in this case the data is only available until another command uses the internal mempool