示例#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 btnTagAction_Click(object sender, EventArgs e)
        {
            int  back      = 0;
            uint BlockSize = 0;

            byte[] Data     = null;
            byte[] respData = null;
            Dictionary <string, FedmIscTagHandler> .ValueCollection listTagHandler;

            if (!connected)
            {
                return;
            }

            listTagHandler = TagList.Values;
            foreach (FedmIscTagHandler tag in listTagHandler)
            {
                if (tag is FedmIscTagHandler_ISO15693)
                {
                    FedmIscTagHandler_ISO15693 newTag = (FedmIscTagHandler_ISO15693)tag;
                    Console.WriteLine(newTag.GetTagName());

                    // read data blocks and write same data back to tag
                    back = newTag.ReadMultipleBlocks((uint)4, (uint)4, out BlockSize, out Data);
                    back = newTag.WriteMultipleBlocks(4, 4, 4, Data);
                }
                else if (tag is FedmIscTagHandler_ISO14443)
                {
                    FedmIscTagHandler newTag = null;

                    // execute a select command for MIFARE DESFire
                    // TagSelect creates a new TagHandler object internally
                    newTag = Reader.TagSelect(tag, 9);

                    if (newTag is FedmIscTagHandler_ISO14443_4_MIFARE_DESFire)
                    {
                        FedmIscTagHandler_ISO14443_4_MIFARE_DESFire desfireTag = (FedmIscTagHandler_ISO14443_4_MIFARE_DESFire)newTag;

                        Console.WriteLine(desfireTag.GetTagName());

                        // read version information
                        // use the internal Interface IFlexSoftCrypto
                        back = desfireTag.IFlexSoftCrypto.GetVersion((byte)0, out respData);
                    }
                }
                else if (tag is OBID.TagHandler.FedmIscTagHandler_EPC_Class1_Gen2)
                {
                    FedmIscTagHandler_EPC_Class1_Gen2 newTag = (FedmIscTagHandler_EPC_Class1_Gen2)tag;
                    Console.WriteLine(newTag.GetTagName());

                    // write a new EPC number (without password)
                    back = newTag.WriteEPC("1102030405060708090A0B0C", "");
                }
            }
        }
示例#3
0
        public bool WriteTagASCII(string asciiString)
        {
            var tagsInventory = _reader.TagInventory(true, 0x10, Settings.Instance.AntennaByte);

            int status   = -1;
            int tagCount = tagsInventory.Count;

            if (tagCount > 1)
            {
                Display.WriteError("Too Many Tags in Reader Field");
                return(false);
            }

            if (tagCount < 1)
            {
                Display.WriteError("No Tags in Reader Field");
                return(false);
            }

            FedmIscTagHandler_EPC_Class1_Gen2 tag = tagsInventory.Values.First() as FedmIscTagHandler_EPC_Class1_Gen2;

            if (tag != null)
            {
                Display.WriteInformation($"Detected Tag - Writing: {asciiString}");
                status = tag.WriteEPC(HexConverter.ConvertASCIItoHexString(asciiString), "");
            }

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

            Display.WriteError("Error status code " + status + ": " + _reader.GetStatusText((byte)status));

            return(false);
        }