Skip to content

Commit

Permalink
ULog: fix parser error
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Mar 10, 2023
1 parent 767b0cc commit 3e2d41e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions ExtLibs/Utilities/ULog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -193,11 +194,13 @@ public struct message_format_s
public message_format_s(Span<byte> 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)]
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -395,7 +405,7 @@ public string Value

public ulog_message_parameter_default_header_s(Span<byte> buffer) : this()
{
key_len = buffer[0];
key_len = buffer[1];
key = buffer.Slice(2, key_len).ToArray();
value = buffer.Slice(2 + key_len).ToArray();
}
Expand Down Expand Up @@ -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; }

Expand Down

0 comments on commit 3e2d41e

Please sign in to comment.