Skip to content

[BUGFIX] Avoid invalid Wipetower G-Code (G1 F-2147483648) #14433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mjonuschat
Copy link
Contributor

@mjonuschat mjonuschat commented Apr 12, 2025

Setup instructions for some open source MMUs recommend setting all ramming and cooling parameters to 0 when using a filament cutter. This in turn leads to division by zero errors in the wipe tower g-code, and the outcome depends on the operating system and compiler being used.

At least on builds for Windows with VC2019 the bug leads to invalid code for the cooling moves that looks like this:

;WIDTH:0.5
G1 X98.896 Y232.718
G1 F3000
G1 F-2147483648
G1 F3000
G1 F-2147483648
G1 F3000
G1 F-2147483648
G1 F3000
G1 F-2147483648
G1 F2000
G1 X98.846 Y232.718 F2400

The behavior seems to originate from the compiller spec recommending turning a NaN float value (from the division by zero) into an INT_MIN when casting from float to int.

This diff avoids emitting the whole cooling move when either speed or distance are 0.

Setup instructions for some open source MMUs recommend setting all ramming and cooling parameters to 0 when using a filament cutter.
This in turn leads to division by zero errors in the wipe tower g-code, and the outcome depends on the operating system and compiler being used.
At least on builds for Windows with VC2019 the bug leads to invalid code for the cooling moves that looks like this:

```
;WIDTH:0.5
G1 X98.896 Y232.718
G1 F3000
G1 F-2147483648
G1 F3000
G1 F-2147483648
G1 F3000
G1 F-2147483648
G1 F3000
G1 F-2147483648
G1 F2000
G1 X98.846 Y232.718 F2400
```

The behavior seems to originate from the compiller spec recommending turning a NaN float value (from the division by zero) into an INT_MIN when casting from float to int.

This diff avoids emitting the whole cooling move when either speed or distance are 0.
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.

1 participant