public ApduResponse SendCommand(ApduCommand apduCommand) { CardQ.EnqueueToInput(new CardRequest(apduCommand, CardinterfaceServiceRequestEnum.ADPU)); CardResponse response = CardQ.DequeueFromOutput(false); //this will poll indefinetely return(response.ApduResponse); }
private async Task StartServicingeQ() { //run for as long as card reader is active while (1 == 1) { try { CardRequest cardRequest = CardQ.DequeueFromInput(false, true); if (cardRequest == null) //timeout { if (cancellationTokenForCardInterfaceManager.Token.IsCancellationRequested) { cancellationTokenForCardInterfaceManager.Dispose(); break; } else { continue; } } CardResponse response; try { response = new CardResponse(await Transceive(cardRequest.ApduCommand), CardInterfaceServiceResponseEnum.RA); } catch { ApduResponse apduRes = new ApduResponse(); byte[] dataOut = new byte[] { 0x00, 0x00 }; apduRes.Deserialize(dataOut); response = new CardResponse(apduRes, CardInterfaceServiceResponseEnum.L1RSP); } CardQ.EnqueueToOutput(response); } catch (Exception ex) { StopServiceQProcess(); OnExceptionOccured(ex); } } }