/// <summary>
        /// 检查
        /// </summary>
        /// <param name="bean"></param>
        /// <returns></returns>
        public static ResultBean CheckEntity(TreeEntity bean)
        {
            ResultBean result = new ResultBean();

            for (int i = 0; i < 4; i++)
            {
                if (bean.StartBit[i] != startBit[i])
                {
                    result.Code++;
                    result.Msg += "起始位" + i + "不正确|";
                }
            }

            ushort crc = CRCUtil.CalculateCrc(bean.Data, bean.Data.Length);
            //src[6] = (byte)(crc & 0xff);
            //src[7] = (byte) (crc >> 8);
            byte crcL = ((byte)(crc & 0xff));
            byte crcH = ((byte)(crc >> 8));

            if (bean.Crc[0] != crcL || bean.Crc[1] != crcH)
            {
                result.Code++;
                result.Msg += "接收的CRC为" + bean.Crc[0] + "" + bean.Crc[1] + "计算的CRC为" + crcL + "" + crcH + " 对比不正确|";
            }
            result.Result = result.Code == 0;
            if (result.Result)
            {
                result.Msg = "正确";
            }
            result.Obj     = bean;
            bean.CheckCode = result.Code;
            bean.CheckMsg  = result.Msg;

            return(result);
        }
        /// <summary>
        /// 回复
        /// </summary>
        /// <param name="bean"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public static byte[] Respond(TreeEntity bean, int order)
        {
            int length = 17;

            byte[] respond = new byte[length];
            for (int i = 0; i < 4; i++)//起始位和结尾
            {
                respond[i] = startBit[i];
                if (i < 2)
                {
                    respond[length - i - 1] = endBit[1 - i];
                }
            }
            respond[4] = (byte)(order & 0xFF);
            respond[5] = (byte)(order >> 8 & 0xFF); //序列号

            respond[6] = 0x09;                      //数据类型

            respond[8] = 0x00;
            respond[7] = 0x04;//数据包长度

            respond[9]  = respond[4];
            respond[10] = respond[5];//数据包,CJC  =序列号

            ushort crc = CRCUtil.CalculateCrc(Copy(respond, 9, 4), 4);
            //src[6] = (byte)(crc & 0xff);
            //src[7] = (byte) (crc >> 8);
            byte crcL = ((byte)(crc & 0xff));
            byte crcH = ((byte)(crc >> 8));

            respond[13] = crcL;
            respond[14] = crcH; //CRC

            return(respond);
        }
Example #3
0
        // Token: 0x0600019B RID: 411 RVA: 0x00005DC8 File Offset: 0x00003FC8
        public override uint[] readCard(bool beep)
        {
            if (!this.checkDevice(true))
            {
                return(null);
            }
            uint num = this.getCardID(false);

            this.pwd = base.getPassword(false, num);
            if (this.pwd == null)
            {
                return(null);
            }
            byte[] array = new byte[28];
            if (QingtongReader.qt_T5557_readm(this.device, 0, 1, array) == 0)
            {
                WMMessageBox.Show(this.owner, "该卡为空白卡,请先初始化!");
                return(null);
            }
            int num2 = (int)QingtongReader.qt_T5557_pwdreadm(this.device, 0, 7, this.pwd, array);

            if (num2 != 0)
            {
                WMMessageBox.Show(this.owner, "读卡错误!");
                return(null);
            }
            if ((int)this.device > 0 && beep)
            {
                QingtongReader.dv_beep(this.device, 10);
            }
            uint[] array2 = base.byte2Uint32(array);
            uint[] array3 = new uint[]
            {
                array2[1],
                array2[2],
                array2[3],
                array2[4],
                array2[5],
                array2[6]
            };
            num = num * ICardReader.DATA_PASS1 + ICardReader.DATA_PASS2;
            for (int i = 0; i < array3.Length; i++)
            {
                array3[i] ^= num;
            }
            CRCUtil crcutil = new CRCUtil(array3);

            if (!crcutil.checkCRC())
            {
                WMMessageBox.Show(this.owner, "CRC检查错误!");
                return(null);
            }
            return(array3);
        }
