Skip to content

Commit

Permalink
Change data type of minor command fraction
Browse files Browse the repository at this point in the history
This is a fix for #209
  • Loading branch information
chrishamm committed Nov 4, 2024
1 parent 661174a commit 8f8a9fc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/DuetAPI/Commands/Code/Code.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Code(string code)
/// <summary>
/// Minor code number (e.g. 3 in G54.3)
/// </summary>
public sbyte? MinorNumber { get; set; }
public int? MinorNumber { get; set; }

/// <summary>
/// Flags of this code
Expand Down
2 changes: 1 addition & 1 deletion src/DuetAPI/Commands/Code/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/DuetAPI/Commands/Code/ParserAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/DuetControlServer/SPI/Serialization/Writer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public static int WriteCode(Span<byte> 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)
};

Expand Down

0 comments on commit 8f8a9fc

Please sign in to comment.