Browse Source

No 'ls' if media isn't mounted

Scott Lahteine 4 years ago
parent
commit
14314b68ec
3 changed files with 12 additions and 5 deletions
  1. 1
    0
      Marlin/src/core/language.h
  2. 7
    3
      Marlin/src/gcode/sd/M20.cpp
  3. 4
    2
      Marlin/src/sd/cardreader.cpp

+ 1
- 0
Marlin/src/core/language.h View File

120
 #define STR_ERR_CHECKSUM_MISMATCH           "checksum mismatch, Last Line: "
120
 #define STR_ERR_CHECKSUM_MISMATCH           "checksum mismatch, Last Line: "
121
 #define STR_ERR_NO_CHECKSUM                 "No Checksum with line number, Last Line: "
121
 #define STR_ERR_NO_CHECKSUM                 "No Checksum with line number, Last Line: "
122
 #define STR_FILE_PRINTED                    "Done printing file"
122
 #define STR_FILE_PRINTED                    "Done printing file"
123
+#define STR_NO_MEDIA                        "No media"
123
 #define STR_BEGIN_FILE_LIST                 "Begin file list"
124
 #define STR_BEGIN_FILE_LIST                 "Begin file list"
124
 #define STR_END_FILE_LIST                   "End file list"
125
 #define STR_END_FILE_LIST                   "End file list"
125
 #define STR_INVALID_EXTRUDER                "Invalid extruder"
126
 #define STR_INVALID_EXTRUDER                "Invalid extruder"

+ 7
- 3
Marlin/src/gcode/sd/M20.cpp View File

31
  * M20: List SD card to serial output
31
  * M20: List SD card to serial output
32
  */
32
  */
33
 void GcodeSuite::M20() {
33
 void GcodeSuite::M20() {
34
-  SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST);
35
-  card.ls();
36
-  SERIAL_ECHOLNPGM(STR_END_FILE_LIST);
34
+  if (card.flag.mounted) {
35
+    SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST);
36
+    card.ls();
37
+    SERIAL_ECHOLNPGM(STR_END_FILE_LIST);
38
+  }
39
+  else
40
+    SERIAL_ECHO_MSG(STR_NO_MEDIA);
37
 }
41
 }
38
 
42
 
39
 #endif // SDSUPPORT
43
 #endif // SDSUPPORT

+ 4
- 2
Marlin/src/sd/cardreader.cpp View File

276
 // List all files on the SD card
276
 // List all files on the SD card
277
 //
277
 //
278
 void CardReader::ls() {
278
 void CardReader::ls() {
279
-  root.rewind();
280
-  printListing(root);
279
+  if (flag.mounted) {
280
+    root.rewind();
281
+    printListing(root);
282
+  }
281
 }
283
 }
282
 
284
 
283
 #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
285
 #if ENABLED(LONG_FILENAME_HOST_SUPPORT)

Loading…
Cancel
Save