What is the correct Mcode to restart a completed print job?



  • Hi guys,

    I've been printing the same plate of mask buckles in production mode over and over with no issues. It would be great if I had a physical push button on the printer to start the last print over again after clearing the bed instead of having to wake the pc from sleep, wait for it to reconnect to the wifi and then click the restart print button in the DWC.

    I understand how to set up physical buttons to run macros, but what is the Mcode to restart a print that completed successfully? (I did look for this but maybe I'm going blind? ...)

    Thanks!

    Steve Graber

    Board: Duet WiFi 1.02 or later
    Firmware: RepRapFirmware for Duet 2 WiFi/Ethernet 2.02(RTOS) (2018-12-24b1)
    Duet WiFi Server Version: 1.23



  • It seems like M24 might be the gcode you're after.

    You may have to send M23 before, to reset the loaded file. You may even have to send M23 <filename> but maybe not. Try simply M24. If that doesn't work, try M23 then M24.



  • @bot Why thank you Bot (not actually a bot)!

    I'll give it a try as soon as the current print is finished

    ✌



  • Unfortunately, M24 and M23 commands both expect a filename to be included with the command. So that's a no-go.

    The 'Start Again' button in the DWC uses M32 command but it too is asking for the filename, and in the DWC the command+filename is written out directly to the html page when it's generated.

    It appears that any macro created to restart a completed job using the M23, 24 or 32 commands would need to have the filename of the currently selected file written to it each time a print was selected. Or maybe the filename would need to be held in memory.

    Unless there is some other option.


  • administrators

    In RRF 3.1 there is a property called job.lastFileName in the object model that holds the name of the last file printed. It will be null if no file has been printed since the last power up or reset.



  • It struck me last night as I was falling asleep that I wasn't seeing the super basic and easy way to accomplish what I want.

    The best overall solution would of course be to set up a dynamic macro to repeat any currently selected print via a physical button. And that would require knowing the current print file name and path which would require upgrading to RRF3.1. That way the button would be maintenance free.

    In my case I'm printing a known file over and over and I don't have time to upgrade right now. So I'll simply hard-code the macro with the filename I want to reprint. If that file ever changes due to versioning, etc. I'll just edit the macro.

    M32 "0:/gcodes/Cerb400_1-1.0mmNozz/PETG/30xMB_V4.0-Plated.gcode"

    When I finalize the physical button housing attached to the printer it will include several other momentary push buttons for preheat, motors off, home and board reset. Maybe I'll include a little clip to hold a post-it with the macro-filename listed on it.



  • @grabercars said in What is the correct Mcode to restart a completed print job?:

    It struck me last night as I was falling asleep that I wasn't seeing the super basic and easy way to accomplish what I want.........................

    ................When I finalize the physical button housing attached to the printer it will include several other momentary push buttons for preheat, motors off, home and board reset. Maybe I'll include a little clip to hold a post-it with the macro-filename listed on it.

    Nice idea. But while we are in "super basic and easy" mode, have you considered using a PanelDue? https://www.duet3d.com/PanelDue

    That would do everything you want and more, without having to write all those other macros or wire any external buttons to pins.



  • @deckingman said in What is the correct Mcode to restart a completed print job?:

    That would do everything you want and more...

    Can you elaborate? Let's say that I sent a file to the duet from my slicer with 'auto start' option. Once the first print is completed, how do I print another one from the PanelDue?



  • @zapta said in What is the correct Mcode to restart a completed print job?:

    @deckingman said in What is the correct Mcode to restart a completed print job?:

    That would do everything you want and more...

    Can you elaborate? Let's say that I sent a file to the duet from my slicer with 'auto start' option. Once the first print is completed, how do I print another one from the PanelDue?

    I was responding to the OP's intention of using a number of buttons to initiate various macros. This isn't about what you would want to do in a hypothetical case, it's about what the OP wants and intends to do. He intends to run a macro to re-print an object by initiating that macro with a physical button wired to an input pin. He could run that macro from the PanelDue.

    His other use cases are quote "When I finalize the physical button housing attached to the printer it will include several other momentary push buttons for preheat, motors off, home and board reset". All of these, he could do with the PanelDue instead of using a number of push buttons.



  • @deckingman said in What is the correct Mcode to restart a completed print job?:

    I was responding to the OP's intention of using a number of buttons to initiate various macros. This isn't about what you would want to do in a hypothetical case, it's about what the OP wants and intends to do.

    Thanks for the clarification. I think that the OP has similar use case to mine. Starting a print from a computer and then having a simple print-again function near the printer. I am not sure that PanelDue has that capability. (There was somewhere else a discussion about not have a fixed gcode sequence that can reprint the last print, otherwise a macro would achieve that).



  • @dc42 said in What is the correct Mcode to restart a completed print job?:

    In RRF 3.1 there is a property called job.lastFileName in the object model that holds the name of the last file printed. It will be null if no file has been printed since the last power up or reset.

    ; todo: detect if job.lastFileName is null
    ; if state.status == "idle" // doesn't work.  state.status returns "busy" while in a macro
    echo "Repeating print of " ^ job.lastFileName
    M23 job.lastFileName         ; select the file to be printed as the filename of the last job
    M24                          ; start printing the selected file
    

    The one thing missing here is a way to detect if the printer is currently doing something else. Obviously, this macro shouldn't run if there's already a print in progress. However, I don't see a good way to detect that. "if state.status == "idle"" doesn't work because "state.status" seems to return "busy" while running a macro.

    That leads to the question of: Is there any way for a macro to detect the state of the printer using the object model?


  • administrators

    @garyd9 It does return 'busy' when a macro is being executed (except when running daemon.g) but it will remain 'processing' while a print is in progress.


Log in to reply