public override void Deserialize(ref ReadOnlySpan <byte> buffer) { UavIdFilterEnabled = BinSerialize.ReadBool(ref buffer); UavSystemId = BinSerialize.ReadByte(ref buffer); UavComponentId = BinSerialize.ReadByte(ref buffer); WpIndex = BinSerialize.ReadUShort(ref buffer); }
public byte GetMinByteSize() => 20; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; Icao = BinSerialize.ReadUInt(ref buffer); index += 4; Stallspeed = BinSerialize.ReadUShort(ref buffer); index += 2; arraySize = /*ArrayLength*/ 9 - Math.Max(0, ((/*PayloadByteSize*/ 20 - payloadSize - /*ExtendedFieldsLength*/ 0) / 1 /*FieldTypeByteSize*/)); Callsign = new char[arraySize]; unsafe { fixed(byte *bytePointer = buffer) fixed(char *charPointer = Callsign) { Encoding.ASCII.GetChars(bytePointer, arraySize, charPointer, Callsign.Length); } } buffer = buffer.Slice(arraySize); index += arraySize; Emittertype = (AdsbEmitterType)BinSerialize.ReadByte(ref buffer); index += 1; Aircraftsize = (UavionixAdsbOutCfgAircraftSize)BinSerialize.ReadByte(ref buffer); index += 1; Gpsoffsetlat = (UavionixAdsbOutCfgGpsOffsetLat)BinSerialize.ReadByte(ref buffer); index += 1; Gpsoffsetlon = (UavionixAdsbOutCfgGpsOffsetLon)BinSerialize.ReadByte(ref buffer); index += 1; Rfselect = (UavionixAdsbOutRfSelect)BinSerialize.ReadByte(ref buffer); index += 1; }
public byte GetMinByteSize() => 33; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; arraySize = /*ArrayLength*/ 4 - Math.Max(0, ((/*PayloadByteSize*/ 33 - payloadSize - /*ExtendedFieldsLength*/ 0) / 4 /*FieldTypeByteSize*/)); ArU32 = new uint[arraySize]; for (var i = 0; i < arraySize; i++) { ArU32[i] = BinSerialize.ReadUInt(ref buffer); index += 4; } arraySize = 4; for (var i = 0; i < arraySize; i++) { ArU16[i] = BinSerialize.ReadUShort(ref buffer); index += 2; } V1 = (byte)BinSerialize.ReadByte(ref buffer); index += 1; arraySize = 4; for (var i = 0; i < arraySize; i++) { ArI8[i] = (sbyte)BinSerialize.ReadByte(ref buffer); index += 1; } arraySize = 4; for (var i = 0; i < arraySize; i++) { ArU8[i] = (byte)BinSerialize.ReadByte(ref buffer); index += 1; } }
public void Deserialize(ref ReadOnlySpan <byte> buffer) { Comment = BinSerialize.ReadString(ref buffer); Version = BinSerialize.ReadByte(ref buffer); Hash = BinSerialize.ReadUInt(ref buffer); ItemsCount = BinSerialize.ReadInt(ref buffer); }
public byte GetMinByteSize() => 84; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; arraySize = 2; for (var i = 0; i < arraySize; i++) { ArD[i] = BinSerialize.ReadDouble(ref buffer); index += 8; } arraySize = 2; for (var i = 0; i < arraySize; i++) { ArF[i] = BinSerialize.ReadFloat(ref buffer); index += 4; } arraySize = 2; for (var i = 0; i < arraySize; i++) { ArU32[i] = BinSerialize.ReadUInt(ref buffer); index += 4; } arraySize = 2; for (var i = 0; i < arraySize; i++) { ArI32[i] = BinSerialize.ReadInt(ref buffer); index += 4; } arraySize = 2; for (var i = 0; i < arraySize; i++) { ArU16[i] = BinSerialize.ReadUShort(ref buffer); index += 2; } arraySize = 2; for (var i = 0; i < arraySize; i++) { ArI16[i] = BinSerialize.ReadShort(ref buffer); index += 2; } arraySize = 2; for (var i = 0; i < arraySize; i++) { ArU8[i] = (byte)BinSerialize.ReadByte(ref buffer); index += 1; } arraySize = 2; for (var i = 0; i < arraySize; i++) { ArI8[i] = (sbyte)BinSerialize.ReadByte(ref buffer); index += 1; } arraySize = /*ArrayLength*/ 32 - Math.Max(0, ((/*PayloadByteSize*/ 84 - payloadSize - /*ExtendedFieldsLength*/ 0) / 1 /*FieldTypeByteSize*/)); ArC = new char[arraySize]; unsafe { fixed(byte *bytePointer = buffer) fixed(char *charPointer = ArC) { Encoding.ASCII.GetChars(bytePointer, arraySize, charPointer, ArC.Length); } } buffer = buffer.Slice(arraySize); index += arraySize; }
public byte GetMinByteSize() => 1; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; Rfhealth = (UavionixAdsbRfHealth)BinSerialize.ReadByte(ref buffer); index += 1; }
public byte GetMinByteSize() => 1; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; Status = (IcarousFmsState)BinSerialize.ReadByte(ref buffer); index += 1; }
public byte GetMinByteSize() => 5; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; Checksum = BinSerialize.ReadUInt(ref buffer); index += 4; MissionType = (MavMissionType)BinSerialize.ReadByte(ref buffer); index += 1; }
public byte GetMinByteSize() => 3; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; Mode = (byte)BinSerialize.ReadByte(ref buffer); index += 1; NavMode = (byte)BinSerialize.ReadByte(ref buffer); index += 1; Pilot = (byte)BinSerialize.ReadByte(ref buffer); index += 1; }
public byte GetMinByteSize() => 12; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; ErrorStatus = BinSerialize.ReadUInt(ref buffer); index += 4; TimeBootMs = BinSerialize.ReadUInt(ref buffer); index += 4; BatteryStatus = BinSerialize.ReadUShort(ref buffer); index += 2; ArmStatus = (byte)BinSerialize.ReadByte(ref buffer); index += 1; ChangeStatus = (byte)BinSerialize.ReadByte(ref buffer); index += 1; }
public void Deserialize(ref ReadOnlySpan <byte> buffer) { SessionId ??= new SessionId(); SessionId.Deserialize(ref buffer); Counter = BinSerialize.ReadPackedUnsignedInteger(ref buffer); Flags = (Pv2StreamFlags)BinSerialize.ReadByte(ref buffer); var count = BinSerialize.ReadByte(ref buffer); Groups = new List <ushort>(count); for (var i = 0; i < count; i++) { Groups.Add(BinSerialize.ReadUShort(ref buffer)); } }
public void Deserialize(ref ReadOnlySpan <byte> buffer) { IsPresent = true; LinkId = BinSerialize.ReadByte(ref buffer); Timestamp = BinSerialize.ReadByte(ref buffer); Timestamp |= (ulong)BinSerialize.ReadByte(ref buffer) << 8; Timestamp |= ((ulong)BinSerialize.ReadByte(ref buffer)) << 16; Timestamp |= ((ulong)BinSerialize.ReadByte(ref buffer)) << 24; Timestamp |= ((ulong)BinSerialize.ReadByte(ref buffer)) << 32; Timestamp |= ((ulong)BinSerialize.ReadByte(ref buffer)) << 40; Sign = BinSerialize.ReadByte(ref buffer); Sign |= (ulong)BinSerialize.ReadByte(ref buffer) << 8; Sign |= ((ulong)BinSerialize.ReadByte(ref buffer)) << 16; Sign |= ((ulong)BinSerialize.ReadByte(ref buffer)) << 24; Sign |= ((ulong)BinSerialize.ReadByte(ref buffer)) << 32; Sign |= ((ulong)BinSerialize.ReadByte(ref buffer)) << 40; }
public static void ReadHeader(ref ReadOnlySpan <byte> span, out ushort methodInterfaceId, out ushort methodMethodId, out byte requestId) { requestId = BinSerialize.ReadByte(ref span); var val = BinSerialize.ReadPackedUnsignedInteger(ref span); if (val > ushort.MaxValue) { throw new Exception($"Interface ID is more then max value {val} > {ushort.MaxValue}"); } methodInterfaceId = (ushort)val; val = BinSerialize.ReadPackedUnsignedInteger(ref span); if (val > ushort.MaxValue) { throw new Exception($"Method ID is more then max value {val} > {ushort.MaxValue}"); } methodMethodId = (ushort)val; }
public byte GetMinByteSize() => 46; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; Min1 = BinSerialize.ReadFloat(ref buffer); index += 4; Max1 = BinSerialize.ReadFloat(ref buffer); index += 4; Min2 = BinSerialize.ReadFloat(ref buffer); index += 4; Max2 = BinSerialize.ReadFloat(ref buffer); index += 4; Min3 = BinSerialize.ReadFloat(ref buffer); index += 4; Max3 = BinSerialize.ReadFloat(ref buffer); index += 4; Min4 = BinSerialize.ReadFloat(ref buffer); index += 4; Max4 = BinSerialize.ReadFloat(ref buffer); index += 4; Min5 = BinSerialize.ReadFloat(ref buffer); index += 4; Max5 = BinSerialize.ReadFloat(ref buffer); index += 4; Numbands = (sbyte)BinSerialize.ReadByte(ref buffer); index += 1; Type1 = (IcarousTrackBandTypes)BinSerialize.ReadByte(ref buffer); index += 1; Type2 = (IcarousTrackBandTypes)BinSerialize.ReadByte(ref buffer); index += 1; Type3 = (IcarousTrackBandTypes)BinSerialize.ReadByte(ref buffer); index += 1; Type4 = (IcarousTrackBandTypes)BinSerialize.ReadByte(ref buffer); index += 1; Type5 = (IcarousTrackBandTypes)BinSerialize.ReadByte(ref buffer); index += 1; }
public byte GetMinByteSize() => 41; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; Utctime = BinSerialize.ReadUInt(ref buffer); index += 4; Gpslat = BinSerialize.ReadInt(ref buffer); index += 4; Gpslon = BinSerialize.ReadInt(ref buffer); index += 4; Gpsalt = BinSerialize.ReadInt(ref buffer); index += 4; Baroaltmsl = BinSerialize.ReadInt(ref buffer); index += 4; Accuracyhor = BinSerialize.ReadUInt(ref buffer); index += 4; Accuracyvert = BinSerialize.ReadUShort(ref buffer); index += 2; Accuracyvel = BinSerialize.ReadUShort(ref buffer); index += 2; Velvert = BinSerialize.ReadShort(ref buffer); index += 2; Velns = BinSerialize.ReadShort(ref buffer); index += 2; Velew = BinSerialize.ReadShort(ref buffer); index += 2; State = (UavionixAdsbOutDynamicState)BinSerialize.ReadUShort(ref buffer); index += 2; Squawk = BinSerialize.ReadUShort(ref buffer); index += 2; Gpsfix = (UavionixAdsbOutDynamicGpsFix)BinSerialize.ReadByte(ref buffer); index += 1; Numsats = (byte)BinSerialize.ReadByte(ref buffer); index += 1; Emergencystatus = (UavionixAdsbEmergencyStatus)BinSerialize.ReadByte(ref buffer); index += 1; }
protected override byte InternalReadKey(ref ReadOnlySpan <byte> buffer) { return(BinSerialize.ReadByte(ref buffer)); }
public byte GetMinByteSize() => 179; // of byte sized of fields (exclude extended) public void Deserialize(ref ReadOnlySpan <byte> buffer, int payloadSize) { var index = 0; var endIndex = payloadSize; var arraySize = 0; U64 = BinSerialize.ReadULong(ref buffer); index += 8; S64 = BinSerialize.ReadLong(ref buffer); index += 8; D = BinSerialize.ReadDouble(ref buffer); index += 8; arraySize = /*ArrayLength*/ 3 - Math.Max(0, ((/*PayloadByteSize*/ 179 - payloadSize - /*ExtendedFieldsLength*/ 0) / 8 /*FieldTypeByteSize*/)); U64Array = new ulong[arraySize]; for (var i = 0; i < arraySize; i++) { U64Array[i] = BinSerialize.ReadULong(ref buffer); index += 8; } arraySize = 3; for (var i = 0; i < arraySize; i++) { S64Array[i] = BinSerialize.ReadLong(ref buffer); index += 8; } arraySize = 3; for (var i = 0; i < arraySize; i++) { DArray[i] = BinSerialize.ReadDouble(ref buffer); index += 8; } U32 = BinSerialize.ReadUInt(ref buffer); index += 4; S32 = BinSerialize.ReadInt(ref buffer); index += 4; F = BinSerialize.ReadFloat(ref buffer); index += 4; arraySize = 3; for (var i = 0; i < arraySize; i++) { U32Array[i] = BinSerialize.ReadUInt(ref buffer); index += 4; } arraySize = 3; for (var i = 0; i < arraySize; i++) { S32Array[i] = BinSerialize.ReadInt(ref buffer); index += 4; } arraySize = 3; for (var i = 0; i < arraySize; i++) { FArray[i] = BinSerialize.ReadFloat(ref buffer); index += 4; } U16 = BinSerialize.ReadUShort(ref buffer); index += 2; S16 = BinSerialize.ReadShort(ref buffer); index += 2; arraySize = 3; for (var i = 0; i < arraySize; i++) { U16Array[i] = BinSerialize.ReadUShort(ref buffer); index += 2; } arraySize = 3; for (var i = 0; i < arraySize; i++) { S16Array[i] = BinSerialize.ReadShort(ref buffer); index += 2; } C = (char)buffer[0]; buffer = buffer.Slice(1); index += 1; arraySize = 10; unsafe { fixed(byte *bytePointer = buffer) fixed(char *charPointer = S) { Encoding.ASCII.GetChars(bytePointer, arraySize, charPointer, S.Length); } } buffer = buffer.Slice(arraySize); index += arraySize; U8 = (byte)BinSerialize.ReadByte(ref buffer); index += 1; S8 = (sbyte)BinSerialize.ReadByte(ref buffer); index += 1; arraySize = 3; for (var i = 0; i < arraySize; i++) { U8Array[i] = (byte)BinSerialize.ReadByte(ref buffer); index += 1; } arraySize = 3; for (var i = 0; i < arraySize; i++) { S8Array[i] = (sbyte)BinSerialize.ReadByte(ref buffer); index += 1; } }
public void Deserialize(ref ReadOnlySpan <byte> buffer) { var crcBuffer = buffer.Slice(1); var stx = BinSerialize.ReadByte(ref buffer); if (stx != PacketV2Helper.MagicMarkerV2) { throw new MavlinkException(string.Format(RS.WheelKnownConstant_VerifyStx_Unknown_STX_value, PacketV2Helper.MagicMarkerV2, stx)); } var payloadSize = BinSerialize.ReadByte(ref buffer); IncompatFlags = BinSerialize.ReadByte(ref buffer); CompatFlags = BinSerialize.ReadByte(ref buffer); Sequence = BinSerialize.ReadByte(ref buffer); SystemId = BinSerialize.ReadByte(ref buffer); ComponenId = BinSerialize.ReadByte(ref buffer); int messageId = BinSerialize.ReadByte(ref buffer); messageId |= BinSerialize.ReadByte(ref buffer) << 8; messageId |= BinSerialize.ReadByte(ref buffer) << 16; if (messageId != MessageId) { throw new MavlinkException(string.Format(RS.PacketV2_Deserialize_Error_message_id_type, MessageId, messageId)); } var crcStartBuffer = buffer.Slice(payloadSize, 2); var crc = BinSerialize.ReadUShort(ref crcStartBuffer); var originSize = Payload.GetMinByteSize(); if (payloadSize < originSize) { // this is Empty-Byte Payload Truncation https://mavlink.io/en/guide/serialization.html#payload_truncation var data = ArrayPool <byte> .Shared.Rent(originSize); var span = new Span <byte>(data, 0, originSize); buffer.Slice(0, payloadSize).CopyTo(span); var zeroByteNotEnough = originSize - payloadSize; for (var i = 0; i < zeroByteNotEnough; i++) { data[payloadSize + i] = 0; } try { var readOnly = new ReadOnlySpan <byte>(data, 0, originSize); Payload.Deserialize(ref readOnly, originSize); // Debug.Assert(readOnly.Length == 0); } finally { ArrayPool <byte> .Shared.Return(data); } } else { var payloadBuffer = buffer.Slice(0, payloadSize); Payload.Deserialize(ref payloadBuffer, payloadSize); //Debug.Assert(payloadBuffer.Length == 0); } var crcBuffer1 = crcBuffer.Slice(0, 9); var crcBuffer2 = crcBuffer.Slice(9, payloadSize); var calcCrc = X25Crc.Accumulate(ref crcBuffer1, X25Crc.CrcSeed); calcCrc = X25Crc.Accumulate(ref crcBuffer2, calcCrc); calcCrc = X25Crc.Accumulate(GetCrcEtra(), calcCrc); if (crc != calcCrc) { throw new MavlinkException(string.Format(RS.PacketV2Helper_VerifyCrc_Bad_X25Crc, calcCrc, crc)); } if ((IncompatFlags & 0x01) != 0) { Signature.Deserialize(ref buffer); } }