Exemplo n.º 1
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            for (var i = 0; i < Aileron.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, Aileron[i]); index += 2;
            }
            for (var i = 0; i < Elevator.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, Elevator[i]); index += 2;
            }
            for (var i = 0; i < Rudder.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, Rudder[i]); index += 2;
            }
            for (var i = 0; i < Gyro.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, Gyro[i]); index += 2;
            }
            for (var i = 0; i < Pitch.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, Pitch[i]); index += 2;
            }
            for (var i = 0; i < Throttle.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, Throttle[i]); index += 2;
            }
            return(index); // /*PayloadByteSize*/42;
        }
Exemplo n.º 2
0
        public void Serialize(ref Span <byte> buffer)
        {
            var fillBuffer    = buffer.Slice(0);
            var payloadBuffer = buffer.Slice(10);
            var payloadSize   = Payload.Serialize(ref payloadBuffer);

            Debug.Assert(payloadSize <= byte.MaxValue, $"Wrong payload serialize size (must be {byte.MaxValue} size)");

            BinSerialize.WriteByte(ref fillBuffer, PacketV2Helper.MagicMarkerV2);
            BinSerialize.WriteByte(ref fillBuffer, (byte)payloadSize);
            BinSerialize.WriteByte(ref fillBuffer, IncompatFlags);
            BinSerialize.WriteByte(ref fillBuffer, CompatFlags);
            BinSerialize.WriteByte(ref fillBuffer, Sequence);
            BinSerialize.WriteByte(ref fillBuffer, SystemId);
            BinSerialize.WriteByte(ref fillBuffer, ComponenId);
            BinSerialize.WriteByte(ref fillBuffer, (byte)((MessageId) & 0xFF));
            BinSerialize.WriteByte(ref fillBuffer, (byte)((MessageId >> 8) & 0xFF));
            BinSerialize.WriteByte(ref fillBuffer, (byte)((MessageId >> 16) & 0xFF));
            var crcBuff = buffer.Slice(1, 9);
            var crc     = X25Crc.Accumulate(ref crcBuff, X25Crc.CrcSeed);

            crcBuff    = buffer.Slice(10, payloadSize);
            crc        = X25Crc.Accumulate(ref crcBuff, crc);
            crc        = X25Crc.Accumulate(GetCrcEtra(), crc);
            fillBuffer = fillBuffer.Slice(payloadSize);
            BinSerialize.WriteUShort(ref fillBuffer, crc);
            if (Signature.IsPresent)
            {
                Signature.Serialize(ref fillBuffer);
            }
            // Debug.Assert((payloadSize + Signature.ByteSize + PacketV2Helper.PacketV2FrameSize) == (buffer.Length - fillBuffer.Length));
            buffer = fillBuffer;
        }
Exemplo n.º 3
0
 public override void Serialize(ref Span <byte> buffer)
 {
     BinSerialize.WriteBool(ref buffer, UavIdFilterEnabled);
     BinSerialize.WriteByte(ref buffer, UavSystemId);
     BinSerialize.WriteByte(ref buffer, UavComponentId);
     BinSerialize.WriteUShort(ref buffer, WpIndex);
 }
Exemplo n.º 4
0
 public void Serialize(ref Span <byte> buffer)
 {
     SessionId.Serialize(ref buffer);
     BinSerialize.WritePackedUnsignedInteger(ref buffer, Counter);
     BinSerialize.WriteByte(ref buffer, (byte)Flags);
     BinSerialize.WriteByte(ref buffer, (byte)Groups.Count);
     foreach (var group in Groups)
     {
         BinSerialize.WriteUShort(ref buffer, group);
     }
 }
Exemplo n.º 5
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            BinSerialize.WriteUInt(ref buffer, ErrorStatus); index        += 4;
            BinSerialize.WriteUInt(ref buffer, TimeBootMs); index         += 4;
            BinSerialize.WriteUShort(ref buffer, BatteryStatus); index    += 2;
            BinSerialize.WriteByte(ref buffer, (byte)ArmStatus); index    += 1;
            BinSerialize.WriteByte(ref buffer, (byte)ChangeStatus); index += 1;
            return(index); // /*PayloadByteSize*/12;
        }
