Beispiel #1
0
    public void Read()
    {
        ct.RequestICC();
        Thread.Sleep(200);
        ct.SelectFile();
        Thread.Sleep(200);

        Console.WriteLine("ReadResult: " + Hexify(ct.Read(10, 10)));
        Console.WriteLine("ReadResult: " + Hexify(ct.Read(5, 10)));
        Console.WriteLine("ReadResult: " + Hexify(ct.Read(0, 10)));
    }
Beispiel #2
0
        // Check for card insertion / removes
        // Called every second
        protected bool CheckCardStatus()
        {
            bool card;

            if (ct == null)
            {
                return(false);          // stop checking
            }
            try {
                card = ct.CardInserted();

                StatusErrorCounter = 0;

                if (card && !CardInSlot)
                {
                    if (!ct.RequestICC())
                    {
                        return(true);
                    }
                    CardInSlot = true;

                    OnCardInserted();
                }
                else if (!card && CardInSlot)
                {
                    OnCardRemoved();
                    CardInSlot = false;
                }
                ;
            } catch (CTException ex) {
                Console.Error.WriteLine(ex);

                StatusErrorCounter++;
                if (StatusErrorCounter == 2)
                {
                    CTError();
                    return(false);
                }
            }

            return(true);          // recheck in 1s
        }
Beispiel #3
0
        /// <summary>
        ///  Called regulary (1 Hz) by GLib.Timeout
        /// </summary>
        private bool CheckCardStatus()
        {
            if (ct == null)
            {
                return(false);                   // stop checking
            }
            try {
                bool card;

                card = ct.CardInserted();

                if (card && !CardInSlot)
                {
                    if (!ct.RequestICC())
                    {
                        return(true);
                    }
                    CardInSlot = true;

                    Thread.Sleep(200);
                    OnCardInserted();
                }
                else if (!card && CardInSlot)
                {
                    OnCardRemoved();
                    CardInSlot = false;
                }
                ;
            } catch (CTException ex) {
                Console.Error.WriteLine(ex);

                errorCounter++;
                if (errorCounter == 2)
                {
                    // XXX
                    return(false);
                }
            }

            return(true);                  // recheck in 1s
        }