Bläddra i källkod

No 'ls' if media isn't mounted

Scott Lahteine 4 år sedan
förälder
incheckning
14314b68ec
3 ändrade filer med 12 tillägg och 5 borttagningar
  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 Visa fil

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

+ 7
- 3
Marlin/src/gcode/sd/M20.cpp Visa fil

@@ -31,9 +31,13 @@
31 31
  * M20: List SD card to serial output
32 32
  */
33 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 43
 #endif // SDSUPPORT

+ 4
- 2
Marlin/src/sd/cardreader.cpp Visa fil

@@ -276,8 +276,10 @@ void CardReader::printListing(SdFile parent, const char * const prepend/*=nullpt
276 276
 // List all files on the SD card
277 277
 //
278 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 285
 #if ENABLED(LONG_FILENAME_HOST_SUPPORT)

Laddar…
Avbryt
Spara