Пример #1
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);
            }
        }
Пример #2
0
        public static byte[] ConvUserCfgToBytes(UserCfg cfg)
        {
            byte[] data    = new byte[USERCFGSIZE];
            byte   AntStat = 0;

            int pos = 0;

            data[pos++] = (byte)cfg.WorkMode;
            data[pos++] = cfg.ReaderID;
            data[pos++] = (byte)cfg.RFChipPower;
            data[pos++] = (byte)cfg.NeedBCC;
            data[pos++] = (byte)cfg.CommPort;


            for (int i = 0; i < cfg.AntStatus.Length; i++)
            {
                AntStat |= (byte)((cfg.AntStatus[i] ? 1 : 0) << i);
            }
            if (AntStat == 0)
            {
                data[pos++] = (byte)cfg.BlockSize;
            }
            else
            {
                data[pos++] = AntStat;
            }

            data[pos++] = (byte)cfg.AvailableTime;

            return(data);
        }
Пример #3
0
        //设置用户配置
        public Status_enum SetUserCfg(byte ReaderID, UserCfg cfg)
        {
            byte[]  temp      = null;
            byte[]  cfg_array = UserCfg.ConvUserCfgToBytes(cfg);
            Package package   = new Package(CmdEnum.CMD_SET_USER_CONFIG, ReaderID, cfg_array, 0, (byte)cfg_array.Length);

            if (SendPackage(package))
            {
                //接收
                return(WaitResp(package.CMD, ref temp, ref tempbyte, SET_CFG_TIMEOUT));
            }
            else
            {
                return(Status_enum.SERIAL_CLOSED);
            }
        }
Пример #4
0
        public bool StartHeartBeat()
        {
            UserCfg cfg = new UserCfg();

            if (GetUserCfg(0x00, ref cfg) == Status_enum.SUCCESS)
            {
                ReaderID = cfg.ReaderID;
            }
            else
            {
                return(false);
            }

            if (HeartBeatThreadExit && ((HeartBeatThread == null) || (HeartBeatThread.IsAlive == false)))
            {
                HeartBeatThreadExit          = false;
                HeartBeatThread              = new Thread(HeartBeatThreadFunc);
                HeartBeatThread.IsBackground = true;
                HeartBeatThread.Start();
            }

            return(true);
        }