public static extern int felicaGetUID(int h, ushort srcAddr, ushort targetAddr, Byte mode, ref FELICA_UIDPARAM pUid, Byte[] pTxFrame, Byte[] pRxFrame);
private void buttonReadFelicaTags_Click(object sender, EventArgs e) { if (serialDevice < 0) { MessageBox.Show("请先打开串口"); return; } clearOpResult(); Byte[] buffer = new Byte[255]; ushort[] addrArray = new ushort[2]; Byte mode = 0; FELICA_UIDPARAM pUid = new FELICA_UIDPARAM(); pUid.uid = new Byte[hfReaderDll.HFREADER_FELICA_UID_LEN * hfReaderDll.HFREADER_FELICA_UID_MAX_NUM]; Byte[] sendBuffer = new Byte[1024]; Byte[] rcvBuffer = new Byte[1024]; if (!GetDeviceAddr(addrArray)) { return; } if (this.checkBoxUidEnable.Checked) { if (this.radioButtonRequestTagIdle.Checked) { mode = hfReaderDll.HFREADER_READ_UID_NORMAL; } else { mode = hfReaderDll.HFREADER_READ_UID_REPEAT; } } else { if (this.radioButtonRequestTagIdle.Checked) { mode = hfReaderDll.HFREADER_READ_UID_NORMAL; } else { mode = hfReaderDll.HFREADER_READ_UID_REPEAT; } } while (bOperatingSerial) { ; } bOperatingSerial = true; int rlt = hfReaderDll.felicaGetUID(serialDevice, addrArray[0], addrArray[1], mode, ref pUid, sendBuffer, rcvBuffer); bOperatingSerial = false; if (rlt > 0) { this.radioButtonOpFelicaTagRltOpOK.Checked = false; this.radioButtonOpFelicaTagRltOpFail.Checked = false; this.textBoxOpFelicaTagRltSrcAddr.Text = pUid.result.srcAddr.ToString("X").PadLeft(4, '0'); this.textBoxOpFelicaTagRltDestAddr.Text = pUid.result.targetAddr.ToString("X").PadLeft(4, '0'); if (pUid.num > 0) { int i = 0, j = 0; String s; for (i = 0; i < pUid.num; i++) { s = ""; for (j = 0; j < hfReaderDll.HFREADER_FELICA_UID_LEN; j++) { s += pUid.uid[i * hfReaderDll.HFREADER_FELICA_UID_LEN + j].ToString("X").PadLeft(2, '0'); } if (this.listBoxTagInfo.FindString(s) < 0) { this.listBoxTagInfo.Items.Add(s); } } this.textBoxReadTagNum.Text = this.listBoxTagInfo.Items.Count.ToString("X").PadLeft(2, '0'); this.textBoxRemainTagNum.Text = pUid.remainNum.ToString("X").PadLeft(2, '0'); } } DisplayRcvInf(rcvBuffer, "查询场内标签返回:"); DisplaySendInf(sendBuffer, "查询场内标签:"); }