Exemplo n.º 1
0
        private void buttonGetUid_Click(object sender, EventArgs e)
        {
            if (serialDevice < 0)
            {
                MessageBox.Show("请先打开串口");
                return;
            }
            clearOpResult();

            Byte[]   buffer    = new Byte[255];
            ushort[] addrArray = new ushort[2];

            ISO14443A_UID pUid = new ISO14443A_UID();

            pUid.uid = new Byte[hfReaderDll.HFREADER_ISO14443A_LEN_MAX_UID];

            HFREADER_OPRESULT pResult = new HFREADER_OPRESULT();

            Byte[] sendBuffer = new Byte[1024];
            Byte[] rcvBuffer  = new Byte[1024];

            if (!GetDeviceAddr(addrArray))
            {
                return;
            }

            if (GetHexInput(this.textBoxTagUid.Text, pUid.uid, this.textBoxTagUid.Text.Length / 2) <= 0)
            {
                return;
            }


            while (bOperatingSerial)
            {
                ;
            }
            bOperatingSerial = true;
            int rlt = hfReaderDll.emulNfcType2GetUID(serialDevice, addrArray[0], addrArray[1], ref pUid, ref pResult, sendBuffer, rcvBuffer);

            bOperatingSerial = false;
            if (rlt > 0)
            {
                DisplayOpResult(ref pResult);

                if (pResult.flag == 0)
                {
                    int    i = 0;
                    String s = "";
                    this.textBoxTagType.Text = pUid.type.ToString("X").PadLeft(4, '0');
                    this.textBoxTagSak.Text  = pUid.sak.ToString("X").PadLeft(2, '0');
                    for (i = 0; i < pUid.len; i++)
                    {
                        s += pUid.uid[i].ToString("X").PadLeft(2, '0');
                    }
                    this.textBoxTagUid.Text = s;
                }
            }
            DisplayRcvInf(rcvBuffer, "获取UID返回:");
            DisplaySendInf(sendBuffer, "获取UID:");
        }
Exemplo n.º 2
0
 private void DisplayOpResult(ref HFREADER_OPRESULT pResult)
 {
     this.textBoxOpEmulNfcType2TagRltSrcAddr.Text  = pResult.srcAddr.ToString("X").PadLeft(4, '0');
     this.textBoxOpEmulNfcType2TagRltDestAddr.Text = pResult.targetAddr.ToString("X").PadLeft(4, '0');
     if (pResult.flag == 0)
     {
         this.radioButtonOpEmulNfcType2TagRltOpOK.Checked = true;
         this.radioButtonOpEmulNfcType2ErrTypeOK.Checked  = true;
     }
     else
     {
         this.radioButtonOpEmulNfcType2TagRltOpFail.Checked = true;
         if (pResult.errType == 0x01)
         {
             this.radioButtonOpEmulNfcType2ErrTypeTag.Checked = true;
         }
         else if (pResult.errType == 0x02)
         {
             this.radioButtonOpEmulNfcType2ErrTypeCrc.Checked = true;
         }
         else if (pResult.errType == 0x03)
         {
             this.radioButtonOpEmulNfcType2ErrTypeRsp.Checked = true;
         }
         else if (pResult.errType == 0x04)
         {
             this.radioButtonOpEmulNfcType2ErrTypeParam.Checked = true;
         }
         else
         {
             this.radioButtonOpEmulNfcType2ErrTypeRsp.Checked = true;
         }
     }
     //this.labelUserTimer.Text = pResult.t.ToString("D") + "ms";
 }
Exemplo n.º 3
0
        private void buttonRFControl_Click(object sender, EventArgs e)
        {
            if (serialDevice < 0)
            {
                MessageBox.Show("请先打开串口");
                return;
            }

            Byte[]   buffer    = new Byte[255];
            ushort[] addrArray = new ushort[2];

            Byte rfCtrl = 0;
            HFREADER_OPRESULT pResult = new HFREADER_OPRESULT();

            Byte[] sendBuffer = new Byte[1024];
            Byte[] rcvBuffer  = new Byte[1024];

            if (!GetDeviceAddr(addrArray))
            {
                return;
            }

            if (this.radioButtonRFOpen.Checked)
            {
                rfCtrl = hfReaderDll.HFREADER_RF_OPEN;
            }
            else if (this.radioButtonRFClose.Checked)
            {
                rfCtrl = hfReaderDll.HFREADER_RF_CLOSE;
            }
            else
            {
                rfCtrl = hfReaderDll.HFREADER_RF_RESET;
            }

            //LockUart();
            int rlt = hfReaderDll.hfReaderCtrlRf(serialDevice, addrArray[0], addrArray[1], rfCtrl, ref pResult, sendBuffer, rcvBuffer);

            //UnlockUart();

            if (rlt > 0)
            {
                if (pResult.flag == 0)
                {
                    this.radioButtonRfRltOpOK.Checked = true;
                }
                else
                {
                    this.radioButtonRfRltOpFail.Checked = true;
                }

                this.textBoxRfRltSrcAddr.Text  = pResult.srcAddr.ToString("X").PadLeft(4, '0');
                this.textBoxRfRltDestAddr.Text = pResult.targetAddr.ToString("X").PadLeft(4, '0');
            }
            DisplayRcvInf(rcvBuffer, "射频控制返回:");
            DisplaySendInf(sendBuffer, "射频控制:");
        }
