/// <summary> /// Extension method to SmartCardConnection class similar to Transmit asyc method, however it accepts PCSC SDK /// commands. /// </summary> /// <param name="apduCommand"> /// APDU command object to send to the ICC /// </param> /// <param name="connection"> /// SmartCardConnection object /// </param> /// <returns>APDU response object of type defined by the APDU command object</returns> public static async Task <Iso7816.ApduResponse> TransceiveAsync(this SmartCardConnection connection, ApduCommand apduCommand) { var apduRes = (Iso7816.ApduResponse)Activator.CreateInstance(apduCommand.ApduResponseType); var responseBuf = await connection.TransmitAsync(apduCommand.GetBuffer().AsBuffer()); apduRes.ExtractResponse(responseBuf.ToArray()); return(apduRes); }
/// <summary> /// Extension method to SmartCardConnection class similar to Transmit asyc method, however it accepts PCSC SDK /// commands. /// </summary> /// <param name="apduCommand"> /// APDU command object to send to the ICC /// </param> /// <param name="connection"> /// SmartCardConnection object /// </param> /// <returns>APDU response object of type defined by the APDU command object</returns> public static async Task <Iso7816.ApduResponse> TransceiveAsync(this SmartCardConnection connection, ApduCommand apduCommand) { var apduRes = (Iso7816.ApduResponse)Activator.CreateInstance(apduCommand.ApduResponseType); if (!IsFirstConnection) { await Task.Delay(500); } var responseBuf = connection.Transceive(apduCommand.GetBuffer()); apduRes.ExtractResponse(responseBuf.ToArray()); return(apduRes); }