예제 #1
0
        /// <summary>
        ///发送控制命令
        /// </summary>
        /// <param name="code"></param>
        /// <param name="retBuffer"></param>
        /// <returns></returns>
        public override int SendCommand(string code, ref string retBuffer)
        {
            try
            {
                int    st;
                byte   rlen  = 0;
                byte[] rbuff = new byte[128];

                byte[] searchbytes = COMM.DataConvert.HexStringToByteArray(code);

                st = DCRFHeader.dc_pro_command(icDev, (byte)searchbytes.Length, searchbytes, ref rlen, rbuff, (byte)7);

                if (st != 0)
                {
                    this.SendErrorInfo("发送命令失败,请重试!");
                    DCRFHeader.dc_exit(icDev);
                    return(st);
                }
                retBuffer = COMM.DataConvert.byteToChar(rlen, rbuff);

                return(1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
 public void Dispose()
 {
     try
     {
         DCRFHeader.dc_exit(icDev);
     }
     catch
     {
         throw;
     }
 }
예제 #3
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <returns></returns>
        public override bool Intial()
        {
            try
            {
                char[] ssnr = new char[128];

                int st;

                icDev = DCRFHeader.dc_init(port, rate);
                if (icDev < 0)
                {
                    this.SendErrorInfo("打开设备失败,请重试!");

                    return(false);
                }

                ///设置读非接触卡A类型
                st = DCRFHeader.dc_config_card(icDev, 0x41);
                if (st < 0)
                {
                    this.SendErrorInfo("配置卡设备参数,请重试!");

                    return(false);
                }

                st = DCRFHeader.dc_reset(icDev, 10);
                if (st < 0)
                {
                    this.SendErrorInfo("初始化卡设备参数,请重试!");

                    return(false);
                }

                st = DCRFHeader.dc_beep(icDev, 3);
                if (st < 0)
                {
                    this.SendErrorInfo("初始化卡设备参数,请重试!");

                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        /// <summary>
        /// 检查卡信息
        /// </summary>
        /// <returns></returns>
        public bool CheckCard()
        {
            try
            {
                int  st;
                byte rlen = 0;

                if (icDev == 0)
                {
                    return(false);
                }

                char[] ssnr  = new char[128];
                byte[] rbuff = new byte[128];

                st = DCRFHeader.dc_card_double_hex(icDev, 0, ssnr);
                if (st != 0)
                {
                    this.SendErrorInfo("寻卡失败,请将卡片移走重新放入读卡区重试!");
                    DCRFHeader.dc_exit(icDev);
                    return(false);
                }

                SendReportInfo(DataConvert.ArrayToStirng(ssnr));


                st = DCRFHeader.dc_pro_reset(icDev, ref rlen, rbuff);
                if (st != 0)
                {
                    this.SendErrorInfo("寻卡失败,请将卡片移走重新放入读卡区重试!");
                    DCRFHeader.dc_exit(icDev);
                    return(false);
                }


                SendReportInfo("寻卡成功!");

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
        /// <summary>
        /// 关闭
        /// </summary>
        public override void Exit()
        {
            try
            {
                int st;

                st = DCRFHeader.dc_exit(icDev);

                if (st != 0)
                {
                    this.SendErrorInfo("关闭设备失败!");
                    DCRFHeader.dc_exit(icDev);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }