From 49ca67202f87dc90e296f0e4dc5fb4caecc61214 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 9 Mar 2018 07:42:27 -0600 Subject: [PATCH] Patch configuration_store for extra serial port Fix #9948 --- Marlin/src/gcode/eeprom/M500-M504.cpp | 34 +++++++++++------------ Marlin/src/module/configuration_store.cpp | 8 ++++-- Marlin/src/module/configuration_store.h | 2 +- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Marlin/src/gcode/eeprom/M500-M504.cpp b/Marlin/src/gcode/eeprom/M500-M504.cpp index 2f78526960..8c5e3af9df 100644 --- a/Marlin/src/gcode/eeprom/M500-M504.cpp +++ b/Marlin/src/gcode/eeprom/M500-M504.cpp @@ -22,21 +22,24 @@ #include "../gcode.h" #include "../../module/configuration_store.h" +#include "../../core/serial.h" #include "../../inc/MarlinConfig.h" #if NUM_SERIAL > 1 #include "../../gcode/queue.h" #endif +#if ADD_PORT_ARG + #define CHAT_PORT command_queue_port[cmd_queue_index_r] +#else + #define CHAT_PORT +#endif + /** * M500: Store settings in EEPROM */ void GcodeSuite::M500() { - (void)settings.save( - #if ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1 - command_queue_port[cmd_queue_index_r] - #endif - ); + (void)settings.save(CHAT_PORT); } /** @@ -44,8 +47,8 @@ void GcodeSuite::M500() { */ void GcodeSuite::M501() { (void)settings.load( - #if ENABLED(EEPROM_SETTINGS) && ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1 - command_queue_port[cmd_queue_index_r] + #if ENABLED(EEPROM_SETTINGS) + CHAT_PORT #endif ); } @@ -54,11 +57,7 @@ void GcodeSuite::M501() { * M502: Revert to default settings */ void GcodeSuite::M502() { - (void)settings.reset( - #if ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1 - command_queue_port[cmd_queue_index_r] - #endif - ); + (void)settings.reset(CHAT_PORT); } #if DISABLED(DISABLE_M503) @@ -67,8 +66,9 @@ void GcodeSuite::M502() { * M503: print settings currently in memory */ void GcodeSuite::M503() { - (void)settings.report(parser.seen('S') && !parser.value_bool() - #if ADD_PORT_ARG + (void)settings.report( + parser.seen('S') && !parser.value_bool() + #if NUM_SERIAL > 1 , command_queue_port[cmd_queue_index_r] #endif ); @@ -81,9 +81,9 @@ void GcodeSuite::M502() { * M504: Validate EEPROM Contents */ void GcodeSuite::M504() { - if (settings.validate()) { - SERIAL_ECHO_START(); - SERIAL_ECHOLNPGM("EEPROM OK"); + if (settings.validate(CHAT_PORT)) { + SERIAL_ECHO_START_P(command_queue_port[cmd_queue_index_r]); + SERIAL_ECHOLNPGM_P(command_queue_port[cmd_queue_index_r], "EEPROM OK"); } } #endif diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index 6f395c262f..197d9ad141 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -1462,7 +1462,11 @@ void MarlinSettings::postprocess() { const int8_t port/*=-1*/ #endif ) { - if (validate()) return _load( + if (validate( + #if ADD_PORT_ARG + port + #endif + )) return _load( #if ADD_PORT_ARG port #endif @@ -1864,7 +1868,7 @@ void MarlinSettings::reset( * Unless specifically disabled, M503 is available even without EEPROM */ void MarlinSettings::report(const bool forReplay - #if ADD_PORT_ARG + #if NUM_SERIAL > 1 , const int8_t port/*=-1*/ #endif ) { diff --git a/Marlin/src/module/configuration_store.h b/Marlin/src/module/configuration_store.h index 572dded84a..3352ce726f 100644 --- a/Marlin/src/module/configuration_store.h +++ b/Marlin/src/module/configuration_store.h @@ -86,7 +86,7 @@ class MarlinSettings { #if DISABLED(DISABLE_M503) static void report(const bool forReplay=false - #if ADD_PORT_ARG + #if NUM_SERIAL > 1 , const int8_t port=-1 #endif );