Exemple #1
0
        public string RecycleCard()
        {
            string ret = "";

            if (!FindCard(out ret))
            {
                return(ret);
            }
            if (!VerifyBKey(out ret)) //return ret;
            {
                quit();
                if (!FindCard(out ret))
                {
                    return(ret);
                }
                if (!VerifyBKey2(out ret))
                {
                    return(ret);
                }
            }
            //原始化卡号信息
            byte[] databuff = new byte[16];
            byte[] buff     = new byte[32];

            string data = "00000000000000000000000000000000";

            buff = Encoding.ASCII.GetBytes(data);
            RFDef.a_hex(buff, databuff, 32);
            st = RFDef.rf_write(icdev, sec * 4, databuff);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFWRITEERR);
            }

            //改密码
            byte[] akey1 = new byte[16];
            byte[] akey2 = new byte[6];
            byte[] bkey1 = new byte[16];
            byte[] bkey2 = new byte[6];
            akey1 = Encoding.ASCII.GetBytes(stroldakey);
            bkey1 = Encoding.ASCII.GetBytes(stroldbkey);
            RFDef.a_hex(akey1, akey2, 12);
            RFDef.a_hex(bkey1, bkey2, 12);
            st = RFDef.rf_changeb3(icdev, sec, akey2, 0, 0, 0, 1, 0, bkey2);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFCHANGEB3ERR);
            }

            //蜂鸣
            st = RFDef.rf_beep(icdev, 3);
            quit();
            return(ConstMsg.RFOK);
        }
Exemple #2
0
 private bool ChangePwd(out string ret)
 {
     //改密码
     byte[] akey1 = new byte[16];
     byte[] akey2 = new byte[6];
     byte[] bkey1 = new byte[16];
     byte[] bkey2 = new byte[6];
     akey1 = Encoding.ASCII.GetBytes(strakey);
     bkey1 = Encoding.ASCII.GetBytes(strbkey);
     RFDef.a_hex(akey1, akey2, 12);
     RFDef.a_hex(bkey1, bkey2, 12);
     st = RFDef.rf_changeb3(icdev, sec, akey2, 3, 3, 3, 3, 0, bkey2);
     if (st != 0)
     {
         quit();
         ret = ConstMsg.RFCHANGEB3ERR;
         return(false);
     }
     ret = ConstMsg.RFOK;
     return(true);
 }
Exemple #3
0
        public string PutOutCard(string strCardID, double dCurCharge, int iCurIg)
        {
            //初始化
            icdev = RFDef.rf_init(port, baud);
            if (icdev < 0)
            {
                quit();
                return(ConstMsg.RFINITERR);
            }

            //寻卡
            UInt16 tagtype = 0;
            byte   size    = 0;
            uint   snr     = 0;

            RFDef.rf_reset(icdev, 10);
            st = RFDef.rf_request(icdev, 1, out tagtype);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFREQUESTERR);
            }

            st = RFDef.rf_anticoll(icdev, 0, out snr);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFANTICOLLERR);
            }

            st = RFDef.rf_select(icdev, snr, out size);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFSELECTERR);
            }

            //验证
            byte[] akey1 = new byte[16];
            byte[] akey2 = new byte[6];

            string akey = "123456789012";

            akey1 = Encoding.ASCII.GetBytes(akey);
            RFDef.a_hex(akey1, akey2, 12);
            st = RFDef.rf_load_key(icdev, 0, sec, akey2);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFLOADKEY_A_ERR);
            }
            st = RFDef.rf_authentication(icdev, 0, sec);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFAUTHENTICATION_A_ERR);
            }

            //写卡号
            byte[] databuff = new byte[16];
            byte[] buff     = new byte[32];
            //int lendata=0;

            string data = strCardID;

            data += "000000000000000000000000000";
            buff  = Encoding.ASCII.GetBytes(data);
            RFDef.a_hex(buff, databuff, 32);
            st = RFDef.rf_write(icdev, sec * 4, databuff);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFWRITEERR);
            }

            //改密码
            byte[] bkey1 = new byte[16];
            byte[] bkey2 = new byte[6];
            akey = "123456789012";
            string bkey = "123456789012";

            akey1 = Encoding.ASCII.GetBytes(akey);
            bkey1 = Encoding.ASCII.GetBytes(bkey);
            RFDef.a_hex(akey1, akey2, 12);
            RFDef.a_hex(bkey1, bkey2, 12);
            st = RFDef.rf_changeb3(icdev, sec, akey2, 3, 3, 3, 3, 0, bkey2);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFCHANGEB3ERR);
            }

            //蜂鸣
            st = RFDef.rf_beep(icdev, 3);
            quit();
            return(ConstMsg.RFOK);
        }
