Skip to content
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

[BUG] E0_AUTO_FAN_PIN sanity check for FAN0_PIN is not triggred #26590

Closed
ellensp opened this issue Dec 30, 2023 · 5 comments · Fixed by #26591
Closed

[BUG] E0_AUTO_FAN_PIN sanity check for FAN0_PIN is not triggred #26590

ellensp opened this issue Dec 30, 2023 · 5 comments · Fixed by #26591

Comments

@ellensp
Copy link
Contributor

ellensp commented Dec 30, 2023

Did you test the latest bugfix-2.1.x code?

Yes, and the problem still exists.

Bug Description

Take stock Configs, set #define E0_AUTO_FAN_PIN FAN0_PIN
Watch as Marlin compiles without any issues
despite having the following in sanity check.

    #if PIN_EXISTS(E0_AUTO_FAN) && E0_AUTO_FAN_PIN == FAN0_PIN
      #error "You cannot set E0_AUTO_FAN_PIN equal to FAN0_PIN."

Bug Timeline

Since #25568

Expected behavior

This should trigger the error in sanity check "You cannot set E0_AUTO_FAN_PIN equal to FAN0_PIN."

Actual behavior

no error

Steps to Reproduce

  1. set #define E0_AUTO_FAN_PIN FAN0_PIN
  2. compile
  3. note it compiles without error

Version of Marlin Firmware

Bugfix-2.1.x

@ellensp
Copy link
Contributor Author

ellensp commented Dec 30, 2023

In Marlin/src/inc/SanityCheck.h is the following code

#if HAS_AUTO_FAN
  #if HAS_FAN0
    #if PIN_EXISTS(E0_AUTO_FAN) && E0_AUTO_FAN_PIN == FAN0_PIN
      #error "You cannot set E0_AUTO_FAN_PIN equal to FAN0_PIN."
    #elif PIN_EXISTS(E1_AUTO_FAN) && E1_AUTO_FAN_PIN == FAN0_PIN
      #error "You cannot set E1_AUTO_FAN_PIN equal to FAN0_PIN."
    #elif PIN_EXISTS(E2_AUTO_FAN) && E2_AUTO_FAN_PIN == FAN0_PIN
      #error "You cannot set E2_AUTO_FAN_PIN equal to FAN0_PIN."
    #elif PIN_EXISTS(E3_AUTO_FAN) &&  E3_AUTO_FAN_PIN == FAN0_PIN
      #error "You cannot set E3_AUTO_FAN_PIN equal to FAN0_PIN."
    #endif
  #endif
#endif

But HAS_FAN0 is not set, so this block is ignored.

In Marlin/src/inc/Conditionals_post.h has this code

#define _IS_E_AUTO(N,F) (PIN_EXISTS(E##N##_AUTO_FAN) && E##N##_AUTO_FAN_PIN == FAN##F##_PIN)
#define _HAS_FAN(F) (F < MAX_FANS && PIN_EXISTS(FAN##F) \
                     && !(HAS_CONTROLLER_FAN && CONTROLLER_FAN_PIN == FAN##F##_PIN) \
                     && !_IS_E_AUTO(0,F) && !_IS_E_AUTO(1,F) \
                     && !_IS_E_AUTO(2,F) && !_IS_E_AUTO(3,F) \
                     && !_IS_E_AUTO(4,F) && !_IS_E_AUTO(5,F) \
                     && !_IS_E_AUTO(6,F) && !_IS_E_AUTO(7,F))

#if _HAS_FAN(0)
  #define HAS_FAN0 1
#endif

The test explicitly checks for E0_AUTO_FAN == FAN0_PIN and tells marlin that HAS_FAN0 is false, disabling the sanity check.

@ellensp
Copy link
Contributor Author

ellensp commented Dec 30, 2023

proposal, treat FAN0 as special, only check it has been defined. as it was originally

diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h
index 04e96177b5..d946904e75 100644
--- a/Marlin/src/inc/Conditionals_post.h
+++ b/Marlin/src/inc/Conditionals_post.h
@@ -2657,7 +2657,7 @@
                      && !_IS_E_AUTO(4,F) && !_IS_E_AUTO(5,F) \
                      && !_IS_E_AUTO(6,F) && !_IS_E_AUTO(7,F))
 
-#if _HAS_FAN(0)
+#if PIN_EXISTS(FAN0)
   #define HAS_FAN0 1
 #endif
 #if _HAS_FAN(1)

@thisiskeithb
Copy link
Member

proposal, treat FAN0 as special, only check it has been defined. as it was originally

Can confirm that the sanity check now fails when it should.

@ellensp
Copy link
Contributor Author

ellensp commented Dec 30, 2023

PR created, closing.

@ellensp ellensp closed this as completed Dec 30, 2023
@thisiskeithb thisiskeithb linked a pull request Dec 30, 2023 that will close this issue
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants