/// <summary> /// 选卡操作 /// </summary> /// <returns>返回被选中的标签的 UID,如果未选中标签,则返回 null</returns> private async Task <byte[]> Select() { //请求操作 var info = await i14443a.RequestAsync(RequestMode.AllCard); if (info.ReturnValue != ReturnMessage.Success) { return(null); } //防冲突操作,感应区内只允许放置一张卡片 var info1 = await i14443a.Anticoll2Async(MultiLable.AllowOne); if (info1.ReturnValue != ReturnMessage.Success) { return(null); } //选卡操作 var info2 = await i14443a.SelectAsync(info1.UID); if (info2.ReturnValue != ReturnMessage.Success) { return(null); } return(info1.UID); }
private async Task SelectCard() { if (anticollCard == null) { this.Dispatcher.Invoke(new Action(() => { txtMsg.Text = "请首先执行请求、防冲突命令后再选择标签!"; })); return; } var info = await i14443a.SelectAsync(anticollCard); this.Dispatcher.Invoke(new Action(() => { txtMsg.Text = "发送的字节:" + info.GetSendByteStr(); txtMsg.Text += "\r\n接收的字节:" + info.GetRecvByteStr(); txtMsg.Text += "\r\n" + info.GetStatusStr(); })); if (info.ReturnValue == ReturnMessage.Success) { selCardID = anticollCard; string uid = FrameBase.UIDToString(selCardID); txtCard.Text = uid; if (!lstCard.Items.Contains(uid)) { lstCard.Items.Add(uid); } } }
//选卡 private static async Task <bool> AuthKey(byte sectorNum) { await reader.ChangeToISO14443AAsync(); //请求操作 var info = await i14443a.RequestAsync(RequestMode.AllCard); if (info.ReturnValue != ReturnMessage.Success) { Console.WriteLine(info.GetStatusStr()); return(false); } //防冲突操作 var info1 = await i14443a.AnticollAsync(); if (info1.ReturnValue != ReturnMessage.Success) { Console.WriteLine(info1.GetStatusStr()); return(false); } //选卡操作 var info2 = await i14443a.SelectAsync(info1.UID); if (info2.ReturnValue == ReturnMessage.Success) { Console.WriteLine("选中标签:" + info1.GetUIDStr()); } else { Console.WriteLine(info2.GetStatusStr()); return(false); } //证实 byte[] keyA = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; //密码 A 证实 var info3 = await i14443a.AuthKeyAsync(KeyType.KeyA, sectorNum, keyA); if (info3.ReturnValue != ReturnMessage.Success) { Console.WriteLine(info3.GetStatusStr()); return(false); } Console.WriteLine("证实成功"); return(true); }
private async Task Select() { var info = await reader.ChangeToISO14443AAsync(); this.Dispatcher.Invoke(new Action(() => { txtMsg.Text = "发送的字节:" + info.GetSendByteStr(); txtMsg.Text += "\r\n接收的字节:" + info.GetRecvByteStr(); txtMsg.Text += "\r\n" + info.GetStatusStr(); })); if (info.ReturnValue != ReturnMessage.Success) { return; } var info1 = await i14443a.RequestAsync(RequestMode.IdleCard); this.Dispatcher.Invoke(new Action(() => { txtMsg.Text += "\r\n\r\n发送的字节:" + info1.GetSendByteStr(); txtMsg.Text += "\r\n接收的字节:" + info1.GetRecvByteStr(); txtMsg.Text += "\r\n卡片类型:" + info1.GetCardTypeName(); txtMsg.Text += "\r\n" + info1.GetStatusStr(); })); if (info1.ReturnValue != ReturnMessage.Success) { return; } var info2 = await i14443a.AnticollAsync(); this.Dispatcher.Invoke(new Action(() => { txtMsg.Text += "\r\n\r\n发送的字节:" + info2.GetSendByteStr(); txtMsg.Text += "\r\n接收的字节:" + info2.GetRecvByteStr(); txtMsg.Text += "\r\n返回的标签 UID:" + info2.GetUIDStr(); txtMsg.Text += "\r\n" + info2.GetStatusStr(); })); if (info2.ReturnValue != ReturnMessage.Success) { return; } var info3 = await i14443a.SelectAsync(info2.UID); this.Dispatcher.Invoke(new Action(() => { txtMsg.Text += "\r\n\r\n发送的字节:" + info.GetSendByteStr(); txtMsg.Text += "\r\n接收的字节:" + info.GetRecvByteStr(); txtMsg.Text += "\r\n" + info.GetStatusStr(); })); if (info3.ReturnValue != ReturnMessage.Success) { return; } this.Dispatcher.Invoke(new Action(() => { txtSelCard.Text = info2.GetUIDStr(); })); }