Пример #1
0
        protected override Object getReplyTail(byte[] package)
        {
            ProtocalHead head = (ProtocalHead)getReplyHead(package);

            byte[] tailBytes = ByteArray.CopyTo(package, Marshal.SizeOf(typeof(ProtocalHead)) + head.size, Marshal.SizeOf(typeof(ProtocalTail)));
            return(Struct.BytesToStuct(tailBytes, typeof(ProtocalTail)));
        }
Пример #2
0
        private bool checkout(byte[] buffer)
        {
            byte[]       headBytes = ByteArray.CopyTo(buffer, 0, Marshal.SizeOf(typeof(ProtocalHead)));
            ProtocalHead head      = (ProtocalHead)Struct.BytesToStuct(headBytes, typeof(ProtocalHead));

            byte[]       bodyBytes = ByteArray.CopyTo(buffer, Marshal.SizeOf(typeof(ProtocalHead)), head.size);
            byte[]       tailBytes = ByteArray.CopyTo(buffer, Marshal.SizeOf(typeof(ProtocalHead)) + head.size, Marshal.SizeOf(typeof(ProtocalTail)));
            ProtocalTail tail      = (ProtocalTail)Struct.BytesToStuct(tailBytes, typeof(ProtocalTail));
            UInt16       crc       = Utils.getCRC16(0, ByteArray.CombomByteArray(headBytes, bodyBytes), Marshal.SizeOf(typeof(ProtocalHead)) + head.size);

            return(crc == tail.crc16);
        }
Пример #3
0
        protected override byte getReplyIndex(byte[] package)
        {
            ProtocalHead head = (ProtocalHead)getReplyHead(package);

            return(head.index);
        }
Пример #4
0
        protected override byte[] getReplyData(byte[] package)
        {
            ProtocalHead head = (ProtocalHead)getReplyHead(package);

            return(ByteArray.CopyTo(package, Marshal.SizeOf(typeof(ProtocalHead)), head.size));
        }