Exemplo n.º 6
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            for (var i = 0; i < ArD.Length; i++)
            {
                BinSerialize.WriteDouble(ref buffer, ArD[i]); index += 8;
            }
            BinSerialize.WriteUInt(ref buffer, V3); index += 4;
            for (var i = 0; i < ArU32.Length; i++)
            {
                BinSerialize.WriteUInt(ref buffer, ArU32[i]); index += 4;
            }
            for (var i = 0; i < ArI32.Length; i++)
            {
                BinSerialize.WriteInt(ref buffer, ArI32[i]); index += 4;
            }
            for (var i = 0; i < ArF.Length; i++)
            {
                BinSerialize.WriteFloat(ref buffer, ArF[i]); index += 4;
            }
            BinSerialize.WriteUShort(ref buffer, V2); index += 2;
            for (var i = 0; i < ArU16.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, ArU16[i]); index += 2;
            }
            for (var i = 0; i < ArI16.Length; i++)
            {
                BinSerialize.WriteShort(ref buffer, ArI16[i]); index += 2;
            }
            BinSerialize.WriteByte(ref buffer, (byte)V1); index += 1;
            for (var i = 0; i < ArU8.Length; i++)
            {
                BinSerialize.WriteByte(ref buffer, (byte)ArU8[i]); index += 1;
            }
            for (var i = 0; i < ArI8.Length; i++)
            {
                BinSerialize.WriteByte(ref buffer, (byte)ArI8[i]); index += 1;
            }
            unsafe
            {
                fixed(byte *bytePointer = buffer)
                fixed(char *charPointer = ArC)
                {
                    Encoding.ASCII.GetBytes(charPointer, ArC.Length, bytePointer, ArC.Length);
                }
            }
            buffer = buffer.Slice(ArC.Length);
            index += ArC.Length;
            return(index); // /*PayloadByteSize*/91;
        }
Exemplo n.º 7
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            for (var i = 0; i < ArD.Length; i++)
            {
                BinSerialize.WriteDouble(ref buffer, ArD[i]); index += 8;
            }
            BinSerialize.WriteUInt(ref buffer, V3); index += 4;
            for (var i = 0; i < ArU16.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, ArU16[i]); index += 2;
            }
            return(index); // /*PayloadByteSize*/24;
        }
Exemplo n.º 8
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            BinSerialize.WriteUInt(ref buffer, Utctime); index               += 4;
            BinSerialize.WriteInt(ref buffer, Gpslat); index                 += 4;
            BinSerialize.WriteInt(ref buffer, Gpslon); index                 += 4;
            BinSerialize.WriteInt(ref buffer, Gpsalt); index                 += 4;
            BinSerialize.WriteInt(ref buffer, Baroaltmsl); index             += 4;
            BinSerialize.WriteUInt(ref buffer, Accuracyhor); index           += 4;
            BinSerialize.WriteUShort(ref buffer, Accuracyvert); index        += 2;
            BinSerialize.WriteUShort(ref buffer, Accuracyvel); index         += 2;
            BinSerialize.WriteShort(ref buffer, Velvert); index              += 2;
            BinSerialize.WriteShort(ref buffer, Velns); index                += 2;
            BinSerialize.WriteShort(ref buffer, Velew); index                += 2;
            BinSerialize.WriteUShort(ref buffer, (ushort)State); index       += 2;
            BinSerialize.WriteUShort(ref buffer, Squawk); index              += 2;
            BinSerialize.WriteByte(ref buffer, (byte)Gpsfix); index          += 1;
            BinSerialize.WriteByte(ref buffer, (byte)Numsats); index         += 1;
            BinSerialize.WriteByte(ref buffer, (byte)Emergencystatus); index += 1;
            return(index); // /*PayloadByteSize*/41;
        }
Exemplo n.º 9
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            BinSerialize.WriteUInt(ref buffer, Icao); index         += 4;
            BinSerialize.WriteUShort(ref buffer, Stallspeed); index += 2;
            unsafe
            {
                fixed(byte *bytePointer = buffer)
                fixed(char *charPointer = Callsign)
                {
                    Encoding.ASCII.GetBytes(charPointer, Callsign.Length, bytePointer, Callsign.Length);
                }
            }
            buffer = buffer.Slice(Callsign.Length);
            index += Callsign.Length;
            BinSerialize.WriteByte(ref buffer, (byte)Emittertype); index  += 1;
            BinSerialize.WriteByte(ref buffer, (byte)Aircraftsize); index += 1;
            BinSerialize.WriteByte(ref buffer, (byte)Gpsoffsetlat); index += 1;
            BinSerialize.WriteByte(ref buffer, (byte)Gpsoffsetlon); index += 1;
            BinSerialize.WriteByte(ref buffer, (byte)Rfselect); index     += 1;
            return(index); // /*PayloadByteSize*/20;
        }
