private void timer1_Tick(object sender, EventArgs e) { /*if (RF_YLE280U.YLE280_GetReaderCode() == -2) * { * RF_YLE280U.YLE280_GreenLedOn(); * RF_YLE280U.YLE280_RedLedOff(); * } * else if(RF_YLE280U.YLE280_GetReaderCode() == 0) * { * RF_YLE280U.YLE280_GreenLedOff(); * RF_YLE280U.YLE280_RedLedOn(); * }*/ Byte[] x = new Byte[20]; int result = RF_YLE280U.YLE280_GetSerialNo(x); if (result == 0 && /*x.ToHexString() != ReadBuf.ToHexString() &&*/ Status != 0) { ReadBuf = x; string s = ReadBuf.ToHexString(); string t = string.Empty; for (int i = s.Length - 2; i >= 0; i -= 2) { t += s.Substring(i, 2); t += ":"; } t = t.Substring(0, t.Length - 1); while (t.StartsWith("00:")) { t = t.Substring(3); } lbInfo.Items.Add("UID:" + t); } Status = result; }
private void button_GetUID_Click(object sender, EventArgs e) { int result = RF_YLE280U.YLE280_GetSerialNo(ReadBuf); if (result == RF_YLE280U.YLE280_OK) { //读取序列号成功,其中数据在ReadBuf中,将ReadBuf中的数据转换成十六进制,并显示到界面上 lbInfo.Items.Add("Get UID Succeed."); string s = ReadBuf.ToHexString(); string t = string.Empty; for (int i = s.Length - 2; i >= 0; i -= 2) { t += s.Substring(i, 2); t += ":"; } t = t.Substring(0, t.Length - 1); while (t.StartsWith("00:")) { t = t.Substring(3); } lbInfo.Items.Add("UID:" + t); } else { //数据读取失败,可将结果显示到界面上 lbInfo.Items.Add("Get UID failed! Error " + result); } }