From 027da9bbac4f2ae21384ab9054722132c2395f1a Mon Sep 17 00:00:00 2001 From: tuxuser <462620+tuxuser@users.noreply.github.com> Date: Fri, 24 Jul 2026 05:16:14 +0200 Subject: [PATCH] fix: compatibility with new fw / full error codes --- .../SerialDecoderTests.cs | 15 ++++++++++----- PostCodeSerialMonitor/Models/CsvConverters.cs | 4 ++-- PostCodeSerialMonitor/Models/DecodedCode.cs | 7 ++----- .../Models/ErrorMaskDefinition.cs | 5 +++-- PostCodeSerialMonitor/Models/LogEntry.cs | 3 +-- .../Models/OSErrorDefinition.cs | 3 ++- .../Models/PostCodeDefinition.cs | 5 +++-- .../Services/SerialLineDecoder.cs | 17 +++-------------- .../ViewModels/DebugDialogViewModel.cs | 7 +++---- PostCodeSerialMonitor/Views/MainWindow.axaml | 14 +++----------- 10 files changed, 32 insertions(+), 48 deletions(-) diff --git a/PostCodeSerialMonitor.Tests/SerialDecoderTests.cs b/PostCodeSerialMonitor.Tests/SerialDecoderTests.cs index 27a0e16..39b584e 100644 --- a/PostCodeSerialMonitor.Tests/SerialDecoderTests.cs +++ b/PostCodeSerialMonitor.Tests/SerialDecoderTests.cs @@ -13,14 +13,20 @@ public class TestDataGenerator : IEnumerable { private readonly List _data = new List { - new object[] {"CPU (1): 0x14ff [2BL_FINAL_SUCCESS] (6683 ms)", new DecodedCode(){ + new object[] {"CPU: 0x14ff (+0.000 mS)", new DecodedCode(){ Flavor = CodeFlavor.CPU, - Index = 1, Code = 0x14ff }}, - new object[] {"SP (1): 0x0075 [BOOT_SUCCESS] (2423 ms)", new DecodedCode(){ + new object[] {"CPU: 0x14ff", new DecodedCode(){ + Flavor = CodeFlavor.CPU, + Code = 0x14ff + }}, + new object[] {"SP : 0x75 (+4252.064 mS)", new DecodedCode(){ + Flavor = CodeFlavor.SP, + Code = 0x0075 + }}, + new object[] {"SP : 0x75", new DecodedCode(){ Flavor = CodeFlavor.SP, - Index = 1, Code = 0x0075 }} }; @@ -86,7 +92,6 @@ public void TestDecoding(string input, DecodedCode expected) var result = _decoder.DecodeLine(input, ConsoleType.XboxOnePhat); Assert.NotNull(result); Assert.Equal(expected.Flavor, result.Flavor); - Assert.Equal(expected.Index, result.Index); Assert.Equal(expected.Code, result.Code); } } \ No newline at end of file diff --git a/PostCodeSerialMonitor/Models/CsvConverters.cs b/PostCodeSerialMonitor/Models/CsvConverters.cs index 9a19ff3..6319c07 100644 --- a/PostCodeSerialMonitor/Models/CsvConverters.cs +++ b/PostCodeSerialMonitor/Models/CsvConverters.cs @@ -12,7 +12,7 @@ public class HexNumberConverter : DefaultTypeConverter if (text == null || text == "") return null; - return Convert.ToUInt32(text, 16); + return Convert.ToUInt64(text, 16); } public override string? ConvertToString(object? value, IWriterRow row, MemberMapData memberMapData) @@ -20,7 +20,7 @@ public class HexNumberConverter : DefaultTypeConverter if (value == null) return null; - return $"0x{value:X4}"; + return $"0x{value:X8}"; } } diff --git a/PostCodeSerialMonitor/Models/DecodedCode.cs b/PostCodeSerialMonitor/Models/DecodedCode.cs index 1696cf8..4579c73 100644 --- a/PostCodeSerialMonitor/Models/DecodedCode.cs +++ b/PostCodeSerialMonitor/Models/DecodedCode.cs @@ -4,8 +4,7 @@ namespace PostCodeSerialMonitor.Models; public class DecodedCode { public CodeFlavor Flavor { get; set; } - public int Index { get; set; } - public int Code { get; set; } + public UInt64 Code { get; set; } public CodeSeverity SeverityLevel { get; set; } = CodeSeverity.Info; public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; @@ -14,8 +13,7 @@ public override int GetHashCode() { var result = 0; result = (result * 397) ^ Convert.ToInt32(Flavor); - result = (result * 397) ^ Index; - result = (result * 397) ^ Code; + result = (result * 397) ^ (int)Code; result = (result * 397) ^ Convert.ToInt32(SeverityLevel); return result; } @@ -26,7 +24,6 @@ public bool Equals(DecodedCode obj) { return ( this.Flavor == obj.Flavor - && this.Index == obj.Index && this.Code == obj.Code && this.SeverityLevel == obj.SeverityLevel ); diff --git a/PostCodeSerialMonitor/Models/ErrorMaskDefinition.cs b/PostCodeSerialMonitor/Models/ErrorMaskDefinition.cs index 6e5b580..0062bc1 100644 --- a/PostCodeSerialMonitor/Models/ErrorMaskDefinition.cs +++ b/PostCodeSerialMonitor/Models/ErrorMaskDefinition.cs @@ -1,3 +1,4 @@ +using System; using CsvHelper.Configuration.Attributes; namespace PostCodeSerialMonitor.Models; @@ -12,10 +13,10 @@ public class ErrorMaskDefinition public CodeFlavor CodeFlavor { get; set; } = CodeFlavor.UNKNOWN; [TypeConverter(typeof(HexNumberConverter))] - public uint Bitmask { get; set; } + public UInt64 Bitmask { get; set; } [TypeConverter(typeof(HexNumberConverter))] - public uint Code { get; set; } + public UInt64 Code { get; set; } public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; diff --git a/PostCodeSerialMonitor/Models/LogEntry.cs b/PostCodeSerialMonitor/Models/LogEntry.cs index 714ba8d..dd31be4 100644 --- a/PostCodeSerialMonitor/Models/LogEntry.cs +++ b/PostCodeSerialMonitor/Models/LogEntry.cs @@ -31,7 +31,6 @@ public bool IsSelected public string CodeText => FormatCodeText(); // Individual fields, for column-aligned display public string FlavorText => DecodedCode.Flavor.ToString(); - public string IndexText => $"({DecodedCode.Index}):"; public string CodeHexText => $"{DecodedCode.Code:X4}"; public string NameText => string.IsNullOrEmpty(DecodedCode?.Name) ? string.Empty : $"[{DecodedCode.Name}]"; // Name + description on one line, for the truncated inline preview @@ -48,7 +47,7 @@ public bool IsSelected private string FormatCodeText() { // Format flavor, index, and code with fixed spacing - var formatted = $"{DecodedCode?.Flavor,-4} ({DecodedCode?.Index}): {DecodedCode?.Code,4:X4}"; + var formatted = $"{DecodedCode?.Flavor,-4}: {DecodedCode?.Code,4:X8}"; if (!string.IsNullOrEmpty(DecodedCode?.Name)) formatted += $" [{DecodedCode?.Name}]"; return formatted; diff --git a/PostCodeSerialMonitor/Models/OSErrorDefinition.cs b/PostCodeSerialMonitor/Models/OSErrorDefinition.cs index 8c2d27a..f9e73a9 100644 --- a/PostCodeSerialMonitor/Models/OSErrorDefinition.cs +++ b/PostCodeSerialMonitor/Models/OSErrorDefinition.cs @@ -1,3 +1,4 @@ +using System; using CsvHelper.Configuration.Attributes; namespace PostCodeSerialMonitor.Models; @@ -13,7 +14,7 @@ public class OSErrorDefinition public CodeFlavor CodeFlavor { get; set; } = CodeFlavor.UNKNOWN; [TypeConverter(typeof(HexNumberConverter))] - public uint Code { get; set; } + public UInt64 Code { get; set; } public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; diff --git a/PostCodeSerialMonitor/Models/PostCodeDefinition.cs b/PostCodeSerialMonitor/Models/PostCodeDefinition.cs index 4dbcc19..65212e7 100644 --- a/PostCodeSerialMonitor/Models/PostCodeDefinition.cs +++ b/PostCodeSerialMonitor/Models/PostCodeDefinition.cs @@ -1,3 +1,4 @@ +using System; using CsvHelper.Configuration.Attributes; namespace PostCodeSerialMonitor.Models; @@ -12,9 +13,9 @@ public class PostCodeDefinition public CodeFlavor CodeFlavor { get; set; } = CodeFlavor.UNKNOWN; [TypeConverter(typeof(HexNumberConverter))] - public uint Code { get; set; } + public UInt64 Code { get; set; } [TypeConverter(typeof(HexNumberConverter))] - public uint? Bitmask { get; set; } + public UInt64? Bitmask { get; set; } public bool IsError { get; set; } public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; diff --git a/PostCodeSerialMonitor/Services/SerialLineDecoder.cs b/PostCodeSerialMonitor/Services/SerialLineDecoder.cs index be27df0..24b581e 100644 --- a/PostCodeSerialMonitor/Services/SerialLineDecoder.cs +++ b/PostCodeSerialMonitor/Services/SerialLineDecoder.cs @@ -9,7 +9,7 @@ public class SerialLineDecoder { private readonly MetaDefinitionService _metaDefinitionService; private readonly ILogger _logger; - private static readonly Regex regex = new Regex(@"^(SMC|SP|CPU|OS)\s+?\((\d)\)\s?\:\s?([x0-9a-fA-F]{6})"); + private static readonly Regex regex = new Regex(@"^(SMC|SP|CPU|OS)\s?\:\s?([x0-9a-fA-F]{4,})\s?"); public SerialLineDecoder(MetaDefinitionService metaDefinitionService, ILogger logger) { @@ -27,8 +27,7 @@ public SerialLineDecoder(MetaDefinitionService metaDefinitionService, ILogger x.Code == code && diff --git a/PostCodeSerialMonitor/ViewModels/DebugDialogViewModel.cs b/PostCodeSerialMonitor/ViewModels/DebugDialogViewModel.cs index 47589cb..90a51c3 100644 --- a/PostCodeSerialMonitor/ViewModels/DebugDialogViewModel.cs +++ b/PostCodeSerialMonitor/ViewModels/DebugDialogViewModel.cs @@ -54,7 +54,7 @@ private void FillDummyData() { for (int i = 0; i < (int)EntryCount; i++) { - var code = i * 0x11; + var code = (UInt64)(i * 0x11); var segment = i % 4; var flavor = CodeFlavors[i % CodeFlavors.Count]; @@ -65,7 +65,6 @@ private void FillDummyData() DecodedCode = new DecodedCode { Flavor = flavor, - Index = segment, Code = code, SeverityLevel = (CodeSeverity)(i % 3), Name = $"DEBUG_CODE_{i}", @@ -80,13 +79,13 @@ private void FillDummyData() [RelayCommand] private async Task DecodeStandaloneAsync() { - int code; + UInt64 code; try { var hex = CodeInput.Trim(); if (hex.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) hex = hex[2..]; - code = Convert.ToInt32(hex, 16) & 0xFFFF; + code = Convert.ToUInt64(hex, 16); } catch (Exception) { diff --git a/PostCodeSerialMonitor/Views/MainWindow.axaml b/PostCodeSerialMonitor/Views/MainWindow.axaml index 79774e7..1a0d241 100644 --- a/PostCodeSerialMonitor/Views/MainWindow.axaml +++ b/PostCodeSerialMonitor/Views/MainWindow.axaml @@ -229,15 +229,7 @@ FontSize="16" Margin="0,0,4,0" VerticalAlignment="Top"/> - - - -