Exemplo n.º 10
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            for (var i = 0; i < ArU32.Length; i++)
            {
                BinSerialize.WriteUInt(ref buffer, ArU32[i]); index += 4;
            }
            for (var i = 0; i < ArU16.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, ArU16[i]); index += 2;
            }
            BinSerialize.WriteByte(ref buffer, (byte)V1); index += 1;
            for (var i = 0; i < ArI8.Length; i++)
            {
                BinSerialize.WriteByte(ref buffer, (byte)ArI8[i]); index += 1;
            }
            for (var i = 0; i < ArU8.Length; i++)
            {
                BinSerialize.WriteByte(ref buffer, (byte)ArU8[i]); index += 1;
            }
            return(index); // /*PayloadByteSize*/33;
        }
Exemplo n.º 11
0
 public void Serialize(ref Span <byte> buffer)
 {
     BinSerialize.WriteUShort(ref buffer, Count);
 }
Exemplo n.º 12
0
        public int Serialize(ref Span <byte> buffer)
        {
            var index = 0;

            BinSerialize.WriteULong(ref buffer, U64); index += 8;
            BinSerialize.WriteLong(ref buffer, S64); index  += 8;
            BinSerialize.WriteDouble(ref buffer, D); index  += 8;
            for (var i = 0; i < U64Array.Length; i++)
            {
                BinSerialize.WriteULong(ref buffer, U64Array[i]); index += 8;
            }
            for (var i = 0; i < S64Array.Length; i++)
            {
                BinSerialize.WriteLong(ref buffer, S64Array[i]); index += 8;
            }
            for (var i = 0; i < DArray.Length; i++)
            {
                BinSerialize.WriteDouble(ref buffer, DArray[i]); index += 8;
            }
            BinSerialize.WriteUInt(ref buffer, U32); index += 4;
            BinSerialize.WriteInt(ref buffer, S32); index  += 4;
            BinSerialize.WriteFloat(ref buffer, F); index  += 4;
            for (var i = 0; i < U32Array.Length; i++)
            {
                BinSerialize.WriteUInt(ref buffer, U32Array[i]); index += 4;
            }
            for (var i = 0; i < S32Array.Length; i++)
            {
                BinSerialize.WriteInt(ref buffer, S32Array[i]); index += 4;
            }
            for (var i = 0; i < FArray.Length; i++)
            {
                BinSerialize.WriteFloat(ref buffer, FArray[i]); index += 4;
            }
            BinSerialize.WriteUShort(ref buffer, U16); index += 2;
            BinSerialize.WriteShort(ref buffer, S16); index  += 2;
            for (var i = 0; i < U16Array.Length; i++)
            {
                BinSerialize.WriteUShort(ref buffer, U16Array[i]); index += 2;
            }
            for (var i = 0; i < S16Array.Length; i++)
            {
                BinSerialize.WriteShort(ref buffer, S16Array[i]); index += 2;
            }
            BinSerialize.WriteByte(ref buffer, (byte)C); index += 1;
            unsafe
            {
                fixed(byte *bytePointer = buffer)
                fixed(char *charPointer = S)
                {
                    Encoding.ASCII.GetBytes(charPointer, S.Length, bytePointer, S.Length);
                }
            }
            buffer = buffer.Slice(S.Length);
            index += S.Length;
            BinSerialize.WriteByte(ref buffer, (byte)U8); index += 1;
            BinSerialize.WriteByte(ref buffer, (byte)S8); index += 1;
            for (var i = 0; i < U8Array.Length; i++)
            {
                BinSerialize.WriteByte(ref buffer, (byte)U8Array[i]); index += 1;
            }
            for (var i = 0; i < S8Array.Length; i++)
            {
                BinSerialize.WriteByte(ref buffer, (byte)S8Array[i]); index += 1;
            }
            return(index); // /*PayloadByteSize*/179;
        }