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!