condition gcode in daemon
-
Im having this problem and I cant see what it really is. This is my daemon.g
while true if !(state.status = "processing") if (heat.heaters[0].current > 60) | (heat.heaters[1].current > 65) | (heat.heaters[2].current > 65) | (heat.heaters[0].avgPwm > 0.01) M42 P3 S1 M42 P3 S1 echo "active" else M42 P3 S0 G4 S2
If in console I do "echo (heat.heaters[0].current > 60) | (heat.heaters[1].current > 65) | (heat.heaters[2].current > 65) | (heat.heaters[0].avgPwm > 0.01)" while not printing, I get a FALSE result:
echo (heat.heaters[0].current > 60) | (heat.heaters[1].current > 65) | (heat.heaters[2].current > 65) | (heat.heaters[0].avgPwm > 0.01)
falseMy intention is to be sure a rele is OFF while not printin nor any heater active or hot.
For some reason that if statemen is been taken as true, and I dont know why. I have tested with echo the hole sentence and I can see it returns a false result. Also checking each of the conditional gives me false so Im sure the result of that if should be falso and so the else statement be exucuted, but... it is not working
but this failure is only happening after a print has finished. I I reboot the printer, looks like the daemon.g do what it is suposed to do.
Any ideas why?
thanks in advance
-
@Tinchus Content after
else
isn't supported. PutM42 P3 S0
in the next line:while true if state.status != "processing" if (heat.heaters[0].current > 60) | (heat.heaters[1].current > 65) | (heat.heaters[2].current > 65) | (heat.heaters[0].avgPwm > 0.01) M42 P3 S1 M42 P3 S1 echo "active" else M42 P3 S0 G4 S2
-
@chrishamm so I delete the "else"?
Why the lines in the fo statement are being executed even when the if result is being false? because of the wrong "else"?
-
@Tinchus No, just put the stuff in the next line. I updated your macro accordingly, see my previous post.
With your original macro
M42 P3 S0
is never executed because actions followingelse
must go into a new code block, which does not start before a "new line" with proper indentation. -
@chrishamm this the my original daemon.g (the one you saw was edited by my trying to see if the indentation in the else was the problem
while true if !(state.status = "processing") if (heat.heaters[0].current > 60) | (heat.heaters[1].current > 65) | (heat.heaters[2].current > 65) | (heat.heaters[0].avgPwm > 0.01) M42 P3 S1 M42 P3 S1 echo "active" else M42 P3 S0 G4 S2
-
@Tinchus Is there any particular reason you check
avgPwm
?