private void btnResetReadProtect_Click(object sender, EventArgs e) { int ret; ret = IsAntSet(); if (ret == -1) { MessageBox.Show("please select antenna"); return; } else if (ret == 1) { DialogResult stat = DialogResult.OK; stat = MessageBox.Show("execute operation on the port without finding antenna ?", "tip-off", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (stat != DialogResult.OK) { return; } } byte[] pwd = null; ret = Form1.IsValidPasswd(this.tbaccesspasswd.Text.Trim()); { switch (ret) { case -3: MessageBox.Show("please input access password"); break; case -2: case -4: MessageBox.Show("access password must be 8 of hexadecimal numbers"); break; case -1: MessageBox.Show("access password must be 8 of hexadecimal numbers"); break; } } if (ret != 0) { return; } else { pwd = ByteFormat.FromHex(this.tbaccesspasswd.Text.Trim()); } Gen2TagFilter filter = null; if (checkfilter(ref filter) != 0) { return; } try { NXP_ResetReadProtectPara para = new NXP_ResetReadProtectPara(pwd); mrdr.CustomCmd(filter, CustomCmdType.NXP_ResetReadProtect, para); } catch (OpFaidedException notagexp) { if (notagexp.ErrCode == 0x400) { MessageBox.Show("no tag"); } else { MessageBox.Show("operation failed:" + notagexp.ToString()); } return; } catch (Exception ex) { MessageBox.Show("operation failed:" + ex.ToString()); return; } }
private void btnResetReadProtect_Click(object sender, EventArgs e) { int ret; ret = IsAntSet(); if (ret == -1) { MessageBox.Show("请选择操作天线"); return; } else if (ret == 1) { DialogResult stat = DialogResult.OK; stat = MessageBox.Show("在未检测到天线的端口执行操作,真的要执行吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (stat != DialogResult.OK) { return; } } byte[] pwd = null; ret = Form1.IsValidPasswd(this.tbaccesspasswd.Text.Trim()); { switch (ret) { case -3: MessageBox.Show("访问密码不能为空"); break; case -2: case -4: MessageBox.Show("访问密码必须是8个16进制数"); break; case -1: MessageBox.Show("访问密码只能是16进制数字"); break; } } if (ret != 0) { return; } else { pwd = ByteFormat.FromHex(this.tbaccesspasswd.Text.Trim()); } Gen2TagFilter filter = null; if (checkfilter(ref filter) != 0) { return; } try { NXP_ResetReadProtectPara para = new NXP_ResetReadProtectPara(pwd); mrdr.CustomCmd(filter, CustomCmdType.NXP_ResetReadProtect, para); } catch (OpFaidedException notagexp) { if (notagexp.ErrCode == 0x400) { MessageBox.Show("没法发现标签"); } else { MessageBox.Show("操作失败:" + notagexp.ToString()); } return; } catch (Exception ex) { MessageBox.Show("操作失败:" + ex.ToString()); return; } }