Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    M291 cancel in nested macro does not abort parent macros

    Scheduled Pinned Locked Moved
    Gcode meta commands
    3
    5
    258
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • curieosundefined
      curieos
      last edited by

      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.

      She/Her
      I work at a local 3D printing shop.
      Printers: Micron+ w/Duet 3 Mini, in-progress adaptation of the Jubilee REL onto an E3D MS, Prusa i3 MK3S.

      1 Reply Last reply Reply Quote 0
      • Phaedruxundefined
        Phaedrux Moderator
        last edited by

        Firmware version?

        Z-Bot CoreXY Build | Thingiverse Profile

        curieosundefined 1 Reply Last reply Reply Quote 0
        • curieosundefined
          curieos @Phaedrux
          last edited by

          @Phaedrux

          @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)

          She/Her
          I work at a local 3D printing shop.
          Printers: Micron+ w/Duet 3 Mini, in-progress adaptation of the Jubilee REL onto an E3D MS, Prusa i3 MK3S.

          OwenDundefined 1 Reply Last reply Reply Quote 0
          • OwenDundefined
            OwenD @curieos
            last edited by

            @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 false

            So you upper macro would look like

            M98 P"do-probing.g"
            if global.macroSuccessful = false
               echo "nested macro failed"
               M99
            
            curieosundefined 1 Reply Last reply Reply Quote 1
            • curieosundefined
              curieos @OwenD
              last edited by

              @OwenD

              @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.

              She/Her
              I work at a local 3D printing shop.
              Printers: Micron+ w/Duet 3 Mini, in-progress adaptation of the Jubilee REL onto an E3D MS, Prusa i3 MK3S.

              1 Reply Last reply Reply Quote 0
              • kerfunundefined kerfun referenced this topic
              • First post
                Last post
              Unless otherwise noted, all forum content is licensed under CC-BY-SA