Skip to content

Fix where 'ACCEL_CHIP' required double quoting#235

Open
Contomo wants to merge 1 commit intoFrix-x:mainfrom
Contomo:main
Open

Fix where 'ACCEL_CHIP' required double quoting#235
Contomo wants to merge 1 commit intoFrix-x:mainfrom
Contomo:main

Conversation

@Contomo
Copy link

@Contomo Contomo commented Sep 1, 2025

possible fix for issue ticket #234

Summary by Sourcery

Update Shaketune dummy_macros.cfg to simplify parameter handling in gcode macros by using params.update and xmlattr filter, fixing ACCEL_CHIP quoting issue

Bug Fixes:

  • Ensure ACCEL_CHIP parameter is properly quoted in generated gcode macros

Enhancements:

  • Refactor template macros to update params inline and render attributes using xmlattr filter instead of manual filtering loops

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 1, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors three gcode macros in dummy_macros.cfg to replace manual parameter filtering and loop-based attribute construction with params.update() and xmlattr rendering, ensuring ACCEL_CHIP and other optional parameters are correctly quoted.

Sequence diagram for macro parameter handling in gcode macros

sequenceDiagram
    participant Macro as gcode_macro
    participant Params as params
    participant Render as xmlattr
    Macro->>Params: update() with macro variables
    Macro->>Render: Render params as xmlattr
    Render-->>Macro: Quoted attributes for command
    Macro->>Macro: Execute command with quoted params
Loading

Class diagram for updated macro parameter handling

classDiagram
    class Params {
        +update(dict)
        +xmlattr
    }
    class gcode_macro {
        -macro variables
        +params: Params
        +command execution
    }
    gcode_macro --> Params: uses
    Params --> xmlattr: renders attributes
Loading

File-Level Changes

Change Details Files
Consolidate parameter handling and attribute rendering for macros using params.update and xmlattr
  • Removed manual params_filtered dicts and for-loop expansions
  • Added params.update() calls to merge new parameters
  • Replaced per-key loop with a single {params
xmlattr} invocation
  • Ensured ACCEL_CHIP and other optional values are properly quoted

  • Tips and commands

    Interacting with Sourcery

    • Trigger a new review: Comment @sourcery-ai review on the pull request.
    • Continue discussions: Reply directly to Sourcery's review comments.
    • Generate a GitHub issue from a review comment: Ask Sourcery to create an
      issue from a review comment by replying to it. You can also reply to a
      review comment with @sourcery-ai issue to create an issue from it.
    • Generate a pull request title: Write @sourcery-ai anywhere in the pull
      request title to generate a title at any time. You can also comment
      @sourcery-ai title on the pull request to (re-)generate the title at any time.
    • Generate a pull request summary: Write @sourcery-ai summary anywhere in
      the pull request body to generate a PR summary at any time exactly where you
      want it. You can also comment @sourcery-ai summary on the pull request to
      (re-)generate the summary at any time.
    • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
      request to (re-)generate the reviewer's guide at any time.
    • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
      pull request to resolve all Sourcery comments. Useful if you've already
      addressed all the comments and don't want to see them anymore.
    • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
      request to dismiss all existing Sourcery reviews. Especially useful if you
      want to start fresh with a new review - don't forget to comment
      @sourcery-ai review to trigger a new review!

    Customizing Your Experience

    Access your dashboard to:

    • Enable or disable review features such as the Sourcery-generated pull request
      summary, the reviewer's guide, and others.
    • Change the review language.
    • Add, remove or edit custom review instructions.
    • Adjust other review settings.

    Getting Help

    Copy link
    Contributor

    @sourcery-ai sourcery-ai bot left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Hey there - I've reviewed your changes and they look great!


    Sourcery is free for open source - if you like our reviews please consider sharing them ✨
    Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

    @Frix-x
    Copy link
    Owner

    Frix-x commented Sep 25, 2025

    Thanks a lot for the issue and PR! It indeed solves the quoting issue with spaces in string parameters (like ACCEL_CHIP="adxl345 T0"), which I agree is a problem with the current dummy macros.

    However, switching everything to {params|xmlattr} also introduces a side effect with optional parameters that will stay empty and be emmited like Z_HEIGHT="" and that will break the Python side, since gcmd.get_float() tries to parse "" and fails. So that's why in my current macros, I've got the things done like this with those optional values skipped entirely when not provided.

    So I won’t merge this version as-is, but if you are OK, I’ll adapt it into a combined solution that:

    1. preserve proper quoting for strings with spaces
    2. keep skipping None/empty parameters instead of emitting param=""

    @Frix-x
    Copy link
    Owner

    Frix-x commented Sep 25, 2025

    Can you have a look at #239 and see if it's working for you?

    @Contomo
    Copy link
    Author

    Contomo commented Sep 26, 2025

    a side effect with optional parameters that will stay empty and be emmited like Z_HEIGHT="" and that will break the Python side, since gcmd.get_float() tries to parse "" and fails

    When is that the issue? or rather, when is that the case?
    as in "how would that even happen"

    The only way i can get this issue is when manually entering ""

    Error on '_AXES_SHAPER_CALIBRATION  ACCEL_PER_HZ="" HZ_PER_SEC="1" AXIS="all" TRAVEL_SPEED="120"': unable to parse
    Shake&Tune version: v5.2.1
    axes_shaper_calibration ACCEL_PER_HZ=""
    
    Must home axis first: 175.000 175.000 20.000 [0.000]
    Shake&Tune version: v5.2.1
    axes_shaper_calibration
    

    Or may that be a fluid specific quirk? (im using mainsail)
    otherwise i dont see how that would happen.

    Ill try out your fix once the printer is not in pieces anymore ^^

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants