Ejemplo n.º 1
0
        //查看网络配置参数
        public Status_enum GetCommCfg(byte ReaderID, ref CommCfg cfg)
        {
            byte[]  temp    = new byte[20];
            Package package = new Package(CmdEnum.CMD_GET_TCP_CFG, ReaderID);

            if (SendPackage(package))
            {
                //接收
                Status_enum status = WaitResp(package.CMD, ref temp, ref tempbyte);

                if (status == Status_enum.SUCCESS)
                {
                    if (cfg == null)
                    {
                        cfg = new CommCfg();
                    }
                    cfg.ConvBytesToUserCfg(temp);
                }
                else
                {
                    status = Status_enum.FAILURE;
                }

                return(status);
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Ejemplo n.º 2
0
        public Status_enum AntiCollision(byte ReaderID, List <Antenna_enum> AntList, ref AntiColliResult result)
        {
            byte[] temp = new byte[1] {
                0
            };

            foreach (Antenna_enum ant in AntList)
            {
                temp[0] |= (byte)(1 << (int)ant);
            }

            Package package = new Package(CmdEnum.CMD_ANTI_COLLISION, ReaderID, temp, 0, 1);

            AntiReqFlg = true;
            AntiResult.UidList.Clear();
            if (SendPackage(package))
            {
                //接收
                Status_enum status = WaitResp(package.CMD, ref temp, ref tempbyte, ANTI_COLLISION_TIMEOUT);
                result     = new AntiColliResult(AntiResult);
                AntiReqFlg = false;
                AntiResult.UidList.Clear();
                return(status);
            }
            else
            {
                AntiReqFlg = false;
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Ejemplo n.º 3
0
        //查看用户配置
        public Status_enum GetUserCfg(byte ReaderID, ref UserCfg cfg)
        {
            byte[]  temp    = new byte[UserCfg.USERCFGSIZE];
            Package package = new Package(CmdEnum.CMD_GET_USER_CONFIG, ReaderID);

            if (SendPackage(package))
            {
                //接收
                Status_enum status = WaitResp(package.CMD, ref temp, ref tempbyte);

                if ((status == Status_enum.SUCCESS) && (tempbyte == UserCfg.USERCFGSIZE))
                {
                    cfg.ConvBytesToUserCfg(temp);
                }
                else
                {
                    status = Status_enum.FAILURE;
                }

                return(status);
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Ejemplo n.º 4
0
        bool ExecHeartBeat()
        {
            byte gpiStatus = 0, gpiCnt = 0;
            int  i = 0;

            for (i = 0; i < 2; i++)
            {
                try
                {
                    WaitHeartBeatCmdResp = true;
                    Package package = new Package(CmdEnum.CMD_GET_PIN_LEVEL, ReaderID);

                    if (SendPackage(package))
                    {
                        byte[] temp = new byte[2];

                        Status_enum status = WaitHeartBeatResp(package.CMD, ref temp, ref tempbyte, DEFAULT_TIMEOUT);
                        if (status == Status_enum.SUCCESS)
                        {
                            gpiCnt    = temp[0];
                            gpiStatus = temp[1];
                        }
                        return(true);
                    }
                }
                finally
                {
                    WaitHeartBeatCmdResp = false;
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        //获取标签系统信息
        public Status_enum GetTagInfo(byte ReaderID, Opcode_enum Opcode, byte[] UID_I, ref byte InformationFlag,
                                      ref byte[] UID_O, ref byte DSFID, ref byte AFI, ref byte BlockCnt, ref byte BlockSize, ref byte ICReference)
        {
            byte[] temp = new byte[14];

            if (UID_O.Length < UIDLEN)
            {
                return(Status_enum.PARAM_ERR);
            }

            Package package = new Package(CmdEnum.CMD_GET_VICC_INFO, ReaderID);

            if ((UID_I != null) && (UID_I.Length >= 8))
            {
                package.Opcode = Opcode;
            }
            else
            {
                package.Opcode = Opcode_enum.NON_ADDRESS_MODE;
            }
            if (package.Opcode == Opcode_enum.ADDRESS_MODE)
            {
                Array.Copy(UID_I, 0, package.Datas, package.DataLen, 8);
                package.DataLen += 8;
                package.BCC      = tool.GetBCC(package.Datas, 0, package.DataLen);
            }
            if (SendPackage(package))
            {
                Status_enum status = WaitResp(package.CMD, ref temp, ref tempbyte);
                if (status == Status_enum.SUCCESS)
                {
                    int pos = 0;
                    InformationFlag = temp[pos++];
                    for (int i = 0; i < UIDLEN; i++)
                    {
                        UID_O[i] = temp[pos++];
                    }
                    DSFID       = temp[pos++];
                    AFI         = temp[pos++];
                    BlockCnt    = temp[pos++];
                    BlockSize   = temp[pos++];
                    ICReference = temp[pos++];
                }
                return(status);
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Ejemplo n.º 6
0
        public Status_enum GetTagInfo(byte ReaderID, Opcode_enum Opcode, byte[] UID, ref TagInfo info, Antenna_enum ant)
        {
            byte[] temp = new byte[14];

            Package package = new Package(CmdEnum.CMD_GET_VICC_INFO, ReaderID, ant);

            if ((UID != null) && (UID.Length >= 8))
            {
                package.Opcode = Opcode;
            }
            else
            {
                package.Opcode = Opcode_enum.NON_ADDRESS_MODE;
            }
            if (package.Opcode == Opcode_enum.ADDRESS_MODE)
            {
                Array.Copy(UID, 0, package.Datas, package.DataLen, 8);
                package.DataLen += 8;
                package.BCC      = tool.GetBCC(package.Datas, 0, package.DataLen);
            }
            if (SendPackage(package))
            {
                Status_enum status = WaitResp(package.CMD, ref temp, ref tempbyte);
                if (status == Status_enum.SUCCESS)
                {
                    if (info == null)
                    {
                        info = new TagInfo();
                    }
                    int pos = 0;
                    info.InformationFlag = temp[pos++];
                    for (int i = 0; i < UIDLEN; i++)
                    {
                        info.UID[i] = temp[pos++];
                    }
                    info.DSFID        = temp[pos++];
                    info.AFI          = temp[pos++];
                    info.BlockCnt     = temp[pos++];
                    info.BlockSize    = temp[pos++];
                    info.ICrefcerence = temp[pos++];
                }
                return(status);
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Ejemplo n.º 7
0
        public Status_enum CheckStatus()
        {
            byte    cnt     = new byte();
            Package package = new Package(CmdEnum.CMD_GET_PIN_LEVEL, ReaderID);

            if (SendPackage(package))
            {
                byte[]      temp   = new byte[2];
                Status_enum status = WaitResp(package.CMD, ref temp, ref cnt);
                return(status);
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Ejemplo n.º 8
0
        //查看功率
        public Status_enum GetPowerLevel(byte ReaderID, ref PowerLevelEnum PowerLevel)
        {
            byte[] temp = new byte[2];

            Package package = new Package(CmdEnum.CMD_GET_POWER_LEVEL, ReaderID);

            if (SendPackage(package))
            {
                //接收
                Status_enum status = WaitResp(package.CMD, ref temp, ref tempbyte);
                if (status == Status_enum.SUCCESS)
                {
                    PowerLevel = (PowerLevelEnum)temp[0];
                }
                return(status);
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Ejemplo n.º 9
0
        public Status_enum GetGpiStatus(byte ReaderID, ref byte GpiStatus, ref byte cnt)
        {
            Package package = new Package(CmdEnum.CMD_GET_PIN_LEVEL, ReaderID);

            if (SendPackage(package))
            {
                byte[] temp = new byte[2];

                Status_enum status = WaitResp(package.CMD, ref temp, ref cnt);
                if (status == Status_enum.SUCCESS)
                {
                    cnt       = temp[0];
                    GpiStatus = temp[1];
                }
                return(status);
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Ejemplo n.º 10
0
        //获取自动读取的功能
        public Status_enum GetAutoReadFunc(byte ReaderID, ref AutoReadFuncEnum func, ref byte block)
        {
            byte[] temp = new byte[3];

            Package package = new Package(CmdEnum.CMD_GET_AUTO_READ_FUNC, ReaderID);

            if (SendPackage(package))
            {
                //接收
                Status_enum status = WaitResp(package.CMD, ref temp, ref tempbyte);
                if (status == Status_enum.SUCCESS)
                {
                    func  = (AutoReadFuncEnum)temp[1];
                    block = temp[2];
                }
                return(status);
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Ejemplo n.º 11
0
 public extern static void Invoke(Status_enum status);