📄
src/DltMessage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using SharpDlt.Internal; namespace SharpDlt; /// <summary> /// A DLT message consisting of its headers and its payload. /// </summary> /// <param name="StorageHeader">Storage Header of the message, if the message was stored in a file.</param> /// <param name="StandardHeader">Standard Header of the message.</param> /// <param name="ExtendedHeader">Extended Header of the message, if it is transmitted.</param> /// <param name="Payload">Payload of the message, if it carries one.</param> public sealed record DltMessage( StorageHeader? StorageHeader, StandardHeader StandardHeader, ExtendedHeader? ExtendedHeader, DltPayload? Payload ) { /// <summary>Gets a value indicating whether the message is in verbose mode.</summary> public bool IsVerbose => ExtendedHeader?.Verbose ?? false; /// <summary>Gets the payload as a verbose payload, or <see langword="null"/> if it is not verbose.</summary> public VerbosePayload? VerbosePayload => Payload as VerbosePayload; /// <summary>Gets the payload as a non-verbose payload, or <see langword="null"/> if it is verbose.</summary> public NonVerbosePayload? NonVerbosePayload => Payload as NonVerbosePayload; /// <summary>Parses a single DLT message from the beginning of <paramref name="data"/>.</summary> /// <param name="data">The data of one complete DLT message.</param> /// <param name="options">Options controlling the parsing, <see cref="DltReaderOptions.Default"/> if omitted.</param> /// <exception cref="DltParseException">The data is malformed.</exception> public static DltMessage Parse(ReadOnlySpan<byte> data, DltReaderOptions? options = null) { options ??= DltReaderOptions.Default; return DltMessageParser.Parse(data, options.HasStorageHeader, options.StringEncoding); } /// <summary> /// Gets an overview of the message in the format /// <c>[time ][timestamp ]counter[ ecuid][ apid][ ctid][ session][ type][ subtype] mode[ args][ payload]</c>. /// </summary> public override string ToString() => DltMessageParser.Describe(this); }