public JT808_0x0705 Deserialize(ReadOnlySpan <byte> bytes, out int readSize) { int offset = 0; JT808_0x0705 jT808_0X0705 = new JT808_0x0705 { CanItemCount = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset), FirstCanReceiveTime = JT808BinaryExtensions.ReadDateTime5Little(bytes, ref offset), CanItems = new List <JT808Properties.JT808CanProperty>() }; for (var i = 0; i < jT808_0X0705.CanItemCount; i++) { JT808Properties.JT808CanProperty jT808CanProperty = new JT808Properties.JT808CanProperty { CanId = JT808BinaryExtensions.ReadBytesLittle(bytes, ref offset, 4) }; if (jT808CanProperty.CanId.Length != 4) { throw new JT808Exception(Enums.JT808ErrorCode.NotEnoughLength, $"{nameof(jT808CanProperty.CanId)}->4"); } jT808CanProperty.CanData = JT808BinaryExtensions.ReadBytesLittle(bytes, ref offset, 8); if (jT808CanProperty.CanData.Length != 8) { throw new JT808Exception(Enums.JT808ErrorCode.NotEnoughLength, $"{nameof(jT808CanProperty.CanData)}->8"); } jT808_0X0705.CanItems.Add(jT808CanProperty); } readSize = offset; return(jT808_0X0705); }
public JT808_0x0705 Deserialize(ReadOnlySpan <byte> bytes, out int readSize) { int offset = 0; JT808_0x0705 jT808_0X0705 = new JT808_0x0705(); jT808_0X0705.CanItemCount = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808_0X0705.FirstCanReceiveTime = JT808BinaryExtensions.ReadDateTime5Little(bytes, ref offset); jT808_0X0705.CanItems = new List <JT808Properties.JT808CanProperty>(); for (var i = 0; i < jT808_0X0705.CanItemCount; i++) { JT808Properties.JT808CanProperty jT808CanProperty = new JT808Properties.JT808CanProperty(); jT808CanProperty.CanId = JT808BinaryExtensions.ReadBytesLittle(bytes, ref offset, 4); jT808CanProperty.CanData = JT808BinaryExtensions.ReadBytesLittle(bytes, ref offset, 8); jT808_0X0705.CanItems.Add(jT808CanProperty); } readSize = offset; return(jT808_0X0705); }