diff --git a/src/DuetAPI/Commands/Code/Code.cs b/src/DuetAPI/Commands/Code/Code.cs index f25fe8fa9..8e0751587 100644 --- a/src/DuetAPI/Commands/Code/Code.cs +++ b/src/DuetAPI/Commands/Code/Code.cs @@ -95,7 +95,7 @@ public Code(string code) /// /// Minor code number (e.g. 3 in G54.3) /// - public sbyte? MinorNumber { get; set; } + public int? MinorNumber { get; set; } /// /// Flags of this code diff --git a/src/DuetAPI/Commands/Code/Parser.cs b/src/DuetAPI/Commands/Code/Parser.cs index 3b836edf1..8287d0cc0 100644 --- a/src/DuetAPI/Commands/Code/Parser.cs +++ b/src/DuetAPI/Commands/Code/Parser.cs @@ -457,7 +457,7 @@ public static bool Parse(TextReader reader, Code result) { throw new CodeParserException($"Failed to parse major {char.ToUpperInvariant((char)result.Type)}-code number ({args[0]})", result); } - if (sbyte.TryParse(args[1], out sbyte minorNumber) && minorNumber >= 0) + if (int.TryParse(args[1], out int minorNumber) && minorNumber >= 0) { result.MinorNumber = minorNumber; } diff --git a/src/DuetAPI/Commands/Code/ParserAsync.cs b/src/DuetAPI/Commands/Code/ParserAsync.cs index 7c953f6c1..c26879bfc 100644 --- a/src/DuetAPI/Commands/Code/ParserAsync.cs +++ b/src/DuetAPI/Commands/Code/ParserAsync.cs @@ -597,7 +597,7 @@ void clearValue() { throw new CodeParserException($"Failed to parse major {char.ToUpperInvariant((char)result.Type)}-code number ({args[0]})", result); } - if (sbyte.TryParse(args[1], out sbyte minorNumber) && minorNumber >= 0) + if (int.TryParse(args[1], out int minorNumber) && minorNumber >= 0) { result.MinorNumber = minorNumber; } diff --git a/src/DuetControlServer/SPI/Serialization/Writer.cs b/src/DuetControlServer/SPI/Serialization/Writer.cs index 671ce3aaa..97a5c2efc 100644 --- a/src/DuetControlServer/SPI/Serialization/Writer.cs +++ b/src/DuetControlServer/SPI/Serialization/Writer.cs @@ -72,8 +72,8 @@ public static int WriteCode(Span to, Code code) Channel = code.Channel, FilePosition = (uint)(code.FilePosition ?? 0xFFFFFFFF), Letter = (byte)code.Type, - MajorCode = (code.Type == CodeType.Comment) ? 0 : (code.MajorNumber ?? -1), - MinorCode = code.MinorNumber ?? -1, + MajorCode = (code.Type == CodeType.Comment) ? 0 : (code.MajorNumber ?? 0), + MinorCode = code.MinorNumber ?? 0, NumParameters = (byte)((code.Type == CodeType.Comment) ? 1 : code.Parameters.Count) };