Browse Source

Patch configuration_store for extra serial port

Fix #9948
Scott Lahteine 6 years ago
parent
commit
49ca67202f

+ 17
- 17
Marlin/src/gcode/eeprom/M500-M504.cpp View File

@@ -22,21 +22,24 @@
22 22
 
23 23
 #include "../gcode.h"
24 24
 #include "../../module/configuration_store.h"
25
+#include "../../core/serial.h"
25 26
 #include "../../inc/MarlinConfig.h"
26 27
 
27 28
 #if NUM_SERIAL > 1
28 29
   #include "../../gcode/queue.h"
29 30
 #endif
30 31
 
32
+#if ADD_PORT_ARG
33
+  #define CHAT_PORT command_queue_port[cmd_queue_index_r]
34
+#else
35
+  #define CHAT_PORT
36
+#endif
37
+
31 38
 /**
32 39
  * M500: Store settings in EEPROM
33 40
  */
34 41
 void GcodeSuite::M500() {
35
-  (void)settings.save(
36
-    #if ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1
37
-      command_queue_port[cmd_queue_index_r]
38
-    #endif
39
-  );
42
+  (void)settings.save(CHAT_PORT);
40 43
 }
41 44
 
42 45
 /**
@@ -44,8 +47,8 @@ void GcodeSuite::M500() {
44 47
  */
45 48
 void GcodeSuite::M501() {
46 49
   (void)settings.load(
47
-    #if ENABLED(EEPROM_SETTINGS) && ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1
48
-      command_queue_port[cmd_queue_index_r]
50
+    #if ENABLED(EEPROM_SETTINGS)
51
+      CHAT_PORT
49 52
     #endif
50 53
   );
51 54
 }
@@ -54,11 +57,7 @@ void GcodeSuite::M501() {
54 57
  * M502: Revert to default settings
55 58
  */
56 59
 void GcodeSuite::M502() {
57
-  (void)settings.reset(
58
-    #if ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1
59
-      command_queue_port[cmd_queue_index_r]
60
-    #endif
61
-  );
60
+  (void)settings.reset(CHAT_PORT);
62 61
 }
63 62
 
64 63
 #if DISABLED(DISABLE_M503)
@@ -67,8 +66,9 @@ void GcodeSuite::M502() {
67 66
    * M503: print settings currently in memory
68 67
    */
69 68
   void GcodeSuite::M503() {
70
-    (void)settings.report(parser.seen('S') && !parser.value_bool()
71
-      #if ADD_PORT_ARG
69
+    (void)settings.report(
70
+      parser.seen('S') && !parser.value_bool()
71
+      #if NUM_SERIAL > 1
72 72
         , command_queue_port[cmd_queue_index_r]
73 73
       #endif
74 74
     );
@@ -81,9 +81,9 @@ void GcodeSuite::M502() {
81 81
    * M504: Validate EEPROM Contents
82 82
    */
83 83
   void GcodeSuite::M504() {
84
-    if (settings.validate()) {
85
-      SERIAL_ECHO_START();
86
-      SERIAL_ECHOLNPGM("EEPROM OK");
84
+    if (settings.validate(CHAT_PORT)) {
85
+      SERIAL_ECHO_START_P(command_queue_port[cmd_queue_index_r]);
86
+      SERIAL_ECHOLNPGM_P(command_queue_port[cmd_queue_index_r], "EEPROM OK");
87 87
     }
88 88
   }
89 89
 #endif

+ 6
- 2
Marlin/src/module/configuration_store.cpp View File

@@ -1462,7 +1462,11 @@ void MarlinSettings::postprocess() {
1462 1462
       const int8_t port/*=-1*/
1463 1463
     #endif
1464 1464
   ) {
1465
-    if (validate()) return _load(
1465
+    if (validate(
1466
+      #if ADD_PORT_ARG
1467
+        port
1468
+      #endif
1469
+    )) return _load(
1466 1470
       #if ADD_PORT_ARG
1467 1471
         port
1468 1472
       #endif
@@ -1864,7 +1868,7 @@ void MarlinSettings::reset(
1864 1868
    * Unless specifically disabled, M503 is available even without EEPROM
1865 1869
    */
1866 1870
   void MarlinSettings::report(const bool forReplay
1867
-    #if ADD_PORT_ARG
1871
+    #if NUM_SERIAL > 1
1868 1872
       , const int8_t port/*=-1*/
1869 1873
     #endif
1870 1874
   ) {

+ 1
- 1
Marlin/src/module/configuration_store.h View File

@@ -86,7 +86,7 @@ class MarlinSettings {
86 86
 
87 87
     #if DISABLED(DISABLE_M503)
88 88
       static void report(const bool forReplay=false
89
-        #if ADD_PORT_ARG
89
+        #if NUM_SERIAL > 1
90 90
           , const int8_t port=-1
91 91
         #endif
92 92
       );

Loading…
Cancel
Save