How to trigger M112 when M400 was sended
-
Hello,
My Duet: Duet 3 MB6HC v1.01 Firmware 3.4.1
I send Gcode via USB.
When I send G1, I immediately call M's own command to send a status message. The macro contains the M400 command to wait for the end of the movement and then read the position data from the object model.If I call that macro nothing happens when I send M112 (Emergency Stop) but it waits for the end of the turn because there is M400 and then M112.
But if I press emergency stop in Duet Web Control, the response is immediate even though the M400 is there.One more point of interest. Previously, if I remember correctly, when sending a G1 command, the duet only sent an "ok" message after the move was complete. It will now immediately send an "ok" message even if the move is not yet complete. I don't know if I remember it wrong or if I changed something. Is it possible to change this response behavior to the G1 command?
And is there a way to run the M112 even though there is an M400? If Duet Web Control can do it, can't it also be done via USB?
Thank you very much
EDIT:
The problem was solved when I send the M400 through the daemon.g file. I created a loop that sends my M command with the M400 during the "busy" status. When the movement is finished, an echo with the status is sent. And during this movement, it responds immediately to the M112 (Emergency stop) command.
I also created a global variable to stop the infinite loop in daemon.g
I am also attaching the code as a sample in case someone has a similar problem. But if you have ideas for better solutions, I welcome them.
Daemon.g
while global.StatusLoop while state.status = "busy" M16 G4 P100;
M16.g macro
; Send status report M400 ; Wait until moves ends ; States var R = state.gpOut[4].pwm ; Red Lamp var O = state.gpOut[5].pwm ; Yellow Lamp var G = state.gpOut[6].pwm ; Greeen Lamp var B = state.gpOut[7].pwm ; Backlight var X = move.axes[0].machinePosition ; X position var Y = move.axes[1].machinePosition ; Y position var Z = move.axes[2].machinePosition ; Z position var A = move.axes[3].machinePosition ; A position var V = sensors.gpIn[2].value ; VaccumLost status var S = sensors.gpIn[1].value ; SafetyDoor status echo "Report: X:" ^ var.X ^ " Y:" ^ var.Y ^ " Z:" ^ var.Z ^ " A:" ^ var.A ^ " Vac:" ^ var.V ^ " BL:" ^ var.B ^ " RL:" ^ var.R ^ " YL:" ^ var.O ^ " GL:" ^ var.G ^ " SD:" ^ var.S ^ ""