private void btn_CascSelect_Click(object sender, RoutedEventArgs e) { bool status = false; //把前一个防碰撞命令返回的UID(包含级联志)赋值给选择主机命令的UID(4 字节) for (int i = 0; i < RFIDHelper.cardID.Length; i++) { RFIDHelper.PiccSelect[5 + i] = RFIDHelper.cardID[i]; } //把计算好的BCC码赋值给选择字节数组 RFIDHelper.PiccSelect[RFIDHelper.PiccSelect.Length - 2] = RFIDHelper.bcc_Calc(RFIDHelper.PiccSelect); status = RFIDHelper.cmdCom(RFIDHelper.PiccSelect, RFIDHelper.buffer_PiccSelect); //判断从机应答状态是否为0和帧结束符是否为3 if (status) { //string temp = "SELECT * FROM authorization"; //StringBuilder temp2 = DataBaseHelper.QueryData(temp); //string[] temp3 = temp2.ToString().Split(' '); //for (int i = 0; i < temp3.Length; i++) //{ // //字符串数组转换为字节数组,十六进制转为十进制 // MacthingCardID[i] = byte.Parse(temp3[i]); //} //Enumerable.SequenceEqual() //把卡ID显示出来(4 字节,低字节在先),十进制转为十六进制,如果高位没有值,就用0代替 tb_Hint.Text = "选择成功!\n" + "卡ID:" + RFIDHelper.showCardID(); } else { tb_Hint.Text = "选择失败!"; } }
private void btn_CascAnticoll_Click(object sender, RoutedEventArgs e) { bool status = false; RFIDHelper.PiccAnticoll[RFIDHelper.PiccAnticoll.Length - 2] = RFIDHelper.bcc_Calc(RFIDHelper.PiccAnticoll); status = RFIDHelper.cmdCom(RFIDHelper.PiccAnticoll, RFIDHelper.buffer_PiccAnticoll); if (status) { tb_Hint.Text = " 防碰撞成功!\n" + "卡ID:" + RFIDHelper.showCardID(); } else { tb_Hint.Text = "设备没应答!"; } }