From 3e2d41ec34cd2fb5b4d34d767051ba6ecab5ce3c Mon Sep 17 00:00:00 2001 From: Michael Oborne Date: Fri, 10 Mar 2023 16:22:05 +1100 Subject: [PATCH] ULog: fix parser error --- ExtLibs/Utilities/ULog.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ExtLibs/Utilities/ULog.cs b/ExtLibs/Utilities/ULog.cs index 42e7d1ae09..7af96725a3 100644 --- a/ExtLibs/Utilities/ULog.cs +++ b/ExtLibs/Utilities/ULog.cs @@ -7,6 +7,7 @@ using uint16_t = System.UInt16; using uint64_t = System.UInt64; using uint8_t = System.Byte; +using int8_t = System.SByte; namespace MissionPlanner.Utilities { @@ -193,11 +194,13 @@ public struct message_format_s public message_format_s(Span enumerable) : this() { format = enumerable.ToArray(); + Format = ASCIIEncoding.ASCII.GetString(format); + Type = ASCIIEncoding.ASCII.GetString(format).Split(':')[0]; } - public string Format { get => ASCIIEncoding.ASCII.GetString(format); } + public string Format { get; set; } - public string Type { get => ASCIIEncoding.ASCII.GetString(format).Split(':')[0]; } + public string Type { get; set; } } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -235,7 +238,8 @@ public static object ConvertType(string type, byte[] value, ref int width) if (value.Length == 0) return ""; - if (type.Contains("[")) + + if (type.Contains("[") || format.Any(a => a.Type == type)) { var typestring = type.Split('[')[0]; @@ -282,6 +286,12 @@ public static object ConvertType(string type, byte[] value, ref int width) } } + if (type.StartsWith("int8_t")) + { + width = 1; + return value[0]; + } + if (type.StartsWith("uint8_t")) { width = 1; @@ -395,7 +405,7 @@ public string Value public ulog_message_parameter_default_header_s(Span buffer) : this() { - key_len = buffer[0]; + key_len = buffer[1]; key = buffer.Slice(2, key_len).ToArray(); value = buffer.Slice(2 + key_len).ToArray(); } @@ -435,7 +445,7 @@ public struct message_data_s { public uint16_t msg_id; - public uint8_t[] data; + internal uint8_t[] data; public string Decoded { get; set; }