Exemplo n.º 4
0
        private void buttonTrgCtrl_Click(object sender, EventArgs e)
        {
            if (serialDevice < 0)
            {
                MessageBox.Show("请先打开串口");
                return;
            }

            Byte[]   buffer    = new Byte[255];
            ushort[] addrArray = new ushort[2];

            Byte trgCtrl = 0;
            HFREADER_OPRESULT pResult = new HFREADER_OPRESULT();

            Byte[] sendBuffer = new Byte[1024];
            Byte[] rcvBuffer  = new Byte[1024];

            if (!GetDeviceAddr(addrArray))
            {
                return;
            }

            if (this.radioButtonTrg.Checked)
            {
                trgCtrl = hfReaderDll.HFREADER_TRG_INVENTORY;
            }
            else
            {
                trgCtrl = hfReaderDll.HFREADER_TRG_NO;
            }

            LockUart();
            int rlt = hfReaderDll.hfReaderTrigger(serialDevice, addrArray[0], addrArray[1], trgCtrl, ref pResult, sendBuffer, rcvBuffer);

            UnlockUart();

            if (rlt > 0)
            {
                if (pResult.flag == 0)
                {
                    this.radioButtonTrgRltOpOK.Checked = true;
                }
                else
                {
                    this.radioButtonTrgRltOpFail.Checked = true;
                }

                this.textBoxTrgRltSrcAddr.Text  = pResult.srcAddr.ToString("X").PadLeft(4, '0');
                this.textBoxTrgRltDestAddr.Text = pResult.targetAddr.ToString("X").PadLeft(4, '0');
            }
            DisplayRcvInf(rcvBuffer, "触发控制返回:");
            DisplaySendInf(sendBuffer, "触发控制:");
        }
Exemplo n.º 5
0
        private void buttonSetUid_Click(object sender, EventArgs e)
        {
            if (serialDevice < 0)
            {
                MessageBox.Show("请先打开串口");
                return;
            }
            clearOpResult();

            Byte[]   buffer    = new Byte[255];
            ushort[] addrArray = new ushort[2];

            ISO14443A_UID pUid = new ISO14443A_UID();

            pUid.uid = new Byte[hfReaderDll.HFREADER_ISO14443A_LEN_MAX_UID];

            HFREADER_OPRESULT pResult = new HFREADER_OPRESULT();

            Byte[] sendBuffer = new Byte[1024];
            Byte[] rcvBuffer  = new Byte[1024];

            if (!GetDeviceAddr(addrArray))
            {
                return;
            }

            if (GetHexInput(this.textBoxTagUid.Text, pUid.uid, this.textBoxTagUid.Text.Length / 2) <= 0)
            {
                return;
            }
            pUid.len  = (uint)(this.textBoxTagUid.Text.Length / 2);
            pUid.type = Convert.ToUInt16(this.textBoxTagType.Text, 16);
            pUid.sak  = Convert.ToByte(this.textBoxTagSak.Text, 16);


            while (bOperatingSerial)
            {
                ;
            }
            bOperatingSerial = true;
            int rlt = hfReaderDll.emulNfcType2SetUID(serialDevice, addrArray[0], addrArray[1], ref pUid, ref pResult, sendBuffer, rcvBuffer);

            bOperatingSerial = false;
            if (rlt > 0)
            {
                DisplayOpResult(ref pResult);
            }
            DisplayRcvInf(rcvBuffer, "设置UID返回:");
            DisplaySendInf(sendBuffer, "设置UID:");
        }
Exemplo n.º 6
0
 public static extern int iso14443BHalt(int h, ushort srcAddr, ushort targetAddr, ref HFREADER_OPRESULT pResult, Byte[] pTxFrame, Byte[] pRxFrame);
