Browse Source

Patch configuration_store for extra serial port

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

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

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

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

1462
       const int8_t port/*=-1*/
1462
       const int8_t port/*=-1*/
1463
     #endif
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
       #if ADD_PORT_ARG
1470
       #if ADD_PORT_ARG
1467
         port
1471
         port
1468
       #endif
1472
       #endif
1864
    * Unless specifically disabled, M503 is available even without EEPROM
1868
    * Unless specifically disabled, M503 is available even without EEPROM
1865
    */
1869
    */
1866
   void MarlinSettings::report(const bool forReplay
1870
   void MarlinSettings::report(const bool forReplay
1867
-    #if ADD_PORT_ARG
1871
+    #if NUM_SERIAL > 1
1868
       , const int8_t port/*=-1*/
1872
       , const int8_t port/*=-1*/
1869
     #endif
1873
     #endif
1870
   ) {
1874
   ) {

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

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

Loading…
Cancel
Save