Пример #1
0
        private static void Reader_Connect()
        {
            while (hReader < 0)
            {
                hReader = ACR120U.ACR120_Open(PORT);

                //if success return 0 else return < 0
                if (hReader >= 0)
                {
                    if (!ISCONNECTED)
                    {
                        ISCONNECTED = true;
                        break;
                    }
                    else
                    {
                    }
                }
                else
                {
                    string err = ACR120U.GetErrMsg(hReader);
                    ISCONNECTED = false;
                }
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            string serialNumber  = "0000000000";
            string serialNumber2 = "0000000001";

            byte[] dataRead  = new byte[8]; // Will contain card's Serial Number AKA UID
            byte[] tagType   = new byte[50];
            byte   ResultTag = 0;

            if (!Program_Initialize()) // Program_Initialize returns False. Exit program. Possible permission issue.
            {
                Exit_Program();
            }

            Reader_Initialize();

            Program_Delay();

            for (; ;)
            {
                /* Slow down reader read operation based on polling rate since there's no reason to have it run fast continually */
                Thread.Sleep(Int32.Parse(config.pollingRate));

                status = ACR120U.ACR120_Select(hReader, ref tagType[0], ref ResultTag, ref dataRead[0]); // Read operation

                if (status == 0)                                                                         // 0 = No error/successful
                {
                    serialNumber = "0000000000";
                    serialNumber = ByteArrayToString(dataRead).Substring(0, 8);

                    if (config.organizationChoice == UTEM) // UTEM uses numbers only. Convert from Hex to Int
                    {
                        serialNumber = Convert.ToString(Int64.Parse(serialNumber, System.Globalization.NumberStyles.HexNumber));
                    }

                    Console.WriteLine("Serial Number: " + serialNumber);

                    /* Checks if the card being read is the same. If yes, no need to continually send input */
                    if (string.Equals(serialNumber2, serialNumber))
                    {
                        continue;
                    }
                    else
                    {
                        SendKeys.SendWait(serialNumber.Trim());
                        serialNumber2 = serialNumber;
                    }
                }

                /* No card is detected by the reader. Sets both serial number variables to 00000000 as a reset procedure */
                else if (status == 62536)
                {
                    serialNumber  = "0000000000";
                    serialNumber2 = "0000000000";
                    Console.WriteLine("Serial Number: " + serialNumber);
                    continue;
                }
                /* TODO: Error handling? */
                else
                {
                    continue;
                }
            }
        }
Пример #3
0
 private static void Reader_Disconnect()
 {
     status      = ACR120U.ACR120_Close(hReader);
     hReader     = -1;
     ISCONNECTED = false;
 }