//旨收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收 // start access operation //曲收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收 internal void StartAccess() { byte MemBank = bankIDlist[comboBox_bank.SelectedIndex]; UInt32 offset = Convert.ToUInt32(textBox_offset.Text); UInt32 length = Convert.ToUInt32(textBox_length.Text); UInt32 pwdACCESS; button_access.Text = "STOP"; if (false == UtilClass.HEX32(out pwdACCESS, textBox_accesspassword.Text)) { AccessEnd(); return; } MainForm.SetupOperationParameter(); // read access if (radioButton_read.Checked) { MainForm.RFIDAPI.UHFAPI_ReadTag(MemBank, offset, length, pwdACCESS, MainForm.SetControlParam, false); } // write access else if (radioButton_write.Checked) { ushort[] szWriteData; /* * if (textBox_write.Text.Length / 4 != 0 || textBox_write.Text == "0") * { * AccessEnd(); * MessageBox.Show("Wrong Write Data Length !!"); * return; * } */ if (true == UtilClass.HEXSTR(out szWriteData, textBox_write.Text)) { MainForm.RFIDAPI.UHFAPI_WriteTag(MemBank, offset, length, ref szWriteData, pwdACCESS, MainForm.SetControlParam, false); } else { AccessEnd(); } } }
//旨收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收 // Save the option parameters //曲收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收 private void MaskForm_Closing(object sender, CancelEventArgs e) { // checked mask mode. if (radioButton_epcmask.Checked) { MainForm.rfidhost_param.mask_mode = (int)MainForm.MASK_MODE.EPC_MASK_MODE; if (textBox_epcdata.Text.Length != 0) { MainForm.rfidhost_param.mskID_len = (uint)textBox_epcdata.Text.Length; if (true == UtilClass.BitCount(out MainForm.rfidhost_param.mask_bits, textBox_epcdata.Text)) { MainForm.rfidhost_param.mask_offset = 2 * 16; MainForm.rfidhost_param.mask_bank = (byte)MainForm.TAG_MEMORY_BANK.EPC; unsafe { byte[] tagid = new byte[256]; UtilClass.HexStrToByteArray(out tagid, textBox_epcdata.Text); fixed(byte *s = tagid, t = MainForm.rfidhost_param.mskpattern) { for (int i = 0; i < tagid.Length; i++) { *(t + i) = *(s + i); } } } // restore tag id unsafe { byte[] ID = new byte[256]; ID = UtilClass.StrToByteArray(textBox_epcdata.Text); fixed(byte *s = ID, t = MainForm.rfidhost_param.mskID) { for (int i = 0; i < MainForm.rfidhost_param.mskID_len; i++) { *(t + i) = *(s + i); } } } } else { MainForm.rfidhost_param.mask_bits = 0; MainForm.rfidhost_param.mask_offset = 0; MessageBox.Show("Wrong Tag EPC data"); } } else { MainForm.rfidhost_param.mask_bits = 0; MainForm.rfidhost_param.mask_offset = 0; MessageBox.Show("Nothing is Tag ID Value"); } } else if (radioButton_multimode.Checked) { MainForm.rfidhost_param.mask_mode = (int)MainForm.MASK_MODE.MULTI_MASK_MODE; // bank switch (comboBox_bank.SelectedIndex) { case (int)MainForm.TAG_MEMORY_BANK.EPC: MainForm.rfidhost_param.mask_bank = (byte)MainForm.TAG_MEMORY_BANK.EPC; break; case (int)MainForm.TAG_MEMORY_BANK.RESERVED: MainForm.rfidhost_param.mask_bank = (byte)MainForm.TAG_MEMORY_BANK.RESERVED; break; case (int)MainForm.TAG_MEMORY_BANK.TID: MainForm.rfidhost_param.mask_bank = (byte)MainForm.TAG_MEMORY_BANK.TID; break; case (int)MainForm.TAG_MEMORY_BANK.USER: MainForm.rfidhost_param.mask_bank = (byte)MainForm.TAG_MEMORY_BANK.USER; break; } // offset if (textBox_offset.Text.Length != 0) { uint offset; if (true == UtilClass.HEX32(out offset, textBox_offset.Text)) { MainForm.rfidhost_param.mask_offset = offset; } } // bit count if (textBox_length.Text.Length != 0) { uint len; if (true == UtilClass.HEX32(out len, textBox_length.Text)) { MainForm.rfidhost_param.mask_bits = len; } } // tag mask data if (textBox_maskdata.Text.Length != 0) { uint len; if (true == UtilClass.BitCount(out len, textBox_maskdata.Text)) { unsafe { byte[] tagid = new byte[256]; UtilClass.HexStrToByteArray(out tagid, textBox_maskdata.Text); fixed(byte *s = tagid, t = MainForm.rfidhost_param.mskpattern) { for (int i = 0; i < tagid.Length; i++) { *(t + i) = *(s + i); } } } // restore tag id unsafe { byte[] ID = new byte[256]; ID = UtilClass.StrToByteArray(textBox_epcdata.Text); fixed(byte *s = ID, t = MainForm.rfidhost_param.mskID) { for (int i = 0; i < MainForm.rfidhost_param.mskID_len; i++) { *(t + i) = *(s + i); } } } } else { MainForm.rfidhost_param.mask_bits = 0; MainForm.rfidhost_param.mask_offset = 0; MessageBox.Show("Wrong Tag EPC data"); } } else { MainForm.rfidhost_param.mask_bits = 0; MainForm.rfidhost_param.mask_offset = 0; MessageBox.Show("Nothing is Tag ID Value"); } } }
//旨收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收 // start access operation //曲收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收收 internal void StartAccess() { button_access.Text = "STOP"; MainForm.SetupOperationParameter(); // lock operation if (radioButton_lock.Checked) { UInt32 pwdACCESS; ushort lock_enable = 0; ushort lock_mask = 0; int mark; int index = (int)comboBox_bank.SelectedIndex; if (false == UtilClass.HEX32(out pwdACCESS, textBox_accesspassword.Text)) { AccessEnd(); MessageBox.Show("Wrong Access Password!!"); return; } // set kill password field if (index == 0) { mark = (int)comboBox_lockop.SelectedIndex; } else { mark = 0; } lock_enable |= SWAPLSB2(mark > 0 ? mark - 1 : 0); lock_mask |= (ushort)(mark > 0 ? 3 : 0); lock_enable <<= 2; lock_mask <<= 2; // set access password field if (index == 1) { mark = (int)comboBox_lockop.SelectedItem; } else { mark = 0; } lock_enable |= SWAPLSB2(mark > 0 ? mark - 1 : 0); lock_mask |= (ushort)(mark > 0 ? 3 : 0); lock_enable <<= 2; lock_mask <<= 2; // set EPC memory field if (index == 2) { mark = (int)comboBox_lockop.SelectedItem; } else { mark = 0; } lock_enable |= SWAPLSB2(mark > 0 ? mark - 1 : 0); lock_mask |= (ushort)(mark > 0 ? 3 : 0); lock_enable <<= 2; lock_mask <<= 2; // TID memory field if (index == 3) { mark = (int)comboBox_lockop.SelectedItem; } else { mark = 0; } lock_enable |= SWAPLSB2(mark > 0 ? mark - 1 : 0); lock_mask |= (ushort)(mark > 0 ? 3 : 0); lock_enable <<= 2; lock_mask <<= 2; // USER memory field if (index == 4) { mark = (int)comboBox_lockop.SelectedItem; } else { mark = 0; } lock_enable |= SWAPLSB2(mark > 0 ? mark - 1 : 0); lock_mask |= (ushort)(mark > 0 ? 3 : 0); MainForm.RFIDAPI.UHFAPI_LockSetTag((UHFAPI_NET.UHFAPI_NET.typeLockMasks)lock_mask, (UHFAPI_NET.UHFAPI_NET.typeLockMasks)lock_enable, pwdACCESS, MainForm.SetControlParam, false); } else if (radioButton_kill.Checked) { UInt32 pwdACCESS; UInt32 pwdKILL; if (false == UtilClass.HEX32(out pwdACCESS, textBox_accesspassword.Text)) { AccessEnd(); MessageBox.Show("Wrong Access Password!!"); return; } if (false == UtilClass.HEX32(out pwdKILL, textBox_killpassword.Text)) { AccessEnd(); MessageBox.Show("Wrong Access Password!!"); return; } System.Windows.Forms.DialogResult rts = System.Windows.Forms.MessageBox.Show("If you click on this YES, the kill tag will run..", "Warring", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); switch (rts) { case System.Windows.Forms.DialogResult.Yes: { MainForm.SetupOperationParameter(); MainForm.RFIDAPI.UHFAPI_KillTag(pwdKILL, pwdACCESS, MainForm.SetControlParam, false); } break; case System.Windows.Forms.DialogResult.No: { AccessEnd(); } break; } } }