M291 cancel in nested macro does not abort parent macros
-
I can't figure out how to get this to behave the way I would expect. I ran into this issue with filament change macros before, where if the user hit "Cancel", the macro called via M98 would abort properly, but the command/macro that called it would continue on as though everything was fine. I'm encountering this issue in a more serious location right now though.
The machine has a Euclid probe, and I'm tweaking the probing macros to be more user-friendly. The homez/all commands call M401/M402, and normally that works fine. Right now I'm trying to solve the edge cases, where either the probe is faulty, or the probe is already deployed. The macros from the euclid creators handle this situation by telling the user to manually retract the probe via M402, which I think is kinda silly.
I'm trying to use M291 to handle this. It prompts the user to verify the probe is in fact deployed correctly, otherwise it allows the user to cancel (in the case that the probe is malfunctioning, etc). I'm on 3.4.6 (I don't want to be on an unstable firmware), and currently when you press OK, the behavior is correct, but if you press "Cancel", what I would expect is the home macro to abort. Instead, the deploy macro finishes, and it continues executing the home macro (effectively the same as pressing "OK"). I tried putting in an "if" to check the value of
result
after the M401 command, but it seems the firmware treats the M401 command as completing successfully, and the result is 0. I would expect it to be -1, or maybe 1 or 2 from the M401 aborting, but it is not. -
Firmware version?
-
@curieos said in M291 cancel in nested macro does not abort parent macros:
I'm on 3.4.6 (I don't want to be on an unstable firmware)
-
@curieos
In my mind the behaviour you're seeing is correct.
If you hit cancel, the rest of that macro is not run (so not the same as hitting OK)
I would not expect it to cancel anything other than the current macro.
To do that use the abort command.
Are you testing the result of M401 immediately after calling it?M401 if result!= 0 abort "probe error"
If you want a way of escalating the cancel, you could use a global variable
Set it to false at the start of the macro and true at the very end (after the M291)
If cancel was pressed it will remain falseSo you upper macro would look like
M98 P"do-probing.g" if global.macroSuccessful = false echo "nested macro failed" M99
-
@OwenD said in M291 cancel in nested macro does not abort parent macros:
Are you testing the result of M401 immediately after calling it?
Yes, currently the relevant snippet of homeall.g looks like:
M401 ; deploy probe if result != 0 abort "Probe deploy error"
I can't use the abort command in this context, since I have no control over what happens when cancel is pressed.
I'm not a big fan of the global variable fix, it feels like a hack. If there is no other solution, I will use that method though.
-