From 8ae9261c1e16d2b19b6897dc23ca0d328437fd1d Mon Sep 17 00:00:00 2001 From: Luc Date: Thu, 29 Aug 2019 18:11:38 +0200 Subject: [PATCH] fix typo --- Grbl_Esp32/commands.cpp | 43 +++++++++++++++++++++++++++++++++++++++++ Grbl_Esp32/system.cpp | 4 ++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Grbl_Esp32/commands.cpp b/Grbl_Esp32/commands.cpp index 1c7dff63..774f5f10 100644 --- a/Grbl_Esp32/commands.cpp +++ b/Grbl_Esp32/commands.cpp @@ -881,6 +881,49 @@ bool COMMANDS::execute_internal_command (int cmd, String cmd_params, level_authe } break; + //Delete SD Card file / directory + //[ESP215] + case 215: + { + if (!espresponse) return false; +#ifdef ENABLE_AUTHENTICATION + if (auth_type == LEVEL_GUEST) { + espresponse->println ("Error: Wrong authentication!"); + return false; + + } +#endif + parameter = get_param (cmd_params, "", true); + if (parameter.length() != 0) { + int8_t state = get_sd_state(true); + if (state == SDCARD_IDLE) { + File file2del = SD.open(cmd_params.c_str()); + if (file2del) { + if (file2del.isDirectory()) { + if (!SD.rmdir((char *)cmd_params.c_str())) { + espresponse->println ("Error: Cannot delete directory! Is directory empty?"); + } else { + espresponse->println ("Directory deleted."); + } + } else { + if (!SD.remove((char *)cmd_params.c_str())) { + espresponse->println ("Error: Cannot delete file!"); + } else { + espresponse->println ("File deleted."); + } + } + } else { + espresponse->println ("Error: Cannot stat file!"); + } + file2del.close(); + } else { + espresponse->println ((state == SDCARD_NOT_PRESENT) ? "No SD card" : "Busy"); + } + } else { + espresponse->println ("Error: Missing file name!"); + } + } + break; //print SD file //[ESP220] case 220: diff --git a/Grbl_Esp32/system.cpp b/Grbl_Esp32/system.cpp index a2ce3245..5666c284 100644 --- a/Grbl_Esp32/system.cpp +++ b/Grbl_Esp32/system.cpp @@ -45,8 +45,8 @@ void system_ini() // Renamed from system_init() due to conflict with esp32 files #endif //customize pin definition if needed -#if (GRBL_SPI_SS != -1) || (GRBL_SPI_MIS0 != -1) || (GRBL_SPI_MOSI != -1) || (GRBL_SPI_SCK != -1) - SPI.begin(GRBL_SPI_SCK, GRBL_SPI_MIS0, GRBL_SPI_MOSI, GRBL_SPI_SS); +#if (GRBL_SPI_SS != -1) || (GRBL_SPI_MISO != -1) || (GRBL_SPI_MOSI != -1) || (GRBL_SPI_SCK != -1) + SPI.begin(GRBL_SPI_SCK, GRBL_SPI_MISO, GRBL_SPI_MOSI, GRBL_SPI_SS); #endif }