예제 #1
0
        public bool WriteTagHEX(string hexString)
        {
            if (!FeHexConvert.isHexString(hexString))
            {
                Console.WriteLine($"{hexString} is not a HEX value");
                return(false);
            }

            var tagsInventory = _reader.TagInventory(true, 0x10, Settings.Instance.AntennaByte);

            int status = -1;

            if (tagsInventory.Count == 1)
            {
                FedmIscTagHandler_EPC_Class1_Gen2 tag = tagsInventory.Values.First() as FedmIscTagHandler_EPC_Class1_Gen2;

                if (tag != null)
                {
                    Console.WriteLine($"Writing: {hexString}");
                    status = tag.WriteEPC(hexString, "");
                }
            }

            if (status == 0)
            {
                return(true);
            }

            return(false);
        }
        private void WriteSequentialHEXFormattedDecimal()
        {
            Display.WriteLine();
            Display.WriteLine("Beging Writing HEX Formatted Decimal");
            Console.Write("Prefix (HEX)");

            string prefix = Console.ReadLine();

            if (!FeHexConvert.isHexString(prefix))
            {
                Display.WriteError($"{prefix} is not a hex string, must contain 0-9 or A-F");
                return;
            }

            Console.Write("Start ID (DEC)");

            string input = Console.ReadLine();

            int padding = input.Length;

            if (!Int32.TryParse(input, out int startID))
            {
                Console.WriteLine($"{input} is not a number");
                return;
            }

            string startingUID = prefix + startID.ToString().PadLeft(padding, '0');

            Display.WriteLine($"Starting at {startingUID} (HEX)");
            Display.WriteLine("Press Enter Key to Write Tag, Escape to Cancel");

            if (!_controller.IsConnected)
            {
                Display.WriteError("Reader not connected");
                return;
            }

            ConsoleKey inputKey = ConsoleKey.Escape;

            do
            {
                bool   error   = false;
                string nextUID = String.Empty;

                inputKey = Console.ReadKey().Key;

                switch (inputKey)
                {
                case ConsoleKey.Enter:
                    nextUID = prefix + startID.ToString().PadLeft(padding, '0');
                    error   = !WriteTagHEX(nextUID);
                    break;
                }

                if (error)
                {
                    Display.WriteError("Error Writing to Tag");
                }
                else
                {
                    startID++;
                }
            } while (inputKey != ConsoleKey.Escape);
        }
예제 #3
0
        private static void WriteHEXFormattedDecimal()
        {
            Console.WriteLine();
            Console.WriteLine("Begin Tag Writing (ASCII)");
            Console.Write("Prefix (HEX): ");

            string prefix = Console.ReadLine();

            if (!FeHexConvert.isHexString(prefix))
            {
                Console.WriteLine($"{prefix} is not a Hex String");
                return;
            }

            Console.Write("Start ID (DEC): ");

            string input = Console.ReadLine();

            int padding = input.Length;

            if (!Int32.TryParse(input, out int startid))
            {
                Console.WriteLine($"{input} is not a number");
                return;
            }

            string startingUID = prefix + startid.ToString().PadLeft(padding, '0');

            Console.WriteLine($"Starting at {startingUID} (HEX)");
            Console.WriteLine($"Press Enter Key to Write Tag, Escape to Cancel");

            ConsoleKey keyInput = ConsoleKey.Escape;

            if (_controller.IsConnected) //Start loop if reader is connected
            {
                do
                {
                    bool   error   = false;
                    string nextUID = String.Empty;

                    keyInput = Console.ReadKey().Key;

                    switch (keyInput)
                    {
                    case ConsoleKey.Enter:
                        nextUID = prefix + startid.ToString().PadLeft(padding, '0');
                        //error = _controller.WriteTagHEX(nextUID);
                        break;
                    }

                    if (error)
                    {
                        Console.WriteLine($"Unknown Error Occured");
                    }
                    else
                    {
                        startid++;
                    }
                } while (keyInput != ConsoleKey.Escape);
            }
            else
            {
                Console.WriteLine($"No Reader Found");
            }
        }