Esempio n. 1
0
        // подготовка метки по индексу в списке инвентаризации
        private void GetRFIDLabelInfo()
        {
            byte[] aB;

            LReady      = false;
            XTIDPresent = false;
            lSerialInt  = 0;

            aEPC   = new byte[0];
            aTID   = new byte[0];
            aBLR   = new byte[0];
            BinEPC = "";

            nCRC   = nLenEPC = nPC = 0;
            nMDID  = nModNum = 0;
            Secure = false;

            try
            {
                if (Drv.SetDword("RFID.CurrentId", nCurInList))
                {
                    aEPC   = Drv.GetBin("RFID.ChipId");
                    LReady = true;
                    PassLocked();
                    LReady4Write = !aSecured[1];
                    //if (aSecured[1] && (AccessPassword == 0))
                    //{
                    //    return;
                    //}

                    if (Drv.SetBin("RFID.EPCC1G2.Id", aEPC))
                    {
                        // доступ
                        Drv.SetBool("RFID.EPCC1G2.Secured", false);

                        //Drv.SetBool("RFID.EPCC1G2.Secured", aSecured[1]);

                        if (Drv.SetDword("RFID.EPCC1G2.Bank", 2))
                        {// чтение TID
                            int nC = 4;

                            TIDInfo(Drv);

                            bool bOld = Drv.throwsException;
                            Drv.throwsException = false;
                            for (nC = 4; nC <= 12; nC = nC + 2)
                            {
                                Drv.SetDword("RFID.BlockPointer", 0);
                                Drv.SetDword("RFID.BlockCount", nC);
                                aB = Drv.GetBin("RFID.BlockData");
                                if ((aB == null) || (aB.Length == 0))
                                {
                                    continue;
                                }
                                aTID = aB;
                            }
                            Drv.throwsException = bOld;
                            nMDID = ((uint)aTID[2]) >> 4;
                            nMDID = ((uint)aTID[1] << 8) + nMDID;

                            nModNum = ((uint)aTID[2]) & 0x0F;
                            nModNum = (nModNum << 8) + ((uint)aTID[3]);
                        }
                        if (Drv.SetDword("RFID.EPCC1G2.Bank", 1))
                        {// чтение служебной перед EPC
                            Drv.SetDword("RFID.BlockPointer", 0);
                            Drv.SetDword("RFID.BlockCount", 16);
                            aBLR = Drv.GetBin("RFID.BlockData");

                            nCRC    = ((uint)aBLR[0] << 8) + ((uint)aBLR[1]);
                            nPC     = ((uint)aBLR[2] << 8) + ((uint)aBLR[3]);
                            nLenEPC = ((uint)aBLR[2] >> 3);
                        }
                    }
                    else
                    {
                        aBLR = aEPC;
                    }
                }
                //*****
            }
            catch (Exception e)
            {
                LReady = false;
                MessageBox.Show("RFID Error!");
            }
        }