Ejemplo n.º 1
0
        private static void DisplayReaderStatus(ISCardReader reader)
        {
            string[]      readerNames;
            SCardProtocol proto;
            SCardState    state;

            byte[] atr;

            var sc = reader.Status(
                out readerNames,    // contains the reader name(s)
                out state,          // contains the current state (flags)
                out proto,          // contains the currently used communication protocol
                out atr);           // contains the ATR

            if (sc == SCardError.Success)
            {
                Console.WriteLine("Connected with protocol {0} in state {1}", proto, state);
                DisplayCardAtr(atr);
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("Unable to retrieve card status.\nError message: {0}",
                                  SCardHelper.StringifyError(sc));
            }
        }
Ejemplo n.º 2
0
        public override IOption <IReader> Content()
        {
            Debug.WriteLine("GetEnumerator Reader TreadID " + Thread.CurrentThread.ManagedThreadId);
            var cardError = _reader.Connect(_readerName, SCardShareMode.Shared, SCardProtocol.Any);

            if (cardError != SCardError.Success)
            {
                Console.WriteLine("Could not begin transaction. {0}", SCardHelper.StringifyError(cardError));
                return(new Option <IReader>());
            }
            SCardProtocol proto;
            SCardState    state;

            byte[] atr;
            var    readerNames = new[] { _readerName };
            var    sc          = _reader.Status(
                out readerNames,
                out state,
                out proto,
                out atr
                );

            if (sc != SCardError.Success)
            {
                Console.WriteLine("Could not begin transaction. {0}", SCardHelper.StringifyError(sc));
                return(new Option <IReader>());
            }

            sc = _reader.BeginTransaction();
            if (sc != SCardError.Success)
            {
                Console.WriteLine("Could not begin transaction. {0}", SCardHelper.StringifyError(sc));
                return(new Option <IReader>());
            }

            Console.WriteLine("Connected with protocol {0} in state {1}", proto, state);
            Console.WriteLine("Card ATR: {0}", BitConverter.ToString(atr));

            return(new Option <IReader>(
                       new WrappedReader(
                           //new LogedReader(
                           _reader
                           //)
                           )
                       ));
        }
Ejemplo n.º 3
0
        private static void DisplayReaderStatus(ISCardReader reader) {
            string[] readerNames;
            SCardProtocol proto;
            SCardState state;
            byte[] atr;

            var sc = reader.Status(
                out readerNames,    // contains the reader name(s)
                out state,          // contains the current state (flags)
                out proto,          // contains the currently used communication protocol
                out atr);           // contains the ATR

            if (sc == SCardError.Success) {
                Console.WriteLine("Connected with protocol {0} in state {1}", proto, state);
                DisplayCardAtr(atr);
                Console.WriteLine();
            } else {
                Console.WriteLine("Unable to retrieve card status.\nError message: {0}", 
                    SCardHelper.StringifyError(sc));
            }
        }