コード例 #1
0
 public void Dispose()
 {
     if (_readerReady)
     {
         if (hndl != null)
         {
             // TODO: stop cyclic inventory if enabled, prior to closing it down
             hndl.Dispose();
             hndl = null;
         }
         _readerReady = false;
     }
 }
コード例 #2
0
        private bool tryPortNamed(string portname)
        {
            dev = new SerialDevice(portname);
            if (!dev.Open())
            {
                return(false);
            }
            Global.m_tracer            = new ConsoleTrace();
            Global.m_tracer.TraceLevel = 0;
            var ph = new CSrfeProtocolHandler(dev);

            if (!test_ReaderInfo(ph))
            {
                return(false);
            }
            hndl = ph;
            return(true);
        }
コード例 #3
0
        private static bool test_ReaderInfo(CSrfeProtocolHandler ph)
        {
            bool ok = false;

            // get reader id
            uint readerId = 0;

            ok = ph.getReaderID(out readerId);
            if (!ok)
            {
                Console.WriteLine("ERROR: Could not get ReaderID");
            }

            // get reader type
            uint readerType = 0;

            ok = ph.getReaderType(out readerType);
            if (!ok)
            {
                Console.WriteLine("ERROR: Could not get ReaderType");
            }

            // get hardware revision
            uint hwRev = 0;

            ok = ph.getHardwareRevision(out hwRev);
            if (!ok)
            {
                Console.WriteLine("ERROR: Could not get HardwareRevision");
            }

            // get software revision
            uint swRev = 0;

            ok = ph.getSoftwareRevision(out swRev);
            if (!ok)
            {
                Console.WriteLine("ERROR: Could not get SoftwareRevision");
            }

            // get bootloader revision
            uint blRev = 0;

            ok = ph.getBootloaderRevision(out blRev);
            if (!ok)
            {
                Console.WriteLine("ERROR: Could not get BootloaderRevision");
            }

            // get current system
            Constants.eRFE_CURRENT_SYSTEM system = 0;
            ok = ph.getCurrentSystem(out system);
            if (!ok)
            {
                Console.WriteLine("ERROR: Could not get CurrentSystem");
            }

            // get current state
            Constants.eRFE_CURRENT_READER_STATE state = 0;
            ok = ph.getCurrentState(out state);
            if (!ok)
            {
                Console.WriteLine("ERROR: Could not get CurrentState");
            }

            // get status register
            ulong statusReg = 0;

            ok = ph.getStatusRegister(out statusReg);
            if (!ok)
            {
                Console.WriteLine("ERROR: Could not get StatusRegister");
            }

            // print out results
            Console.WriteLine("Reader Information:");
            Console.WriteLine("\t -> ReaderID       = 0x{0:X08}", readerId);
            Console.WriteLine("\t -> ReaderType     = 0x{0:X08}", readerType);
            Console.WriteLine("\t -> HardwareRev    = 0x{0:X08}", hwRev);
            Console.WriteLine("\t -> SoftwareRev    = 0x{0:X08}", swRev);
            Console.WriteLine("\t -> BootloaderRev  = 0x{0:X08}", blRev);
            Console.WriteLine("\t -> Current System = {0}", system.ToString());
            Console.WriteLine("\t -> Current State  = {0}", state.ToString());
            Console.WriteLine("\t -> StatusRegister = 0x{0:X016}", statusReg);
            return(ok);
        }