bool select_login() { nowsn = ""; g_retCode = ACR110U.ACR110_Select(g_hReader, ref tagType[0], ref tagLen, ref tagSN[0]); textBox1.AppendText("[DEBUG] SELECT CARD = " + g_retCode + "\n"); textBox1.AppendText("[DEBUG] CARD TYPE = " + ACR110U.GetTagType1(tagType[0]) + "\n"); string str = ""; for (int i = 0; i < tagLen; i++) { str += tagSN[i].ToString("X2") + " "; } nowsn = str; textBox1.AppendText("[DEBUG] CARD SN = " + str + "\n"); if (g_retCode == 0) { byte[] key = new byte[6] { 0xab, 0xab, 0xab, 0xab, 0xab, 0xab }; g_retCode = ACR110U.ACR110_Login(g_hReader, 1, ACR110U.ACR110_LOGIN_KEYTYPE_A, 0, ref key[0]); textBox1.AppendText("[DEBUG] LOGIN = "******"\n"); if (g_retCode == 0) { return(true); } } return(false); }
private void textBox1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { string line = get_last_line(textBox1.Lines); if (line == "CARD_INIT") { { g_retCode = ACR110U.ACR110_Select(g_hReader, ref tagType[0], ref tagLen, ref tagSN[0]); textBox1.AppendText("[DEBUG] SELECT CARD = " + g_retCode + "\n"); textBox1.AppendText("[DEBUG] CARD TYPE = " + ACR110U.GetTagType1(tagType[0]) + "\n"); string str = ""; for (int i = 0; i < tagLen; i++) { str += tagSN[i].ToString("X2") + " "; } textBox1.AppendText("[DEBUG] CARD SN = " + str + "\n"); byte[] key = new byte[6] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; g_retCode = ACR110U.ACR110_Login(g_hReader, 1, ACR110U.ACR110_LOGIN_KEYTYPE_A, 0, ref key[0]); if (g_retCode == 0) { byte[] wbuf = new byte[16] { 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xff, 0x07, 0x80, 0x69, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; g_retCode = ACR110U.ACR110_Write(g_hReader, 7, ref wbuf[0]); if (g_retCode == 0) { textBox1.AppendText("CARD_INIT DONE\n"); } else { textBox1.AppendText("CARD_INIT ERR 2\n"); } } else { textBox1.AppendText("CARD_INIT ERR 1\n"); } } } else if (line == "CARD_ADMIN") { //if (!card_conn) //{ // card_conn = //} //if (card_conn) { select_login(); make_admin_card(); } } else if (line.StartsWith("CARD_FLOOR ")) { string[] words = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); if (words.Length == 2) { byte f = byte.Parse(words[1]); //if (!card_conn) //{ // card_conn = select_login(); //} //if (card_conn) { select_login(); make_floor_card(f); } } } else if (line == "CLS") { textBox1.Clear(); } } }