The command smartcard.transmitAPDU is used to send an APDU command to the smart card.
The parameters should receive only hexadecimal strings.
- datafield [string]
Hexadecimal datafield of an APDU command containing additional information. Optional field: if not used will default to 00
- header [string]
APDU hexadecimal header, composed by CLA + INS + P1 + P2. Required field.
- LC [string]
Datafield parameter size in hexadecimal. Optional field: if not used will default to 00.
- LE [string]
Expected size of the response in hexadecimal. Optional field: if not used will default to 00. If the response size is greater than the two obligatory bytes SW1 and SW2, it is necessary to specify the size of the response in this field.
- slot [string]
slot that was opened with smartcard.startreader
- variabledatafieldresponse [string]
Variable that will store the hexadecimal return value of the APDU command.
- variableSW [string]
Variable that will store the obligatory two hexadecimal bytes from the APDU command.
- variablereturn [integer]
Return of the command, which:
- -2: Error while sending the command to the card
- -1: Invalid slot
- 1: Command successfully sent
In the example above, a while loop waits for the command smartcard.insertedcard to identify a card insertion.
Once the card is inserted, the command smartcard.startreader initializes the reader and the card by sending an ATR command; then the command smartcard.transmitAPDU is executed. In the end the result is displayed using the command display.