Example #4
0
        // Token: 0x06000095 RID: 149 RVA: 0x0000366C File Offset: 0x0000186C
        public uint[] getEntity()
        {
            uint[] array = new uint[]
            {
                this.cardHead.getEntity(),
                this.deviceHead.getEntity(),
                this.userId,
                this.totalRechargeNumber,
                this.totalReadNum,
                this.getTheSixthData()
            };
            CRCUtil crcutil  = new CRCUtil(array);
            ushort  crcValue = crcutil.CrcValue;

            array[5] |= (uint)((uint)(crcValue & 255) << 8);
            array[5] |= (uint)(crcValue & 65280) >> 8;
            return(array);
        }
        // Token: 0x06000072 RID: 114 RVA: 0x000034A0 File Offset: 0x000016A0
        public uint[] getEntity()
        {
            uint[] array = new uint[]
            {
                this.cardHead.getEntity(),
                this.persistData1,
                this.persistData2,
                this.persistData3,
                this.persistData4,
                this.getTheSixthData()
            };
            CRCUtil crcutil  = new CRCUtil(array);
            ushort  crcValue = crcutil.CrcValue;

            array[5] |= (uint)((uint)(crcValue & 255) << 8);
            array[5] |= (uint)(crcValue & 65280) >> 8;
            return(array);
        }
Example #6
0
        // Token: 0x06000046 RID: 70 RVA: 0x00002C70 File Offset: 0x00000E70
        public uint[] getEntity()
        {
            uint[] array = new uint[]
            {
                this.cardHead.getEntity(),
                this.surplusNum,
                this.userId,
                this.getTheFourthData(),
                this.getTheFifthData(),
                this.getTheSixthData()
            };
            CRCUtil crcutil  = new CRCUtil(array);
            ushort  crcValue = crcutil.CrcValue;

            array[5] |= (uint)((uint)(crcValue & 255) << 8);
            array[5] |= (uint)(crcValue & 65280) >> 8;
            return(array);
        }
Example #7
0
        // Token: 0x06000096 RID: 150 RVA: 0x00003708 File Offset: 0x00001908
        public bool parseEntity(uint[] datas)
        {
            if (datas.Length != 6)
            {
                return(false);
            }
            CRCUtil crcutil = new CRCUtil(datas);

            if (!crcutil.checkCRC())
            {
                return(false);
            }
            this.cardHead            = new CardHeadEntity(datas[0]);
            this.deviceHead          = new DeviceHeadEntity(datas[1]);
            this.userId              = datas[2];
            this.totalRechargeNumber = datas[3];
            this.totalReadNum        = datas[4];
            this.parseTheSixthData(datas[5]);
            return(true);
        }
        // Token: 0x06000071 RID: 113 RVA: 0x00003438 File Offset: 0x00001638
        public bool parseEntity(uint[] datas)
        {
            if (datas == null || datas.Length != 6)
            {
                return(false);
            }
            CRCUtil crcutil = new CRCUtil(datas);

            if (!crcutil.checkCRC())
            {
                return(false);
            }
            this.cardHead     = new CardHeadEntity(datas[0]);
            this.persistData1 = datas[1];
            this.persistData2 = datas[2];
            this.persistData3 = datas[3];
            this.persistData4 = datas[4];
            this.parseTheSixthData(datas[5]);
            return(true);
        }
Example #9
0
        // Token: 0x06000045 RID: 69 RVA: 0x00002C08 File Offset: 0x00000E08
        public bool parseEntity(uint[] datas)
        {
            if (datas == null || datas.Length != 6)
            {
                return(false);
            }
            CRCUtil crcutil = new CRCUtil(datas);

            if (!crcutil.checkCRC())
            {
                return(false);
            }
            this.cardHead   = new CardHeadEntity(datas[0]);
            this.surplusNum = datas[1];
            this.userId     = datas[2];
            this.parseTheFourthData(datas[3]);
            this.parseTheFifthData(datas[4]);
            this.parseTheSixthData(datas[5]);
            return(true);
        }
