Exemple #1
0
        /// <summary>
        /// Read TID
        /// </summary>
        private void ReadTID()
        {
            byte[] tagID = null;
            byte[] data;
            string strerr;

            if (TagOperation.ReadTID(tagID, selCodeArea, 1, out data, out strerr))
            {
                tagID = data;
                string tid = Util.ConvertByteArrayToHexWordString(data);
                for (int i = 0; i < cbTargetTag.Items.Count; i++)
                {
                    if (tid == cbTargetTag.Items[i].ToString())
                    {
                        FormatConvert.SoundSucceed();
                        return;
                    }
                }
                cbTargetTag.Items.Add(tid);
                this.cbTargetTag.Text = tid;
                AddToStatusAsync("");
                FormatConvert.SoundSucceed();
            }
            else
            {
                AddToStatusAsync("Read failure," + strerr);
                FormatConvert.SoundError();
            }
        }
Exemple #2
0
        /// <summary>
        /// ReadEpc
        /// </summary>
        private void ReadEpc()
        {
            byte[] tagEpc = null;
            byte[] data;
            string strerr;

            TagOperation.RfidConnecte();
            if (TagOperation.ReadEpc(tagEpc, selCodeArea, 1, out data, out strerr))
            {
                tagEpc = data;
                string epc = Util.ConvertByteArrayToHexWordString(data);
                for (int i = 0; i < tvEpcData.Items.Count; i++)
                {
                    if (epc == tvEpcData.Items[i].ToString())
                    {
                        FormatConvert.SoundSucceed();
                        return;
                    }
                }
                tvEpcData.Items.Add(epc);
                this.tvEpcData.Text = epc;
                AddToStatusAsync("");
                FormatConvert.SoundSucceed();
            }
            else
            {
                AddToStatusAsync("Read failure," + strerr);
                FormatConvert.SoundError();
            }
        }
