No 'ls' if media isn't mounted
This commit is contained in:
		@@ -120,6 +120,7 @@
 | 
				
			|||||||
#define STR_ERR_CHECKSUM_MISMATCH           "checksum mismatch, Last Line: "
 | 
					#define STR_ERR_CHECKSUM_MISMATCH           "checksum mismatch, Last Line: "
 | 
				
			||||||
#define STR_ERR_NO_CHECKSUM                 "No Checksum with line number, Last Line: "
 | 
					#define STR_ERR_NO_CHECKSUM                 "No Checksum with line number, Last Line: "
 | 
				
			||||||
#define STR_FILE_PRINTED                    "Done printing file"
 | 
					#define STR_FILE_PRINTED                    "Done printing file"
 | 
				
			||||||
 | 
					#define STR_NO_MEDIA                        "No media"
 | 
				
			||||||
#define STR_BEGIN_FILE_LIST                 "Begin file list"
 | 
					#define STR_BEGIN_FILE_LIST                 "Begin file list"
 | 
				
			||||||
#define STR_END_FILE_LIST                   "End file list"
 | 
					#define STR_END_FILE_LIST                   "End file list"
 | 
				
			||||||
#define STR_INVALID_EXTRUDER                "Invalid extruder"
 | 
					#define STR_INVALID_EXTRUDER                "Invalid extruder"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,9 +31,13 @@
 | 
				
			|||||||
 * M20: List SD card to serial output
 | 
					 * M20: List SD card to serial output
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void GcodeSuite::M20() {
 | 
					void GcodeSuite::M20() {
 | 
				
			||||||
 | 
					  if (card.flag.mounted) {
 | 
				
			||||||
    SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST);
 | 
					    SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST);
 | 
				
			||||||
    card.ls();
 | 
					    card.ls();
 | 
				
			||||||
    SERIAL_ECHOLNPGM(STR_END_FILE_LIST);
 | 
					    SERIAL_ECHOLNPGM(STR_END_FILE_LIST);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    SERIAL_ECHO_MSG(STR_NO_MEDIA);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // SDSUPPORT
 | 
					#endif // SDSUPPORT
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -276,9 +276,11 @@ void CardReader::printListing(SdFile parent, const char * const prepend/*=nullpt
 | 
				
			|||||||
// List all files on the SD card
 | 
					// List all files on the SD card
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
void CardReader::ls() {
 | 
					void CardReader::ls() {
 | 
				
			||||||
 | 
					  if (flag.mounted) {
 | 
				
			||||||
    root.rewind();
 | 
					    root.rewind();
 | 
				
			||||||
    printListing(root);
 | 
					    printListing(root);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
 | 
					#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user