Beispiel #1
0
        public byte[] ConfirmMessage(byte[] res)
        {
            byte[]     back  = { 0x68, 0x08, 0x68, res[3], res[4], res[5], res[6], res[7], res[8], res[9], 0x00, 0x00, 0x16 };
            byte[]     datas = { res[3], res[4], res[5], res[6], res[7], res[8], res[9], 0x00 };
            FuGuangCRC crc   = new FuGuangCRC();

            back[11] = crc.GetCRCByte(datas);
            return(back);
        }
Beispiel #2
0
        public bool isOk(byte[] res)
        {
            //验证包头包尾
            if (res[0] != 0x68 || res[2] != 0x68 || res[res.Length - 1] != 0x16)
            {
                return(false);
            }
            int len = int.Parse(res[1].ToString());

            byte[] datas = new byte[len];
            Array.Copy(res, 3, datas, 0, len);
            FuGuangCRC crc = new FuGuangCRC();

            //crc校验
            if (res[res.Length - 2] != crc.GetCRCByte(datas))
            {
                return(false);
            }
            return(true);
        }