Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    sbyte (int8_t) type in DSF for g-codes with MinorNumber

    Scheduled Pinned Locked Moved
    DSF Development
    2
    2
    111
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • fragrama17undefined
      fragrama17
      last edited by

      @chrishamm Is there a reason why DSF uses an sbyte (int8_t) for MinorNumber when parsing a g-code, and then check that value is greater than 0 in the Parser class ?

      if (sbyte.TryParse(args[1], out sbyte minorNumber) && minorNumber >= 0)
       {
          result.MinorNumber = minorNumber;
       }
       else
       {
          throw new CodeParserException($"Failed to parse minor {char.ToUpperInvariant((char)result.Type)}-code number ({args[1]})", result);
       }
      

      The type used in RepRap looks like an integer

      struct CodeHeader
      {
      	uint8_t channel;
      	CodeFlags flags;
      	uint8_t numParameters;
      	char letter;
      	int32_t majorCode;
      	int32_t minorCode;
      	uint32_t filePosition;
      	int32_t lineNumber;
      };
      

      Would it be possible to use the same data type or just a more redundant integer type ?

      chrishammundefined 1 Reply Last reply Reply Quote 0
      • chrishammundefined
        chrishamm administrators @fragrama17
        last edited by

        @fragrama17 I'm quite sure the minor number parameter was an sbyte in early DSF versions. I'll change the parser accordingly. Thanks for pointing this out.

        Negative command portions should not be supported so I'll leave that exception there. RRF may be changed to throw an exception, too.

        Duet software engineer

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Unless otherwise noted, all forum content is licensed under CC-BY-SA