private static extern int SCardTransmit([In] IntPtr cardHandle,
                                         [In, Out] ref IoRequest sendPci,
                                         [In] byte[] inputBuffer,
                                         [In] int sendLength,
                                         [In, Out] ref IoRequest recvPci,
                                         [Out] byte[] outputBuffer,
                                         [In, Out] ref int recvLength);
        public static void Transmit(IntPtr connectionHandle, ref IoRequest inputPci, ref IoRequest outputPci, byte[] inputData, ref byte[] outputData, out int dataSize)
        {
            var outputBufferSize = outputData.Length;
            var retCode          = SCardTransmit(connectionHandle, ref inputPci, inputData, inputData.Length, ref outputPci, outputData, ref outputBufferSize);

            if (SuccessCode != retCode)
            {
                throw ExceptionHelper.PrepareException(retCode, "SCardTransmit");
            }

            dataSize = outputBufferSize;
        }
예제 #3
0
 private void Initialize()
 {
     // startup state
     Address.IsEnabled = true;
     BusAcknowledge.Write(DigitalLevel.High);
     Halt.Write(DigitalLevel.High);
     IoRequest.Write(DigitalLevel.High);
     MemoryRequest.Write(DigitalLevel.High);
     MachineCycle1.Write(DigitalLevel.High);
     Refresh.Write(DigitalLevel.High);
     Read.Write(DigitalLevel.High);
     Write.Write(DigitalLevel.High);
 }
        public static void Transmit(IntPtr connectionHandle, Protocol activeProtocol, byte[] inputData, ref byte[] outputData, out int dataSize)
        {
            var inputPci = new IoRequest {
                Protocol = (int)activeProtocol
            };
            var outputPci = new IoRequest {
                Protocol = (int)activeProtocol
            };

            inputPci.PciLength  = Marshal.SizeOf(inputPci);
            outputPci.PciLength = Marshal.SizeOf(outputPci);

            Transmit(connectionHandle, ref inputPci, ref outputPci, inputData, ref outputData, out dataSize);
        }
        public string Transmit(ref IoRequest sendPci, ref IoRequest recivePci, string apdu)
        {
            var response = Transmit(ref sendPci, ref recivePci, BinaryHelper.ConvertOctetStringToBytes(apdu)).ToArray();

            return(BinaryHelper.ConvertBytesToOctetString(response));
        }
        public IReadOnlyList <byte> Transmit(ref IoRequest sendPci, ref IoRequest recivePci, IReadOnlyList <byte> apdu)
        {
            WinSCardWrapper.Transmit(Handle, ref sendPci, ref recivePci, apdu.ToArray(), ref _buffer, out var dataSize);

            return(_buffer.Take(dataSize).ToArray());
        }