Exemple #4
0
        public string RecycleCard()
        {
            //初始化
            icdev = RFDef.rf_init(port, baud);
            if (icdev < 0)
            {
                quit();
                return(ConstMsg.RFINITERR);
            }

            //寻卡
            UInt16 tagtype = 0;
            byte   size    = 0;
            uint   snr     = 0;

            RFDef.rf_reset(icdev, 10);
            st = RFDef.rf_request(icdev, 1, out tagtype);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFREQUESTERR);
            }

            st = RFDef.rf_anticoll(icdev, 0, out snr);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFANTICOLLERR);
            }

            st = RFDef.rf_select(icdev, snr, out size);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFSELECTERR);
            }

            //验证B
            byte[] bkey1 = new byte[16];
            byte[] bkey2 = new byte[6];

            string bkey = "123456789012";

            bkey1 = Encoding.ASCII.GetBytes(bkey);
            RFDef.a_hex(bkey1, bkey2, 12);
            st = RFDef.rf_load_key(icdev, 4, sec, bkey2);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFLOADKEY_B_ERR);
            }
            st = RFDef.rf_authentication(icdev, 4, sec);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFAUTHENTICATION_A_ERR);
            }

            //原始化卡号信息
            byte[] databuff = new byte[16];
            byte[] buff     = new byte[32];

            string data = "00000000000000000000000000000000";

            buff = Encoding.ASCII.GetBytes(data);
            RFDef.a_hex(buff, databuff, 32);
            st = RFDef.rf_write(icdev, sec * 4, databuff);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFWRITEERR);
            }

            //原始化卡余额信息
            databuff = new byte[16];
            buff     = new byte[32];

            data = "00000000000000000000000000000000";
            buff = Encoding.ASCII.GetBytes(data);
            RFDef.a_hex(buff, databuff, 32);
            st = RFDef.rf_write(icdev, sec * 5, databuff);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFWRITEERR);
            }

            //原始化卡积分信息
            databuff = new byte[16];
            buff     = new byte[32];

            data = "00000000000000000000000000000000";
            buff = Encoding.ASCII.GetBytes(data);
            RFDef.a_hex(buff, databuff, 32);
            st = RFDef.rf_write(icdev, sec * 6, databuff);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFWRITEERR);
            }

            //改密码
            byte[] akey1 = new byte[16];
            byte[] akey2 = new byte[6];
            bkey = "123456789012";
            string akey = "123456789012";

            akey1 = Encoding.ASCII.GetBytes(akey);
            bkey1 = Encoding.ASCII.GetBytes(bkey);
            RFDef.a_hex(akey1, akey2, 12);
            RFDef.a_hex(bkey1, bkey2, 12);
            st = RFDef.rf_changeb3(icdev, sec, akey2, 0, 0, 0, 1, 0, bkey2);
            if (st != 0)
            {
                quit();
                return(ConstMsg.RFCHANGEB3ERR);
            }

            //蜂鸣
            st = RFDef.rf_beep(icdev, 3);
            quit();
            return(ConstMsg.RFOK);
        }