Playing G-code files

The Player module allows you to play files from the SD card.

Files are read one line at a time, and each line is executed as if it had been received from a controlling host.

Mac users beware: it appears that the play function does not accept files that have a space in their name.

Here are all the available options for the Player module

Option Example value Explanation
on_boot_gcode /sd/on_boot.gcode G-code file to play when the board boots. This file will automaticaly be played when the board is done booting up. Useful for example if you want to home your printer when it boots, or do similar tasks.
on_boot_gcode_enable true If set to true, play the on_boot_gcode file when the board boots up
after_suspend_gcode G91_G0E-5_G0Z10_G90_G0X-50Y-50 G-code to execute automatically right after the suspend command is received, this is useful if you want to retract, or turn off heaters etc. The _ character gets converted into space
before_resume_gcode G91_G1E1_G90 G-code to execute automatically right after the resume command is received, but before resuming execution. However NOTE this is generally not needed as the resume will restore the state it was in before the suspend. The _ character gets converted into space
leave_heaters_on_suspend false If set to true, heaters are left ON when suspend is received. If set to false, heaters are turned OFF when suspend is received, and then turned back ON when resume is received.
2017/01/25 14:19 · arthur

Here are all the available commands for the Player module


You can use the play command to execute files stored on the SD card.

You must specify a file name and its path, for example :

play /sd/gcodefile.gcode

By default, the command will be quiet. If you want the command to output every G-code in the file to the serial port ( the command was called from ), add the -v ( verbose ) parameter :

play /sd/gcodefile.gcode -v


Pronterface will ignore commands it does not understand, unless you prefix them with @.

Therefore, send your command as @play /sd/gcodefile.gcode and it will work


Repetier will act kind of mean, and ignore any command it doesn't understand.

Unlike Pronterface it won't give you a method to pass commands anyway.

You can possibly use the M24 G-code instead.


When a file is playing, you can use the progress command to get a report of the current position in the file, and elapsed time.


You can also use the abort command to stop the execution of the file.


Can be used for either sd card playing or when streaming from Pronterface or Octoprint.

Will suspend a print in progress it does the following…

1. send pause to upstream host, or pause if printing from sd
2. wait for empty queue
3. save the current position, extruder position, temperatures - any state that would need to be restored
4. –retract by specified amount either on command line or in config– - not implemened yet
5. turn off heaters. (unless the config has leave_heaters_on_suspend true)
6. optionally run after_suspend gcode (set in config defines gcode to run eg. after_suspend G91G0E20G90)

User may jog or remove and insert filament at this point, extruding or retracting as needed.

This could be triggered by a Switch module to setup a simple out of filament detector.

NOTE Issuing a home after a suspend will cancel the suspend and you will not be able to resume.

NOTE the queue must drain before it will suspend, if you need to have the system suspend quicker the only way to do it is to set the config variable mm_per_line_segment 1 this will mean it will stop within 32mm, but there is a performance penalty for segmenting when you do not need to.

Stopping Smoothie

These are the different ways of stopping Smoothie :
Command G-code Movement Heaters File playing Recoverable Documentation Explanation
abort M26 Stops an SDCARD print immediately Not affected Aborts Position maintained, but file must be restarted Player Stops the execution of a file being played from SDCARD, it will complete the current gcode, but stop immediately after that, the rest of the queued commands are discarded. It attempts to maintain the correct position after the abort.
suspend M600 Stops once queue is empty Turned off if option enabled (default) Paused, can be resumed Yes, with resume or M601, position maintained Player Suspends the execution of a file being played from SDCARD or being streamed from a host (upstream support required currently pronterface and octoprint support it, otherwise host needs to be manually paused), all state is saved and jogging and extruding is allowed. Mainly used for mid print filament change, or filament out detection. M601 resumes the print or the resume command
No command, but there is a configurable «kill» button M112 Stops instantly if kill button pressed, if issued from host has to wait for the receive buffer to have room. Turned off aborted No, position is lost, home will be required supported-g-codes Instantly stops all operations, printer fully halts until M999 is sent. Position is lost.
Sending Control-X to smoothie over the serial port or USB serial port should work at any time even when streaming, does the same as the kill button Turned off aborted No, position is lost, home will be required Instantly stops all operations, printer fully halts until M999 is sent (or $X). Position is lost.

If the kill button is pressed (or there is a temperature fault, M112 is issued, a limit switch is hit or other error) the system enters the Halt state, in this state the play led flashes, and the state can be cleared by issuing M999 or holding the flashing kill button for 2 seconds (it can also be cleared from the LCD panel). While in the Halt state any command issued from the host will get a !! response (with a few exceptions). The PSU may be turned off when Halt is entered if there is a psu Switch defined.

All commands can be triggered by a button or a sensor if a Switch module is configured to do so.

2017/01/25 14:20 · arthur


Will resume a suspended print it does the following…

1. restore the temperatures and wait for them to get up to temp
2. optionally run before_resume gcode if specified
3. restore the position it was at and E and any other saved state
4. resume sd print or send resume upstream

The following G-codes are supported by the Player module :

  • M21 : Initialize the SD card. This does nothing in Smoothie but is kept for compatibility
  • M23 : Select a file, for example : M23 file.gcode
  • M24 : Start or resume SD card print
  • M25 : Pause SD card print
  • M26 : Abort a SD card print
  • M27 : Report print progress
  • M32 : Select a file, and start playing it, for example : M32 file.gcode
  • M600 : Suspend print in progress (use console command resume or M601 to continue)
  • M601 : Resume print after suspend