Example #10
0
        // Token: 0x0600017C RID: 380 RVA: 0x000056B0 File Offset: 0x000038B0
        public override uint[] readCard(bool beep)
        {
            if (!this.checkDevice(true))
            {
                return(null);
            }
            uint num = this.getCardID(false);

            this.pwd = base.getPassword(false, num);
            if (this.pwd == null)
            {
                return(null);
            }
            byte[] array = new byte[24];
            if (!this.isEncryptCard())
            {
                WMMessageBox.Show(this.owner, "该卡为空白卡,请先初始化!");
                return(null);
            }
            for (byte b = 1; b < 7; b += 1)
            {
                byte[] array2 = new byte[4];
                int    num2   = 0;
                if (!RDIC100Reader.ATA_AccessPWD(0, b, this.pwd, this.ADDR))
                {
                    WMMessageBox.Show(this.owner, "读卡错误!");
                    return(null);
                }
                int num3 = RDIC100Reader.ATA_ReadCardRF32(array2, ref num2, this.ADDR);
                if (num3 != 1)
                {
                    WMMessageBox.Show(this.owner, "读卡错误!");
                    return(null);
                }
                array[(int)((b - 1) * 4)]     = array2[0];
                array[(int)((b - 1) * 4 + 1)] = array2[1];
                array[(int)((b - 1) * 4 + 2)] = array2[2];
                array[(int)((b - 1) * 4 + 3)] = array2[3];
            }
            if (beep)
            {
                RDIC100Reader.gSetBeep(100, this.ADDR);
            }
            uint[] array3 = base.byte2Uint32(array);
            uint[] array4 = new uint[]
            {
                array3[0],
                array3[1],
                array3[2],
                array3[3],
                array3[4],
                array3[5]
            };
            num = num * ICardReader.DATA_PASS1 + ICardReader.DATA_PASS2;
            for (int i = 0; i < array4.Length; i++)
            {
                array4[i] ^= num;
            }
            CRCUtil crcutil = new CRCUtil(array4);

            if (!crcutil.checkCRC())
            {
                WMMessageBox.Show(this.owner, "数据检查错误!");
                return(null);
            }
            return(array4);
        }
Example #11
0
        // Token: 0x06000163 RID: 355 RVA: 0x00004E9C File Offset: 0x0000309C
        public override uint[] readCard(bool beep)
        {
            if (!this.checkDevice(true))
            {
                return(null);
            }
            uint num = this.getCardID(false);

            this.pwd = base.getPassword(false, num);
            if (this.pwd == null)
            {
                return(null);
            }
            int num2 = this.isValidCard(true);

            if (num2 == 1)
            {
                WMMessageBox.Show(this.owner, "空卡!");
                return(null);
            }
            if (num2 == -2)
            {
                WMMessageBox.Show(this.owner, "无效卡!");
                return(null);
            }
            byte[] array  = new byte[28];
            byte[] array2 = new byte[4];
            for (short num3 = 0; num3 < 7; num3 += 1)
            {
                num2 = MHCardReader.E5557_Direct_Read(0, num3, 1, this.pwd, array2);
                if (num2 != 0)
                {
                    WMMessageBox.Show(this.owner, "读卡错误!");
                    return(null);
                }
                array[(int)(num3 * 4)]     = array2[0];
                array[(int)(num3 * 4 + 1)] = array2[1];
                array[(int)(num3 * 4 + 2)] = array2[2];
                array[(int)(num3 * 4 + 3)] = array2[3];
            }
            MHCardReader.Beep_Option();
            MHCardReader.Led_Option();
            uint[] array3 = base.byte2Uint32(array);
            uint[] array4 = new uint[]
            {
                array3[1],
                array3[2],
                array3[3],
                array3[4],
                array3[5],
                array3[6]
            };
            num = num * ICardReader.DATA_PASS1 + ICardReader.DATA_PASS2;
            for (int i = 0; i < array4.Length; i++)
            {
                array4[i] ^= num;
            }
            CRCUtil crcutil = new CRCUtil(array4);

            if (!crcutil.checkCRC())
            {
                WMMessageBox.Show(this.owner, "CRC检查错误!");
                return(null);
            }
            return(array4);
        }