Exemplo n.º 1
0
        // установка флагов парольной защиты
        public bool PassLocked()
        {
            bool
                bOld = Drv.throwsException,
                bRet = false;

            //byte[]
            //    aPass;

            try
            {
                Drv.throwsException = true;
                Drv.SetBool("RFID.EPCC1G2.Secured", false);

                if (Drv.SetDword("RFID.EPCC1G2.Bank", 0))
                {// чтение Pass
                 //Drv.SetDword("RFID.BlockPointer", 0);
                 //Drv.SetDword("RFID.BlockCount", 4);
                 //try
                 //{
                 //    aPass = Drv.GetBin("RFID.BlockData");
                 //}
                 //catch
                 //{
                 //    aSecured[0] = true;
                 //}
                 //Drv.SetDword("RFID.BlockPointer", 4);
                 //Drv.SetDword("RFID.BlockCount", 4);
                 //try
                 //{
                 //    aPass = Drv.GetBin("RFID.BlockData");
                 //}
                 //catch
                 //{
                 //    aSecured[1] = true;
                 //}

                    try
                    {
                        Drv.SetDword("RFID.BlockPointer", 0);
                        Drv.SetDword("RFID.BlockCount", 8);
                        aRes         = Drv.GetBin("RFID.BlockData");
                        KillPassword = (int)Bytes2Int(aRes, 0);
                        if (KillPassword > 0)
                        {
                            aSecured[0] = true;
                        }
                        //AccessPassword = (int)Bytes2Int(aRes, 4);
                        //if (AccessPassword > 0)
                        //    aSecured[1] = true;
                    }
                    catch
                    {
                        bRet            =
                            aSecured[1] = true;
                    }


                    //bRet = true;
                }
            }
            catch
            {
            }
            finally
            {
                Drv.throwsException = bOld;
            }
            return(bRet);
        }
Exemplo n.º 2
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!");
            }
        }