Exemple #3
0
        /// <summary>
        /// Set Access PassWord
        /// </summary>
        private void SetAccessPwd()
        {
            string oldpwd  = tvOriAccessPwd.Text;
            string newpwd  = tvNewAccessPwd.Text;
            string strcode = "";

            if (cbTargetTag.Items.Count > 0)
            {
                strcode = cbTargetTag.SelectedItem.ToString();
            }
            if (strcode == "")
            {
                AddToStatusAsync("Please select one tag!");
                cbTargetTag.Focus();
                return;
            }
            if (oldpwd == "")
            {
                AddToStatusAsync("Old password can not empty!");
                tvOriAccessPwd.Focus();
                return;
            }
            if (newpwd == "")
            {
                AddToStatusAsync("New password can not empty!");
                tvNewAccessPwd.Focus();
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                byte[] bcode   = Util.ConvertHexStringToByteArray(strcode);
                byte[] boldPwd = Util.ConvertHexStringToByteArray(oldpwd);
                byte[] bnewPwd = Util.ConvertHexStringToByteArray(newpwd);
                string errInfo = "";
                if (TagOperation.SetAccessPassword(boldPwd, bnewPwd, bcode, selCodeArea, out errInfo))
                {
                    AddToStatusAsync("Set Access Password Successfully!");
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    AddToStatusAsync("Set Access Password Failed," + errInfo);
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #4
0
        /// <summary>
        /// Write Epc
        /// </summary>
        protected void UiWriteEpc()
        {
            AddToStatusAsync("");
            string strdata = tvDataMemo.Text;

            if (strdata == "")
            {
                AddToStatusAsync("EPC can not empty!");
                tvDataMemo.Focus();
                return;
            }
            string strpwd = tvPassword.Text;

            if (strpwd == "")
            {
                AddToStatusAsync("PassWord can not empty!");
                tvPassword.Focus();
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();

            try
            {
                byte[] bwritedata = FormatConvert.getWriteData(strdata);
                byte[] bpwd       = FormatConvert.getPwd(strpwd);
                string errInfo    = "";
                string strtmp     = "";
                if (TagOperation.WriteEpc(bpwd, bwritedata, tagID, selCodeArea, out errInfo))
                {
                    strtmp = "Write: " + bwritedata.Length.ToString() + " byte!";
                    AddToStatusAsync(string.Format(strtmp));
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    AddToStatusAsync("Write failure," + errInfo);
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #5
0
        /// <summary>
        /// Kill Tag
        /// </summary>
        private void KillTag()
        {
            string TitleText = "";

            if (cbTargetTag.SelectedIndex < 0)
            {
                AddToStatusAsync("Plese select one tag epc!");
                return;
            }
            string strepc = cbTargetTag.SelectedItem.ToString();
            string strpwd = tvKillPwd.Text;

            if (strpwd == "")
            {
                AddToStatusAsync("The KillPassWord can not empty!");
                return;
            }
            if (DialogResult.No == MessageBox.Show("Are you sure to kill the tag?", TitleText, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
            {
                return;
            }

            byte[] bepc    = Util.ConvertHexStringToByteArray(strepc);
            byte[] killPwd = Util.ConvertHexStringToByteArray(strpwd);
            string errInfo = "";

            if (TagOperation.KillTag_6C(killPwd, bepc, out errInfo))
            {
                AddToStatusAsync("Kill Tag Successfully.");
                FormatConvert.SoundSucceed();
            }
            else
            {
                AddToStatusAsync("Kill Tag Failed," + errInfo);
                FormatConvert.SoundError();
            }
        }
Exemple #6
0
 private void FrConfig_Closed(object sender, EventArgs e)
 {
     TagOperation.Disconnect();
 }
Exemple #7
0
 public FrConfig()
 {
     InitializeComponent();
     TagOperation.RfidConnecte();
 }
Exemple #8
0
        /// <summary>
        /// Set Tag Lock
        /// </summary>
        private void SetTagLock()
        {
            int    seloperate = cbLockOperate.SelectedIndex;
            int    selbank    = cbLockArea.SelectedIndex;
            string accessPwd  = tvOriAccessPwd.Text;
            string strcode    = "";

            if (cbTargetTag.Items.Count > 0)
            {
                strcode = cbTargetTag.SelectedItem.ToString();
            }
            if (strcode == "")
            {
                AddToStatusAsync("Please select one tag!");
                cbTargetTag.Focus();
                return;
            }
            if (accessPwd == "")
            {
                AddToStatusAsync("Access password can not empty!");
                tvOriAccessPwd.Focus();
                return;
            }
            if (seloperate < 0)
            {
                AddToStatusAsync("Select operation type!");
                cbLockOperate.Focus();
                return;
            }
            if (selbank < 0)
            {
                AddToStatusAsync("Select operating memory!");
                cbLockArea.Focus();
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                byte[] bcode      = Util.ConvertHexStringToByteArray(strcode);
                byte[] baccessPwd = Util.ConvertHexStringToByteArray(accessPwd);
                string errInfo    = "";
                if (TagOperation.LockTag_6C(baccessPwd, (byte)seloperate, (byte)selbank, bcode, selCodeArea, out errInfo))
                {
                    if (seloperate == 1)
                    {
                        AddToStatusAsync("Unlock tag successfully.");
                    }
                    else
                    {
                        AddToStatusAsync("Lock tag successfully.");
                        FormatConvert.SoundError();
                    }
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    if (seloperate == 1)
                    {
                        AddToStatusAsync("Unlock failed," + errInfo);
                    }
                    else
                    {
                        AddToStatusAsync("Lock failed," + errInfo);
                    }
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #9
0
        /// <summary>
        /// Write Userdata_6C
        /// </summary>
        protected void UiWriteUserdata_6C()
        {
            AddToStatusAsync("");
            string strdata = tvDataMemo.Text;

            if (strdata == "")
            {
                AddToStatusAsync("User Data can not empty!");
                tvDataMemo.Focus();
                return;
            }

            string strpwd = tvPassword.Text;

            if (strpwd == "")
            {
                AddToStatusAsync("PassWord can not empty!");
                tvPassword.Focus();
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();

            try
            {
                uint   offset      = (ushort)(Convert.ToUInt32("0"));
                ushort BlockLength = 4;
                ushort BlockSize   = 6;
                byte[] bwritedata  = FormatConvert.getWriteData(strdata);
                byte[] bpwd        = FormatConvert.getPwd(strpwd);
                string errInfo     = "";
                int    hadlen      = 0;
                bool   ret         = false;
                int    OpWriteMode = this.cbtype.SelectedIndex;

                byte[] selcode = tagID;

                switch (OpWriteMode)
                {
                case 1:
                    ret = TagOperation.BlockWriteData_6C(offset, bpwd, MemoryBank.UserMemory, bwritedata, selcode, selCodeArea, BlockLength, out hadlen, out errInfo);
                    break;

                case 2:
                    ret = TagOperation.BlockEraseData_6C(offset, bpwd, MemoryBank.UserMemory, BlockLength, BlockSize, selcode, selCodeArea, out errInfo);
                    break;

                default:
                    ret = TagOperation.WriteUserdata_6C(offset, bpwd, bwritedata, selcode, selCodeArea, out errInfo);
                    break;
                }

                if (ret == true)
                {
                    string strtmp = "Write: " + bwritedata.Length.ToString() + " byte!";
                    AddToStatusAsync(string.Format(strtmp));
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    AddToStatusAsync("Write failure," + errInfo);
                    FormatConvert.SoundError();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #10
0
        public FrWriteTags()
        {
            InitializeComponent();

            TagOperation.RfidConnecte();
        }
Exemple #11
0
        /// <summary>
        /// Read Tag Data
        /// </summary>
        private void UiReadData()
        {
            this.lblStatus.Text = "";
            //byte[] selCode = null;
            byte[] data    = null;
            string strerr  = null;
            int    _offset = 0;
            int    _length = 28;
            string errinfo;

            if (rbEpc.Checked)
            {
                if (TagOperation.ReadEpc(tagID, selCodeArea, 1, out data, out strerr))
                {
                    this.tvDataMemo.Text = Util.ConvertByteArrayToHexWordString(data);
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    errinfo = string.Format("Read failure,{0}", strerr);
                    AddToStatusAsync(errinfo);
                    FormatConvert.SoundError();
                }
            }
            else if (rbTid.Checked)
            {
                if (TagOperation.ReadTID(tagID, selCodeArea, 1, out data, out strerr))
                {
                    tagID = data;
                    string tid = Util.ConvertByteArrayToHexWordString(data);
                    for (int i = 0; i < cbtid.Items.Count; i++)
                    {
                        if (tid == cbtid.Items[i].ToString())
                        {
                            this.tvDataMemo.Text = "";
                            FormatConvert.SoundSucceed();
                            return;
                        }
                    }
                    cbtid.Items.Add(tid);
                    this.cbtid.Text      = tid;
                    this.tvDataMemo.Text = "";
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    errinfo = string.Format("Read failure,{0}", strerr);
                    AddToStatusAsync(errinfo);
                    FormatConvert.SoundError();
                }
            }
            else
            {
                if (TagOperation.ReadUserdata_6C((ushort)_offset, (ushort)_length, tagID, selCodeArea, out data, out strerr))
                {
                    this.tvDataMemo.Text = Util.ConvertByteArrayToHexWordString(data);
                    FormatConvert.SoundSucceed();
                }
                else
                {
                    errinfo = string.Format("Read failure,{0}", strerr);
                    AddToStatusAsync(errinfo);
                    FormatConvert.SoundError();
                }
            }
        }