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

Cannot call Macro containing custom m-code before custom m-code

Scheduled Pinned Locked Moved
Gcode meta commands
3
5
240
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.
  • undefined
    rymnd
    last edited by 29 Jul 2023, 01:14

    Apologies in advance if I've been missing something obvious, but I've been having problems getting custom m-codes working the way I'd like on the Duet 3, RRF ver 3.4.5

    I've found that if I call a macro containing a custom m-code with M98 right before calling another custom m-code, the RPi-side code will freeze, and I can only continue after hitting the GUI's emergency stop button to restart the Duet. I'm able to get around this issue by removing the flush command, but then the custom m-code after the macro completes before the custom m-code within the macro. My test code is based almost entirely on the custom m-code example from the dsf-python repository:

    dsf_server.py:

    from dsf.connections import InterceptConnection,InterceptionMode,CommandConnection
    from dsf.commands.code import CodeType
    from dsf.object_model import MessageType
    import time
    if __name__=="__main__":
    filters = ["M1234","M1111"]
    intercept_connection = InterceptConnection(InterceptionMode.POST,filters=filters,debug=True)
    intercept_connection.connect()
    print("Connected and listening...")
    try:
    while True:
    cde = intercept_connection.receive_code()
    cde_str = str(cde.type)+str(cde.majorNumber)
    if cde_str in filters:
    intercept_connection.flush(cde.channel)
    print(cde_str)
    if cde.type==CodeType.MCode and cde.majorNumber==1234:
    #report time of execution
    time_executed = round(time.time(),2)
    msg_type = MessageType.Success
    msg = "Time completed: {}".format(time_executed)
    intercept_connection.resolve_code(msg_type,msg)
    elif cde.type==CodeType.MCode and cde.majorNumber==1111:
    #blank, filler m-code to fill the m queue
    intercept_connection.resolve_code()
    except Exception as e:
    print("Error")
    intercept_connection.close()

    Test gcode that fails:

    M98 P"/tests/Wrapper"
    M1234

    Wrapper macro file:

    M1111
    

    Can we just not put custom m-code calls inside of macros that are used in other macros or gcode files? Or has anyone else run into any similar issues? Thanks so much for your time!

    undefined 1 Reply Last reply 31 Jul 2023, 09:33 Reply Quote 0
    • undefined
      Phaedrux Moderator
      last edited by 30 Jul 2023, 16:56

      Have you tested on 3.5 beta yet?

      Z-Bot CoreXY Build | Thingiverse Profile

      1 Reply Last reply Reply Quote 0
      • undefined
        chrishamm administrators @rymnd
        last edited by 31 Jul 2023, 09:33

        @rymnd Thanks for reporting this problem, I could reproduce it. You have two options to work-around this problem:

        1. Change your G-code to
        M98 P"/tests/Wrapper"
        if true
        M1234

        This ensures that M1234 is not sent to your script before M98 completes.

        1. Use separate scripts/connections for M1111/M1234

        The reason for this problem is that M1234 waits for all other codes to complete while it is waiting for the following M1111 to be handled by that very same script as well, which results in a deadlock. I'm going to add better error handling to the next DSF version and add a new option to the interceptor API to automatically flush the code channel internally (if desired) to avoid this problem altogether.

        Duet software engineer

        undefined 1 Reply Last reply 31 Jul 2023, 18:09 Reply Quote 1
        • undefined
          rymnd @chrishamm
          last edited by 31 Jul 2023, 18:09

          @chrishamm Thanks so much for the fast reply! Regarding your #2 on separate scripts, you're referring to the dsf python code on the RPi side that intercepts the custom m-codes, correct?

          I've also found that if both custom m-codes are wrapped in their own macro files and called via M98 on the same level, that works too

          undefined 1 Reply Last reply 1 Aug 2023, 12:25 Reply Quote 0
          • undefined
            chrishamm administrators @rymnd
            last edited by 1 Aug 2023, 12:25

            @rymnd Yes, that's right. I've got the corresponding changes ready for 3.5.0-rc.1 and potentially 3.4.7.

            Duet software engineer

            1 Reply Last reply Reply Quote 0
            2 out of 5
            • First post
              2/5
              Last post
            Unless otherwise noted, all forum content is licensed under CC-BY-SA