Exemplo n.º 7
0
 public static extern int iso14443BGetIDCardUid(int h, ushort srcAddr, ushort targetAddr, Byte[] pUid, ref HFREADER_OPRESULT pResult, Byte[] pTxFrame, Byte[] pRxFrame);
Exemplo n.º 8
0
 public static extern int iso15693SetEas(int h, ushort srcAddr, ushort targetAddr, Byte[] pUid, Byte cmd, ref HFREADER_OPRESULT pResult, Byte[] pTxFrame, Byte[] pRxFrame);
Exemplo n.º 9
0
 public static extern int iso15693WriteDsfid(int h, ushort srcAddr, ushort targetAddr, Byte[] pUid, Byte defid, ref HFREADER_OPRESULT pResult, Byte[] pTxFrame, Byte[] pRxFrame);
Exemplo n.º 10
0
 public static extern int iso15693LockBlock(int h, ushort srcAddr, ushort targetAddr, Byte[] pUid, Byte blockAddr, ref HFREADER_OPRESULT pResult, Byte[] pTxFrame, Byte[] pRxFrame);
Exemplo n.º 11
0
 public static extern int emulNfcType2GetUID(int h, ushort srcAddr, ushort targetAddr, ref ISO14443A_UID pUid, ref HFREADER_OPRESULT pResult, Byte[] pTxFrame, Byte[] pRxFrame);
Exemplo n.º 12
0
 public static extern int iso14443AAuthUltralightC(int h, ushort srcAddr, ushort targetAddr, Byte[] pKey, ref HFREADER_OPRESULT pResult, Byte[] pTxFrame, Byte[] pRxFrame);
Exemplo n.º 13
0
 public static extern int hfReaderSelectAnt(int h, ushort srcAddr, ushort targetAddr, Byte[] pAnt, ref HFREADER_OPRESULT pResult, Byte[] pTxFrame, Byte[] pRxFrame);
Exemplo n.º 14
0
 public static extern int hfReaderTrigger(int h, ushort srcAddr, ushort targetAddr, Byte triggerCtrl, ref HFREADER_OPRESULT pResult, Byte[] pTxFrame, Byte[] pRxFrame);
Exemplo n.º 15
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (serialDevice < 0)
            {
                MessageBox.Show("请先打开串口");
                return;
            }

            Byte[]   buffer    = new Byte[255];
            ushort[] addrArray = new ushort[2];

            Byte trgCtrl = 0;
            HFREADER_OPRESULT pResult = new HFREADER_OPRESULT();

            Byte[] sendBuffer = new Byte[1024];
            Byte[] rcvBuffer  = new Byte[1024];
            Byte[] ant        = new Byte[6];

            if (!GetDeviceAddr(addrArray))
            {
                return;
            }

            if (this.radioButtonAnt1.Checked)
            {
                ant[0] = 0x01;
            }
            else
            {
                ant[0] = 0x00;
            }
            if (this.radioButtonAnt2.Checked)
            {
                ant[1] = 0x01;
            }
            else
            {
                ant[1] = 0x00;
            }
            if (this.radioButtonAnt3.Checked)
            {
                ant[2] = 0x01;
            }
            else
            {
                ant[2] = 0x00;
            }
            if (this.radioButtonAnt4.Checked)
            {
                ant[3] = 0x01;
            }
            else
            {
                ant[3] = 0x00;
            }
            if (this.radioButtonAnt5.Checked)
            {
                ant[4] = 0x01;
            }
            else
            {
                ant[4] = 0x00;
            }
            if (this.radioButtonAnt6.Checked)
            {
                ant[5] = 0x01;
            }
            else
            {
                ant[5] = 0x00;
            }

            LockUart();
            int rlt = hfReaderDll.hfReaderSelectAnt(serialDevice, addrArray[0], addrArray[1], ant, ref pResult, sendBuffer, rcvBuffer);

            UnlockUart();

            if (rlt > 0)
            {
                if (pResult.flag == 0)
                {
                    this.radioButtonCtrlAntRspOk.Checked = true;
                }
                else
                {
                    this.radioButtonCtrlAntRspFail.Checked = true;
                }

                this.textBoxCtrlAntRspSrcAddr.Text  = pResult.srcAddr.ToString("X").PadLeft(4, '0');
                this.textBoxCtrlAntRspDestAddr.Text = pResult.targetAddr.ToString("X").PadLeft(4, '0');
            }
            DisplayRcvInf(rcvBuffer, "天线控制返回:");
            DisplaySendInf(sendBuffer, "天线控制:");
        }