Пример #1
0
        public byte[] getMessageBuffer()
        {
            byte[] buffer = new byte[this.Size + 5];
            Encoding.ASCII.GetBytes(this.Header).CopyTo(buffer, 0);
            buffer[2] = (byte)this.Operation;
            buffer[3] = (byte)this.Size;
            getPayloadBuffer().CopyTo(buffer, 4);

            byte[] crcBuffer = new byte[this.Size + 2];
            for (int i = 0; i < this.Size + 2; i++)
            {
                crcBuffer[i] = buffer[i + 2];
            }

            buffer[this.Size + 4] = GSIPService.calcCrc7(crcBuffer, this.Size + 2);

            return(buffer);
        }
Пример #2
0
        public GSIP_Message(GSIP_OPERATION _operation, byte _size, object _payload)
        {
            this.Header    = "#S";
            this.Operation = _operation;
            this.Size      = _size;
            this.Payload   = _payload;

            byte[] buffer = new byte[this.Size + 2];
            buffer[0] = (byte)this.Operation;
            buffer[1] = (byte)this.Size;

            if (this.Size > 0)
            {
                byte[] payloadBuffer = this.getPayloadBuffer();
                payloadBuffer.CopyTo(buffer, 2);
            }

            this.Crc7 = GSIPService.calcCrc7(buffer, this.Size + 2);
        }