1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-29 09:10:03 +02:00

Fix sd code not disabled when SD Card feature is disabled

This commit is contained in:
Luc
2021-03-04 13:47:11 +01:00
parent 28592a3ed1
commit 58deae5450
4 changed files with 39 additions and 2 deletions

View File

@@ -291,10 +291,14 @@ std::map<Message, const char*> MessageText = {
// NOTE: For interfaces, messages are always placed within brackets. And if silent mode
// is installed, the message number codes are less than zero.
void report_feedback_message(Message message) { // ok to send to all clients
#if defined (ENABLE_SD_CARD)
if (message == Message::SdFileQuit) {
grbl_notifyf("SD print canceled", "Reset during SD file at line: %d", sd_get_current_line_number());
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Reset during SD file at line: %d", sd_get_current_line_number());
} else {
} else
#endif //ENABLE_SD_CARD
{
auto it = MessageText.find(message);
if (it != MessageText.end()) {
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, it->second);

View File

@@ -18,6 +18,8 @@
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Config.h"
#ifdef ENABLE_SD_CARD
#include "SDCard.h"
File myFile;
@@ -169,3 +171,4 @@ void sd_get_current_filename(char* name) {
name[0] = 0;
}
}
#endif //ENABLE_SD_CARD

View File

@@ -159,16 +159,20 @@ void serialCheckTask(void* pvParameters) {
if (is_realtime_command(data)) {
execute_realtime_command(static_cast<Cmd>(data), client);
} else {
#if defined(ENABLE_SD_CARD)
if (get_sd_state(false) < SDState::Busy) {
#endif //ENABLE_SD_CARD
vTaskEnterCritical(&myMutex);
client_buffer[client].write(data);
vTaskExitCritical(&myMutex);
#if defined(ENABLE_SD_CARD)
} else {
if (data == '\r' || data == '\n') {
grbl_sendf(client, "error %d\r\n", Error::AnotherInterfaceBusy);
grbl_msg_sendf(client, MsgLevel::Info, "SD card job running");
}
}
#endif //ENABLE_SD_CARD
}
} // if something available
WebUI::COMMANDS::handle();

View File

@@ -806,9 +806,35 @@ namespace WebUI {
}
#endif
void listDirLocalFS(fs::FS& fs, const char* dirname, uint8_t levels, uint8_t client) {
//char temp_filename[128]; // to help filter by extension TODO: 128 needs a definition based on something
File root = fs.open(dirname);
if (!root) {
//FIXME: need proper error for FS and not usd sd one
report_status_message(Error::SdFailedOpenDir, client);
return;
}
if (!root.isDirectory()) {
//FIXME: need proper error for FS and not usd sd one
report_status_message(Error::SdDirNotFound, client);
return;
}
File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
if (levels) {
listDirLocalFS(fs, file.name(), levels - 1, client);
}
} else {
grbl_sendf(CLIENT_ALL, "[FILE:%s|SIZE:%d]\r\n", file.name(), file.size());
}
file = root.openNextFile();
}
}
static Error listLocalFiles(char* parameter, AuthenticationLevel auth_level) { // No ESP command
webPrintln("");
listDir(SPIFFS, "/", 10, espresponse->client());
listDirLocalFS(SPIFFS, "/", 10, espresponse->client());
String ssd = "[Local FS Free:" + ESPResponseStream::formatBytes(SPIFFS.totalBytes() - SPIFFS.usedBytes());
ssd += " Used:" + ESPResponseStream::formatBytes(SPIFFS.usedBytes());
ssd += " Total:" + ESPResponseStream::formatBytes(SPIFFS.totalBytes());