M20
Back to the Gcode Dictionary
M20: List SD card
Parameters
- This command can be used without any additional parameters.
- Snnn Output style: 0 = text (default), 2 = JSON
- P"path" Folder to list, defaults to the standard folder for GCode files (0:/gcodes in RepRapFirmware)
- Rnnn Number of files to skip, default 0
Examples
- M20 ; lists all files in the root folder of the internal SD card
- M20 S2 P"/gcodes/subdir" ; lists all files in the gcodes/subdir folder of the internal SD card, using JSON format
- M20 P"1:/" ; lists all files on the secondary (PanelDue) SD card's root
If Marlin compatibility is enabled, a file list response is encapsulated:
Begin file list: Traffic cone.g frog.gcode calibration piece.g End file list ok
If RepRapFirmware emulates no firmware compatibility, a typical response looks like:
GCode files: "Traffic cone.g","frog.gcode","calibration piece.g"
RepRapFirmware always returns long filenames in the case in which they are stored.
If the S2 parameter is used then the file list is returned in JSON format as a single array called "files" with each name that corresponds to a subdirectory preceded by an asterisk, and the directory is returned in variable "dir". Example:
M20 S2 P"/gcodes" {"dir":"/gcodes","first":0,"next":0,"files":["4-piece-1-2-3-4.gcode","Hinged_Box.gcode","Hollow_Dodecahedron_190.gcode","*Calibration pieces"]}
Returned value "first" is the number of files that were skipped (as specified in the R parameter), and "next" is the number to skip next time to retrieve the next block of filenames. If "next" is zero then there are no more filenames.
0 Comments