Exemple #1
0
        //判断连接是否成功,<0 ,连接不成功.0可以读写,1连接成功,但是没插卡.
        private static short IC_Status(int icdev)
        {
            uint  tagType = 0;
            Int16 result  = Dcrf32.dc_request(icdev, 2, ref tagType); //获取卡类型,为4,表示mifare卡

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 在固定的位置读出固定长度的数据
        /// </summary>
        private static short IC_Read_hex(int icdev, int offset, int len, StringBuilder Databuffer)
        {
            Int16 result = 0;

            result = Dcrf32.dc_authentication(icdev, pwd_mode, getSecNr(offset));    //校验第0套密码;
            if (result != 0)
            {
                return(result);
            }
            result = Dcrf32.dc_read_hex(icdev, offset, Databuffer);     //获取数据
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 在固定的位置写入固定长度的数据
        /// </summary>
        private static short IC_Write(int icdev, int offset, int Length, byte[] Databuffer)
        {
            Int16 result = 0;

            result = Dcrf32.dc_authentication(icdev, pwd_mode, getSecNr(offset));    //校验第0套密码;
            if (result != 0)
            {
                return(result);
            }
            result = Dcrf32.dc_write(icdev, offset, Databuffer);
            return(result);
        }
Exemple #4
0
        /// <summary>
        /// 在固定的位置写入固定长度的数据
        /// </summary>
        private static short IC_Write_hex(int icdev, int offset, int Length, string Databuffer)
        {
            Int16 result = 0;

            result = Dcrf32.dc_authentication(icdev, pwd_mode, getSecNr(offset));    //校验第0套密码;
            if (result != 0)
            {
                return(result);
            }
            string data = addZero(Databuffer, 32, true);

            result = Dcrf32.dc_write_hex(icdev, offset, data);
            return(result);
        }
Exemple #5
0
        /// <summary>
        /// 更改密码(0为更改成功)
        /// </summary>
        private static short IC_ChangePass(int icdev, int pwd_postion, int secnr_index, string oldPassWord, string newPassWord)
        {
            Int16 result = 0;

            result = Dcrf32.dc_authentication(icdev, pwd_mode, secnr_index);
            result = ICCardUtility.IC_CheckPass_4442hex(icdev, oldPassWord, secnr_index); //校验出厂密码
            if (result != 0)
            {
                return(result);
            }
            string data = newPassWord + "FF078069" + newPassWord;

            result = Dcrf32.dc_write_hex(icdev, pwd_postion, data);
            return(result);
        }
Exemple #6
0
        /// <summary>
        /// 检查原始密码(不等于0为校验失败)
        /// </summary>
        private static short IC_CheckPass_4442hex(int icdev, string Password, int index = secnr_index)
        {
            Int16 result   = 0;
            ulong icCardNo = 0;

            //B_ICPass = new byte[6] { 0x77, 0x88, 0x52, 0x01, 0x31, 0x45 };
            for (int i = 0; i < 6; i++)
            {
                B_ICPass[i] = Convert.ToByte(Password.Substring(i * 2, 2), 16);
            }
            //B_ICPass = Encoding.ASCII.GetBytes(Password);
            result = Dcrf32.dc_load_key(icdev, pwd_mode, index, B_ICPass); //密码加载到设备
            result = Dcrf32.dc_card(icdev, pwd_mode, ref icCardNo);        //读取卡号,校验之前必须调用
            result = Dcrf32.dc_authentication(icdev, pwd_mode, index);     //校验出厂密码
            return(result);
        }
Exemple #7
0
 /// <summary>
 /// 防卡冲突,返回卡的序列号
 /// </summary>
 private static short dc_anticoll(int icdev, ref ulong _Snr)
 {
     return(Dcrf32.dc_anticoll(icdev, 0, ref _Snr));
 }
Exemple #8
0
 /// <summary>
 /// 关闭端口
 /// </summary>
 private static short IC_ExitComm(int icdev)
 {
     return(Dcrf32.dc_exit(icdev));
 }
Exemple #9
0
 /// <summary>
 /// 初始化端口
 /// </summary>
 private static int IC_InitComm(short Port)
 {
     return(Dcrf32.dc_init(Port, 57600));
 }
Exemple #10
0
 /// <summary>
 /// 读设备硬件版本号
 /// </summary>
 private static int IC_ReadVer(int icdev, byte[] Databuffer)
 {
     return(Dcrf32.dc_getver(icdev, Databuffer));
 }
Exemple #11
0
 /// <summary>
 /// 发出声音
 /// </summary>
 private static short IC_DevBeep(int icdev, uint intime)
 {
     return(Dcrf32.dc_beep(icdev, intime));
 }