Selaa lähdekoodia

Simplify serial port redirect (#13234)

Scott Lahteine 6 vuotta sitten
vanhempi
commit
e15354e387
No account linked to committer's email address

+ 8
- 2
Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp Näytä tiedosto

65
     return CTRL_NO_PRESENT;
65
     return CTRL_NO_PRESENT;
66
 
66
 
67
   #ifdef DEBUG_MMC
67
   #ifdef DEBUG_MMC
68
+  {
68
     char buffer[80];
69
     char buffer[80];
69
     sprintf_P(buffer, PSTR("SDRD: %d @ 0x%08x\n"), nb_sector, addr);
70
     sprintf_P(buffer, PSTR("SDRD: %d @ 0x%08x\n"), nb_sector, addr);
70
-    SERIAL_ECHO_P(0, buffer);
71
+    PORT_REDIRECT(0);
72
+    SERIAL_ECHO(buffer);
73
+  }
71
   #endif
74
   #endif
72
 
75
 
73
   // Start reading
76
   // Start reading
99
     return CTRL_NO_PRESENT;
102
     return CTRL_NO_PRESENT;
100
 
103
 
101
   #ifdef DEBUG_MMC
104
   #ifdef DEBUG_MMC
105
+  {
102
     char buffer[80];
106
     char buffer[80];
103
     sprintf_P(buffer, PSTR("SDWR: %d @ 0x%08x\n"), nb_sector, addr);
107
     sprintf_P(buffer, PSTR("SDWR: %d @ 0x%08x\n"), nb_sector, addr);
104
-    SERIAL_ECHO_P(0, buffer);
108
+    PORT_REDIRECT(0);
109
+    SERIAL_ECHO(buffer);
110
+  }
105
   #endif
111
   #endif
106
 
112
 
107
   if (!card.getSd2Card().writeStart(addr, nb_sector))
113
   if (!card.getSd2Card().writeStart(addr, nb_sector))

+ 2
- 20
Marlin/src/core/serial.cpp Näytä tiedosto

29
 static const char echomagic[]  PROGMEM = "echo:";
29
 static const char echomagic[]  PROGMEM = "echo:";
30
 
30
 
31
 #if NUM_SERIAL > 1
31
 #if NUM_SERIAL > 1
32
-  void serialprintPGM_P(const int8_t p, const char * str) {
33
-    while (char ch = pgm_read_byte(str++)) SERIAL_CHAR_P(p, ch);
34
-  }
35
-
36
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, const char *v)   { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); }
37
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, char v)          { serialprintPGM_P(p, s_P); SERIAL_CHAR_P(p, v); }
38
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, int v)           { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); }
39
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, long v)          { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); }
40
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, float v)         { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); }
41
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, double v)        { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); }
42
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, unsigned int v)  { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); }
43
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, unsigned long v) { serialprintPGM_P(p, s_P); SERIAL_ECHO_P(p, v); }
44
-
45
-  void serial_spaces_P(const int8_t p, uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR_P(p, ' '); }
46
-
47
-  void serial_echo_start_P(const int8_t p)  { serialprintPGM_P(p, echomagic); }
48
-  void serial_error_start_P(const int8_t p) { serialprintPGM_P(p, errormagic); }
49
-
32
+  int8_t serial_port_index = SERIAL_PORT;
50
 #endif
33
 #endif
51
 
34
 
52
 void serialprintPGM(PGM_P str) {
35
 void serialprintPGM(PGM_P str) {
53
-  while (char ch = pgm_read_byte(str++)) SERIAL_CHAR(ch);
36
+  while (const char c = pgm_read_byte(str++)) SERIAL_CHAR(c);
54
 }
37
 }
55
-
56
 void serial_echo_start()  { serialprintPGM(echomagic); }
38
 void serial_echo_start()  { serialprintPGM(echomagic); }
57
 void serial_error_start() { serialprintPGM(errormagic); }
39
 void serial_error_start() { serialprintPGM(errormagic); }
58
 
40
 

+ 29
- 121
Marlin/src/core/serial.h Näytä tiedosto

43
 #define DEBUGGING(F) (marlin_debug_flags & (MARLIN_DEBUG_## F))
43
 #define DEBUGGING(F) (marlin_debug_flags & (MARLIN_DEBUG_## F))
44
 
44
 
45
 #if TX_BUFFER_SIZE < 1
45
 #if TX_BUFFER_SIZE < 1
46
-  #define SERIAL_FLUSHTX_P(p)
47
   #define SERIAL_FLUSHTX()
46
   #define SERIAL_FLUSHTX()
48
 #endif
47
 #endif
49
 
48
 
50
 #if NUM_SERIAL > 1
49
 #if NUM_SERIAL > 1
50
+  extern int8_t serial_port_index;
51
+  #define _PORT_REDIRECT(n,p)   REMEMBER(n,serial_port_index,p)
52
+  #define _PORT_RESTORE(n)      RESTORE(n)
53
+  #define SERIAL_BOTH 0x7F
54
+  #define SERIAL_OUT(WHAT, ...) do{ \
55
+    if (!serial_port_index || serial_port_index == SERIAL_BOTH) MYSERIAL0.WHAT(##__VA_ARGS__); \
56
+    if ( serial_port_index) MYSERIAL1.WHAT(##__VA_ARGS__); \
57
+  }while(0)
58
+#else
59
+  #define _PORT_REDIRECT(n,p)   NOOP
60
+  #define _PORT_RESTORE(n)      NOOP
61
+  #define SERIAL_OUT(WHAT, ...) MYSERIAL0.WHAT(__VA_ARGS__)
62
+#endif
51
 
63
 
52
-  //
53
-  // Serial out to all ports
54
-  //
55
-  #define SERIAL_CHAR(x)                    (MYSERIAL0.write(x), MYSERIAL1.write(x))
56
-  #define SERIAL_ECHO(x)                    (MYSERIAL0.print(x), MYSERIAL1.print(x))
57
-  #define SERIAL_ECHO_F(x,y)                (MYSERIAL0.print(x,y), MYSERIAL1.print(x,y))
58
-  #define SERIAL_ECHOLN(x)                  (MYSERIAL0.println(x), MYSERIAL1.println(x))
59
-  #define SERIAL_PRINT(x,b)                 (MYSERIAL0.print(x,b), MYSERIAL1.print(x,b))
60
-  #define SERIAL_PRINTLN(x,b)               (MYSERIAL0.println(x,b), MYSERIAL1.println(x,b))
61
-  #define SERIAL_PRINTF(args...)            (MYSERIAL0.printf(args), MYSERIAL1.printf(args))
62
-  #define SERIAL_FLUSH()                    (MYSERIAL0.flush(), MYSERIAL1.flush())
63
-  #if TX_BUFFER_SIZE > 0
64
-    #define SERIAL_FLUSHTX()                (MYSERIAL0.flushTX(), MYSERIAL1.flushTX())
65
-  #endif
66
-
67
-  //
68
-  // Serial out with port redirect
69
-  //
70
-  #define SERIAL_CHAR_P(p,x)                (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.write(x) : MYSERIAL1.write(x)) : SERIAL_CHAR(x))
71
-  #define SERIAL_ECHO_P(p,x)                (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.print(x) : MYSERIAL1.print(x)) : SERIAL_ECHO(x))
72
-  #define SERIAL_ECHO_F_P(p,x,y)            (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.print(x,y) : MYSERIAL1.print(x,y)) : SERIAL_ECHO_F(x,y))
73
-  #define SERIAL_ECHOLN_P(p,x)              (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.println(x) : MYSERIAL1.println(x)) : SERIAL_ECHOLN(x))
74
-  #define SERIAL_PRINT_P(p,x,b)             (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.print(x,b) : MYSERIAL1.print(x,b)) : SERIAL_PRINT(x,b))
75
-  #define SERIAL_PRINTLN_P(p,x,b)           (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.println(x,b) : MYSERIAL1.println(x,b)) : SERIAL_PRINTLN(x,b))
76
-  #define SERIAL_PRINTF_P(p,args...)        (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.printf(args) : MYSERIAL1.printf(args)) : SERIAL_PRINTF(args))
77
-  #define SERIAL_FLUSH_P(p)                 (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.flush() : MYSERIAL1.flush()) : SERIAL_FLUSH())
78
-  #if TX_BUFFER_SIZE > 0
79
-    #define SERIAL_FLUSHTX_P(p)             (WITHIN(p, 0, NUM_SERIAL-1) ? (p == 0 ? MYSERIAL0.flushTX() : MYSERIAL1.flushTX()) : SERIAL_FLUSHTX())
80
-  #endif
81
-
82
-  #define SERIAL_ECHOPGM_P(p,x)             (serialprintPGM_P(p,PSTR(x)))
83
-  #define SERIAL_ECHOLNPGM_P(p,x)           (serialprintPGM_P(p,PSTR(x "\n")))
84
-  #define SERIAL_ECHOPAIR_P(p, pre, value)  (serial_echopair_PGM_P(p,PSTR(pre),(value)))
85
-
86
-  #define SERIAL_ECHO_START_P(p)            serial_echo_start_P(p)
87
-  #define SERIAL_ERROR_START_P(p)           serial_error_start_P(p)
88
-  #define SERIAL_EOL_P(p)                   SERIAL_CHAR_P(p,'\n')
89
-
90
-  #define SERIAL_ECHOPAIR_F_P(p, pre, value, y)   do{ SERIAL_ECHO_P(p, pre); SERIAL_ECHO_F_P(p, value, y); }while(0)
91
-  #define SERIAL_ECHOLNPAIR_F_P(p, pre, value, y) do{ SERIAL_ECHOPAIR_F_P(p, pre, value, y); SERIAL_EOL_P(p); }while(0)
92
-
93
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, const char *v);
94
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, char v);
95
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, int v);
96
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, long v);
97
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, float v);
98
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, double v);
99
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, unsigned int v);
100
-  void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, unsigned long v);
101
-  inline void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, uint8_t v) { serial_echopair_PGM_P(p, s_P, (int)v); }
102
-  inline void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, bool v)    { serial_echopair_PGM_P(p, s_P, (int)v); }
103
-  inline void serial_echopair_PGM_P(const int8_t p, PGM_P const s_P, void *v)   { serial_echopair_PGM_P(p, s_P, (unsigned long)v); }
104
-
105
-  void serial_spaces_P(const int8_t p, uint8_t count);
106
-  #define SERIAL_ECHO_SP_P(p,C)             serial_spaces_P(p,C)
107
-
108
-  void serialprintPGM_P(const int8_t p, PGM_P str);
109
-  void serial_echo_start_P(const int8_t p);
110
-  void serial_error_start_P(const int8_t p);
111
-
112
-#else // NUM_SERIAL <= 1
113
-
114
-  //
115
-  // Serial out to all ports
116
-  //
117
-  #define SERIAL_CHAR(x)                    MYSERIAL0.write(x)
118
-  #define SERIAL_ECHO(x)                    MYSERIAL0.print(x)
119
-  #define SERIAL_ECHO_F(x,y)                MYSERIAL0.print(x,y)
120
-  #define SERIAL_ECHOLN(x)                  MYSERIAL0.println(x)
121
-  #define SERIAL_PRINT(x,b)                 MYSERIAL0.print(x,b)
122
-  #define SERIAL_PRINTLN(x,b)               MYSERIAL0.println(x,b)
123
-  #define SERIAL_PRINTF(args...)            MYSERIAL0.printf(args)
124
-  #define SERIAL_FLUSH()                    MYSERIAL0.flush()
125
-  #if TX_BUFFER_SIZE > 0
126
-    #define SERIAL_FLUSHTX()                MYSERIAL0.flushTX()
127
-  #endif
128
-
129
-  //
130
-  // Serial out with port redirect
131
-  //
132
-  #define SERIAL_CHAR_P(p,x)                SERIAL_CHAR(x)
133
-  #define SERIAL_ECHO_P(p,x)                SERIAL_ECHO(x)
134
-  #define SERIAL_ECHO_F_P(p,x,y)            SERIAL_ECHO_F(x,y)
135
-  #define SERIAL_ECHOLN_P(p,x)              SERIAL_ECHOLN(x)
136
-  #define SERIAL_PRINT_P(p,x,b)             SERIAL_PRINT(x,b)
137
-  #define SERIAL_PRINTLN_P(p,x,b)           SERIAL_PRINTLN(x,b)
138
-  #define SERIAL_PRINTF_P(p,args...)        SERIAL_PRINTF(args)
139
-  #define SERIAL_FLUSH_P(p)                 SERIAL_FLUSH()
140
-  #if TX_BUFFER_SIZE > 0
141
-    #define SERIAL_FLUSHTX_P(p)             SERIAL_FLUSHTX()
142
-  #endif
143
-
144
-  #define SERIAL_ECHOPGM_P(p,x)             SERIAL_ECHOPGM(x)
145
-  #define SERIAL_ECHOLNPGM_P(p,x)           SERIAL_ECHOLNPGM(x)
146
-  #define SERIAL_ECHOPAIR_P(p, pre, value)  SERIAL_ECHOPAIR(pre, value)
147
-
148
-  #define SERIAL_ECHO_P(p,x)                SERIAL_ECHO(x)
149
-  #define SERIAL_ECHOLN_P(p,x)              SERIAL_ECHOLN(x)
150
-
151
-  #define SERIAL_ECHO_START_P(p)            SERIAL_ECHO_START()
152
-  #define SERIAL_ERROR_START_P(p)           SERIAL_ERROR_START()
153
-  #define SERIAL_EOL_P(p)                   SERIAL_EOL()
154
-
155
-  #define SERIAL_ECHOPAIR_F_P(p, pre, value, y)   SERIAL_ECHOPAIR_F(pre, value, y)
156
-  #define SERIAL_ECHOLNPAIR_F_P(p, pre, value, y) SERIAL_ECHOLNPAIR_F(pre, value, y)
157
-
158
-  #define serial_echopair_PGM_P(p,s_P,v)    serial_echopair_PGM(s_P, v)
159
-
160
-  #define serial_spaces_P(p,c)              serial_spaces(c)
161
-  #define SERIAL_ECHO_SP_P(p,C)             SERIAL_ECHO_SP(C)
162
-
163
-  #define serialprintPGM_P(p,s)             serialprintPGM(s)
164
-
165
-#endif // NUM_SERIAL < 2
64
+#define PORT_REDIRECT(p)        _PORT_REDIRECT(1,p)
65
+#define PORT_RESTORE()          _PORT_RESTORE(1)
66
+
67
+#define SERIAL_CHAR(x)          SERIAL_OUT(write, x)
68
+#define SERIAL_ECHO(x)          SERIAL_OUT(print, x)
69
+#define SERIAL_ECHO_F(x,y)      SERIAL_OUT(print, x, y)
70
+#define SERIAL_ECHOLN(x)        SERIAL_OUT(println, x)
71
+#define SERIAL_PRINT(x,b)       SERIAL_OUT(print, x, b)
72
+#define SERIAL_PRINTLN(x,b)     SERIAL_OUT(println, x, b)
73
+#define SERIAL_PRINTF(args...)  SERIAL_OUT(printf, args)
74
+#define SERIAL_FLUSH()          SERIAL_OUT(flush)
75
+#if TX_BUFFER_SIZE > 0
76
+  #define SERIAL_FLUSHTX()      SERIAL_OUT(flushTX)
77
+#endif
166
 
78
 
167
 #define SERIAL_ECHOPGM(x)                   (serialprintPGM(PSTR(x)))
79
 #define SERIAL_ECHOPGM(x)                   (serialprintPGM(PSTR(x)))
168
 #define SERIAL_ECHOLNPGM(x)                 (serialprintPGM(PSTR(x "\n")))
80
 #define SERIAL_ECHOLNPGM(x)                 (serialprintPGM(PSTR(x "\n")))
169
 #define SERIAL_ECHOPAIR(pre, value)         (serial_echopair_PGM(PSTR(pre), value))
81
 #define SERIAL_ECHOPAIR(pre, value)         (serial_echopair_PGM(PSTR(pre), value))
170
-#define SERIAL_ECHOLNPAIR(pre, value)       do { SERIAL_ECHOPAIR(pre, value); SERIAL_EOL(); } while(0)
82
+#define SERIAL_ECHOLNPAIR(pre, value)       do{ SERIAL_ECHOPAIR(pre, value); SERIAL_EOL(); }while(0)
171
 
83
 
172
 #define SERIAL_ECHOPAIR_F(pre, value, y)    do{ SERIAL_ECHO(pre); SERIAL_ECHO_F(value, y); }while(0)
84
 #define SERIAL_ECHOPAIR_F(pre, value, y)    do{ SERIAL_ECHO(pre); SERIAL_ECHO_F(value, y); }while(0)
173
 #define SERIAL_ECHOLNPAIR_F(pre, value, y)  do{ SERIAL_ECHOPAIR_F(pre, value, y); SERIAL_EOL(); }while(0)
85
 #define SERIAL_ECHOLNPAIR_F(pre, value, y)  do{ SERIAL_ECHOPAIR_F(pre, value, y); SERIAL_EOL(); }while(0)
177
 #define SERIAL_EOL()                        SERIAL_CHAR('\n')
89
 #define SERIAL_EOL()                        SERIAL_CHAR('\n')
178
 
90
 
179
 #define SERIAL_ECHO_MSG(STR)                do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(STR); }while(0)
91
 #define SERIAL_ECHO_MSG(STR)                do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(STR); }while(0)
180
-#define SERIAL_ECHO_MSG_P(p, STR)           do{ SERIAL_ECHO_START_P(p); SERIAL_ECHOLNPGM_P(p, STR); }while(0)
181
 #define SERIAL_ERROR_MSG(STR)               do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(STR); }while(0)
92
 #define SERIAL_ERROR_MSG(STR)               do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(STR); }while(0)
182
-#define SERIAL_ERROR_MSG_P(p, STR)          do{ SERIAL_ERROR_START_P(p); SERIAL_ECHOLNPGM_P(p, STR); }while(0)
183
-
184
-#define SERIAL_ECHOLNPAIR_P(p, pre, value)  do{ SERIAL_ECHOPAIR_P(p, pre, value); SERIAL_EOL_P(p); }while(0)
185
 
93
 
186
-void serial_spaces(uint8_t count);
187
 #define SERIAL_ECHO_SP(C)                   serial_spaces(C)
94
 #define SERIAL_ECHO_SP(C)                   serial_spaces(C)
188
 
95
 
189
 //
96
 //
206
 void serial_error_start();
113
 void serial_error_start();
207
 void serialprint_onoff(const bool onoff);
114
 void serialprint_onoff(const bool onoff);
208
 void serialprintln_onoff(const bool onoff);
115
 void serialprintln_onoff(const bool onoff);
116
+void serial_spaces(uint8_t count);
209
 
117
 
210
 #if ENABLED(DEBUG_LEVELING_FEATURE)
118
 #if ENABLED(DEBUG_LEVELING_FEATURE)
211
   void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z);
119
   void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z);

+ 2
- 2
Marlin/src/core/utility.h Näytä tiedosto

133
   inline void restore() { ref_ = val_; }
133
   inline void restore() { ref_ = val_; }
134
 };
134
 };
135
 
135
 
136
-#define REMEMBER(N,X, ...) restorer<typeof(X)> N##_restorer(X, ##__VA_ARGS__)
137
-#define RESTORE(N) N##_restorer.restore()
136
+#define REMEMBER(N,X, ...) restorer<typeof(X)> restorer_##N(X, ##__VA_ARGS__)
137
+#define RESTORE(N) restorer_##N.restore()

+ 14
- 30
Marlin/src/feature/bedlevel/ubl/ubl.cpp Näytä tiedosto

34
 
34
 
35
   #include "math.h"
35
   #include "math.h"
36
 
36
 
37
-  void unified_bed_leveling::echo_name(
38
-    #if NUM_SERIAL > 1
39
-      const int8_t port/*= -1*/
40
-    #endif
41
-  ) {
42
-    SERIAL_ECHOPGM_P(port, "Unified Bed Leveling");
37
+  void unified_bed_leveling::echo_name() {
38
+    SERIAL_ECHOPGM("Unified Bed Leveling");
43
   }
39
   }
44
 
40
 
45
-  void unified_bed_leveling::report_current_mesh(
46
-    #if NUM_SERIAL > 1
47
-      const int8_t port/*= -1*/
48
-    #endif
49
-  ) {
41
+  void unified_bed_leveling::report_current_mesh() {
50
     if (!leveling_is_valid()) return;
42
     if (!leveling_is_valid()) return;
51
-    SERIAL_ECHO_MSG_P(port, "  G29 I99");
43
+    SERIAL_ECHO_MSG("  G29 I99");
52
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
44
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
53
       for (uint8_t y = 0;  y < GRID_MAX_POINTS_Y; y++)
45
       for (uint8_t y = 0;  y < GRID_MAX_POINTS_Y; y++)
54
         if (!isnan(z_values[x][y])) {
46
         if (!isnan(z_values[x][y])) {
55
-          SERIAL_ECHO_START_P(port);
56
-          SERIAL_ECHOPAIR_P(port, "  M421 I", x);
57
-          SERIAL_ECHOPAIR_P(port, " J", y);
58
-          SERIAL_ECHOPAIR_F_P(port, " Z", z_values[x][y], 2);
59
-          SERIAL_EOL_P(port);
47
+          SERIAL_ECHO_START();
48
+          SERIAL_ECHOPAIR("  M421 I", x);
49
+          SERIAL_ECHOPAIR(" J", y);
50
+          SERIAL_ECHOPAIR_F(" Z", z_values[x][y], 2);
51
+          SERIAL_EOL();
60
           serial_delay(75); // Prevent Printrun from exploding
52
           serial_delay(75); // Prevent Printrun from exploding
61
         }
53
         }
62
   }
54
   }
63
 
55
 
64
-  void unified_bed_leveling::report_state(
65
-    #if NUM_SERIAL > 1
66
-      const int8_t port/*= -1*/
67
-    #endif
68
-  ) {
69
-    echo_name(
70
-      #if NUM_SERIAL > 1
71
-        port
72
-      #endif
73
-    );
74
-    SERIAL_ECHOPGM_P(port, " System v" UBL_VERSION " ");
75
-    if (!planner.leveling_active) SERIAL_ECHOPGM_P(port, "in");
76
-    SERIAL_ECHOLNPGM_P(port, "active.");
56
+  void unified_bed_leveling::report_state() {
57
+    echo_name();
58
+    SERIAL_ECHOPGM(" System v" UBL_VERSION " ");
59
+    if (!planner.leveling_active) SERIAL_ECHOPGM("in");
60
+    SERIAL_ECHOLNPGM("active.");
77
     serial_delay(50);
61
     serial_delay(50);
78
   }
62
   }
79
 
63
 

+ 3
- 15
Marlin/src/feature/bedlevel/ubl/ubl.h Näytä tiedosto

94
 
94
 
95
   public:
95
   public:
96
 
96
 
97
-    static void echo_name(
98
-      #if NUM_SERIAL > 1
99
-        const int8_t port = -1
100
-      #endif
101
-    );
102
-    static void report_current_mesh(
103
-      #if NUM_SERIAL > 1
104
-        const int8_t port = -1
105
-      #endif
106
-    );
107
-    static void report_state(
108
-      #if NUM_SERIAL > 1
109
-        const int8_t port = -1
110
-      #endif
111
-    );
97
+    static void echo_name();
98
+    static void report_current_mesh();
99
+    static void report_state();
112
     static void save_ubl_active_state_and_disable();
100
     static void save_ubl_active_state_and_disable();
113
     static void restore_ubl_active_state_and_leave();
101
     static void restore_ubl_active_state_and_leave();
114
     static void display_map(const int) _O0;
102
     static void display_map(const int) _O0;

+ 7
- 11
Marlin/src/gcode/config/M217.cpp Näytä tiedosto

33
 
33
 
34
 void M217_report(const bool eeprom=false) {
34
 void M217_report(const bool eeprom=false) {
35
 
35
 
36
-  #if NUM_SERIAL > 1
37
-    const int16_t port = command_queue_port[cmd_queue_index_r];
38
-  #endif
39
-
40
   #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
36
   #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
41
-    serialprintPGM_P(port, eeprom ? PSTR("  M217") : PSTR("Singlenozzle:"));
42
-    SERIAL_ECHOPAIR_P(port, " S", LINEAR_UNIT(toolchange_settings.swap_length));
43
-    SERIAL_ECHOPAIR_P(port, " P", LINEAR_UNIT(toolchange_settings.prime_speed));
44
-    SERIAL_ECHOPAIR_P(port, " R", LINEAR_UNIT(toolchange_settings.retract_speed));
37
+    serialprintPGM(eeprom ? PSTR("  M217") : PSTR("Singlenozzle:"));
38
+    SERIAL_ECHOPAIR(" S", LINEAR_UNIT(toolchange_settings.swap_length));
39
+    SERIAL_ECHOPAIR(" P", LINEAR_UNIT(toolchange_settings.prime_speed));
40
+    SERIAL_ECHOPAIR(" R", LINEAR_UNIT(toolchange_settings.retract_speed));
45
 
41
 
46
     #if ENABLED(TOOLCHANGE_PARK)
42
     #if ENABLED(TOOLCHANGE_PARK)
47
-      SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(toolchange_settings.change_point.x));
48
-      SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(toolchange_settings.change_point.y));
43
+      SERIAL_ECHOPAIR(" X", LINEAR_UNIT(toolchange_settings.change_point.x));
44
+      SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(toolchange_settings.change_point.y));
49
     #endif
45
     #endif
50
 
46
 
51
   #else
47
   #else
54
 
50
 
55
   #endif
51
   #endif
56
 
52
 
57
-  SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(toolchange_settings.z_raise));
53
+  SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(toolchange_settings.z_raise));
58
   SERIAL_EOL();
54
   SERIAL_EOL();
59
 }
55
 }
60
 
56
 

+ 11
- 21
Marlin/src/gcode/config/M92.cpp Näytä tiedosto

23
 #include "../gcode.h"
23
 #include "../gcode.h"
24
 #include "../../module/planner.h"
24
 #include "../../module/planner.h"
25
 
25
 
26
-void report_M92(
27
-  #if NUM_SERIAL > 1
28
-    const int8_t port,
29
-  #endif
30
-  const bool echo=true, const int8_t e=-1
31
-) {
32
-  if (echo) SERIAL_ECHO_START_P(port); else SERIAL_CHAR(' ');
33
-  SERIAL_ECHOPAIR_P(port, " M92 X", LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]));
34
-  SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]));
35
-  SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]));
26
+void report_M92(const bool echo=true, const int8_t e=-1) {
27
+  if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' ');
28
+  SERIAL_ECHOPAIR(" M92 X", LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]));
29
+  SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]));
30
+  SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]));
36
   #if DISABLED(DISTINCT_E_FACTORS)
31
   #if DISABLED(DISTINCT_E_FACTORS)
37
-    SERIAL_ECHOPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS]));
32
+    SERIAL_ECHOPAIR(" E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS]));
38
   #endif
33
   #endif
39
-  SERIAL_EOL_P(port);
34
+  SERIAL_EOL();
40
 
35
 
41
   #if ENABLED(DISTINCT_E_FACTORS)
36
   #if ENABLED(DISTINCT_E_FACTORS)
42
     for (uint8_t i = 0; i < E_STEPPERS; i++) {
37
     for (uint8_t i = 0; i < E_STEPPERS; i++) {
43
       if (e >= 0 && i != e) continue;
38
       if (e >= 0 && i != e) continue;
44
-      if (echo) SERIAL_ECHO_START_P(port); else SERIAL_CHAR(' ');
45
-      SERIAL_ECHOPAIR_P(port, " M92 T", (int)i);
46
-      SERIAL_ECHOLNPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)]));
39
+      if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' ');
40
+      SERIAL_ECHOPAIR(" M92 T", (int)i);
41
+      SERIAL_ECHOLNPAIR(" E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)]));
47
     }
42
     }
48
   #endif
43
   #endif
49
 }
44
 }
71
     #if ENABLED(MAGIC_NUMBERS_GCODE)
66
     #if ENABLED(MAGIC_NUMBERS_GCODE)
72
       "HL"
67
       "HL"
73
     #endif
68
     #endif
74
-  )) return report_M92(
75
-    #if NUM_SERIAL > 1
76
-      command_queue_port[cmd_queue_index_r],
77
-    #endif
78
-    true, target_extruder
79
-  );
69
+  )) return report_M92(true, target_extruder);
80
 
70
 
81
   LOOP_XYZE(i) {
71
   LOOP_XYZE(i) {
82
     if (parser.seenval(axis_codes[i])) {
72
     if (parser.seenval(axis_codes[i])) {

+ 6
- 21
Marlin/src/gcode/eeprom/M500-M504.cpp Näytä tiedosto

33
   #include "../../gcode/queue.h"
33
   #include "../../gcode/queue.h"
34
 #endif
34
 #endif
35
 
35
 
36
-#if ADD_PORT_ARG
37
-  #define CHAT_PORT command_queue_port[cmd_queue_index_r]
38
-#else
39
-  #define CHAT_PORT
40
-#endif
41
-
42
 /**
36
 /**
43
  * M500: Store settings in EEPROM
37
  * M500: Store settings in EEPROM
44
  */
38
  */
45
 void GcodeSuite::M500() {
39
 void GcodeSuite::M500() {
46
-  (void)settings.save(CHAT_PORT);
40
+  (void)settings.save();
47
   #if ENABLED(EXTENSIBLE_UI)
41
   #if ENABLED(EXTENSIBLE_UI)
48
     ExtUI::onStoreSettings();
42
     ExtUI::onStoreSettings();
49
   #endif
43
   #endif
53
  * M501: Read settings from EEPROM
47
  * M501: Read settings from EEPROM
54
  */
48
  */
55
 void GcodeSuite::M501() {
49
 void GcodeSuite::M501() {
56
-  (void)settings.load(
57
-    #if ENABLED(EEPROM_SETTINGS)
58
-      CHAT_PORT
59
-    #endif
60
-  );
50
+  (void)settings.load();
61
   #if ENABLED(EXTENSIBLE_UI)
51
   #if ENABLED(EXTENSIBLE_UI)
62
     ExtUI::onLoadSettings();
52
     ExtUI::onLoadSettings();
63
   #endif
53
   #endif
67
  * M502: Revert to default settings
57
  * M502: Revert to default settings
68
  */
58
  */
69
 void GcodeSuite::M502() {
59
 void GcodeSuite::M502() {
70
-  (void)settings.reset(CHAT_PORT);
60
+  (void)settings.reset();
71
   #if ENABLED(EXTENSIBLE_UI)
61
   #if ENABLED(EXTENSIBLE_UI)
72
     ExtUI::onFactoryReset();
62
     ExtUI::onFactoryReset();
73
   #endif
63
   #endif
79
    * M503: print settings currently in memory
69
    * M503: print settings currently in memory
80
    */
70
    */
81
   void GcodeSuite::M503() {
71
   void GcodeSuite::M503() {
82
-    (void)settings.report(
83
-      parser.seen('S') && !parser.value_bool()
84
-      #if NUM_SERIAL > 1
85
-        , command_queue_port[cmd_queue_index_r]
86
-      #endif
87
-    );
72
+    (void)settings.report(parser.boolval('S', true));
88
   }
73
   }
89
 
74
 
90
 #endif // !DISABLE_M503
75
 #endif // !DISABLE_M503
94
    * M504: Validate EEPROM Contents
79
    * M504: Validate EEPROM Contents
95
    */
80
    */
96
   void GcodeSuite::M504() {
81
   void GcodeSuite::M504() {
97
-    if (settings.validate(CHAT_PORT))
98
-      SERIAL_ECHO_MSG_P(command_queue_port[cmd_queue_index_r], "EEPROM OK");
82
+    if (settings.validate())
83
+      SERIAL_ECHO_MSG("EEPROM OK");
99
   }
84
   }
100
 #endif
85
 #endif

+ 2
- 0
Marlin/src/gcode/gcode.cpp Näytä tiedosto

754
 void GcodeSuite::process_next_command() {
754
 void GcodeSuite::process_next_command() {
755
   char * const current_command = command_queue[cmd_queue_index_r];
755
   char * const current_command = command_queue[cmd_queue_index_r];
756
 
756
 
757
+  PORT_REDIRECT(command_queue_port[cmd_queue_index_r]);
758
+
757
   if (DEBUGGING(ECHO)) {
759
   if (DEBUGGING(ECHO)) {
758
     SERIAL_ECHO_START();
760
     SERIAL_ECHO_START();
759
     SERIAL_ECHOLN(current_command);
761
     SERIAL_ECHOLN(current_command);

+ 2
- 8
Marlin/src/gcode/host/M115.cpp Näytä tiedosto

40
  * M115: Capabilities string
40
  * M115: Capabilities string
41
  */
41
  */
42
 void GcodeSuite::M115() {
42
 void GcodeSuite::M115() {
43
-  #if NUM_SERIAL > 1
44
-    const int8_t port = command_queue_port[cmd_queue_index_r];
45
-    #define CAPLINE(STR,...) cap_line(PSTR(STR), port, __VA_ARGS__)
46
-  #else
47
-    #define CAPLINE(STR,...) cap_line(PSTR(STR), __VA_ARGS__)
48
-  #endif
49
-
50
-  SERIAL_ECHOLNPGM_P(port, MSG_M115_REPORT);
43
+
44
+  SERIAL_ECHOLNPGM(MSG_M115_REPORT);
51
 
45
 
52
   #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
46
   #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
53
 
47
 

+ 4
- 7
Marlin/src/gcode/parser.cpp Näytä tiedosto

328
 #endif // CNC_COORDINATE_SYSTEMS
328
 #endif // CNC_COORDINATE_SYSTEMS
329
 
329
 
330
 void GCodeParser::unknown_command_error() {
330
 void GCodeParser::unknown_command_error() {
331
-  #if NUM_SERIAL > 1
332
-    const int16_t port = command_queue_port[cmd_queue_index_r];
333
-  #endif
334
-  SERIAL_ECHO_START_P(port);
335
-  SERIAL_ECHOPAIR_P(port, MSG_UNKNOWN_COMMAND, command_ptr);
336
-  SERIAL_CHAR_P(port, '"');
337
-  SERIAL_EOL_P(port);
331
+  SERIAL_ECHO_START();
332
+  SERIAL_ECHOPAIR(MSG_UNKNOWN_COMMAND, command_ptr);
333
+  SERIAL_CHAR('"');
334
+  SERIAL_EOL();
338
 }
335
 }
339
 
336
 
340
 #if ENABLED(DEBUG_GCODE_PARSER)
337
 #if ENABLED(DEBUG_GCODE_PARSER)

+ 52
- 50
Marlin/src/gcode/queue.cpp Näytä tiedosto

219
   #if NUM_SERIAL > 1
219
   #if NUM_SERIAL > 1
220
     const int16_t port = command_queue_port[cmd_queue_index_r];
220
     const int16_t port = command_queue_port[cmd_queue_index_r];
221
     if (port < 0) return;
221
     if (port < 0) return;
222
+    PORT_REDIRECT(port);
222
   #endif
223
   #endif
223
   if (!send_ok[cmd_queue_index_r]) return;
224
   if (!send_ok[cmd_queue_index_r]) return;
224
-  SERIAL_ECHOPGM_P(port, MSG_OK);
225
+  SERIAL_ECHOPGM(MSG_OK);
225
   #if ENABLED(ADVANCED_OK)
226
   #if ENABLED(ADVANCED_OK)
226
     char* p = command_queue[cmd_queue_index_r];
227
     char* p = command_queue[cmd_queue_index_r];
227
     if (*p == 'N') {
228
     if (*p == 'N') {
228
-      SERIAL_ECHO_P(port, ' ');
229
-      SERIAL_ECHO_P(port, *p++);
229
+      SERIAL_ECHO(' ');
230
+      SERIAL_ECHO(*p++);
230
       while (NUMERIC_SIGNED(*p))
231
       while (NUMERIC_SIGNED(*p))
231
-        SERIAL_ECHO_P(port, *p++);
232
+        SERIAL_ECHO(*p++);
232
     }
233
     }
233
-    SERIAL_ECHOPGM_P(port, " P"); SERIAL_ECHO_P(port, int(BLOCK_BUFFER_SIZE - planner.movesplanned() - 1));
234
-    SERIAL_ECHOPGM_P(port, " B"); SERIAL_ECHO_P(port, BUFSIZE - commands_in_queue);
234
+    SERIAL_ECHOPGM(" P"); SERIAL_ECHO(int(BLOCK_BUFFER_SIZE - planner.movesplanned() - 1));
235
+    SERIAL_ECHOPGM(" B"); SERIAL_ECHO(BUFSIZE - commands_in_queue);
235
   #endif
236
   #endif
236
-  SERIAL_EOL_P(port);
237
+  SERIAL_EOL();
237
 }
238
 }
238
 
239
 
239
 /**
240
 /**
244
   #if NUM_SERIAL > 1
245
   #if NUM_SERIAL > 1
245
     const int16_t port = command_queue_port[cmd_queue_index_r];
246
     const int16_t port = command_queue_port[cmd_queue_index_r];
246
     if (port < 0) return;
247
     if (port < 0) return;
248
+    PORT_REDIRECT(port);
247
   #endif
249
   #endif
248
-  SERIAL_FLUSH_P(port);
249
-  SERIAL_ECHOPGM_P(port, MSG_RESEND);
250
-  SERIAL_ECHOLN_P(port, gcode_LastN + 1);
250
+  SERIAL_FLUSH();
251
+  SERIAL_ECHOPGM(MSG_RESEND);
252
+  SERIAL_ECHOLN(gcode_LastN + 1);
251
   ok_to_send();
253
   ok_to_send();
252
 }
254
 }
253
 
255
 
270
   }
272
   }
271
 }
273
 }
272
 
274
 
273
-void gcode_line_error(PGM_P err, uint8_t port) {
274
-  SERIAL_ERROR_START_P(port);
275
-  serialprintPGM_P(port, err);
276
-  SERIAL_ECHOLN_P(port, gcode_LastN);
275
+void gcode_line_error(PGM_P const err, const int8_t port) {
276
+  PORT_REDIRECT(port);
277
+  SERIAL_ERROR_START();
278
+  serialprintPGM(err);
279
+  SERIAL_ECHOLN(gcode_LastN);
277
   while (read_serial(port) != -1);           // clear out the RX buffer
280
   while (read_serial(port) != -1);           // clear out the RX buffer
278
   flush_and_request_resend();
281
   flush_and_request_resend();
279
   serial_count[port] = 0;
282
   serial_count[port] = 0;
281
 
284
 
282
 #if ENABLED(FAST_FILE_TRANSFER)
285
 #if ENABLED(FAST_FILE_TRANSFER)
283
 
286
 
284
-  #if ENABLED(SDSUPPORT)
285
-    #define CARD_CHAR_P(C)   SERIAL_CHAR_P(card.transfer_port, C)
286
-    #define CARD_ECHO_P(V)   SERIAL_ECHO_P(card.transfer_port, V)
287
-    #define CARD_ECHOLN_P(V) SERIAL_ECHOLN_P(card.transfer_port, V)
288
-  #endif
289
-
290
   inline bool serial_data_available(const uint8_t index) {
287
   inline bool serial_data_available(const uint8_t index) {
291
     switch (index) {
288
     switch (index) {
292
       case 0: return MYSERIAL0.available();
289
       case 0: return MYSERIAL0.available();
380
     void receive(char (&buffer)[buffer_size]) {
377
     void receive(char (&buffer)[buffer_size]) {
381
       uint8_t data = 0;
378
       uint8_t data = 0;
382
       millis_t transfer_timeout = millis() + RX_TIMESLICE;
379
       millis_t transfer_timeout = millis() + RX_TIMESLICE;
380
+
381
+      #if ENABLED(SDSUPPORT)
382
+        PORT_REDIRECT(card.transfer_port);
383
+      #endif
384
+
383
       while (PENDING(millis(), transfer_timeout)) {
385
       while (PENDING(millis(), transfer_timeout)) {
384
         switch (stream_state) {
386
         switch (stream_state) {
385
           case StreamState::STREAM_RESET:
387
           case StreamState::STREAM_RESET:
388
             packet_reset();
390
             packet_reset();
389
             stream_state = StreamState::PACKET_HEADER;
391
             stream_state = StreamState::PACKET_HEADER;
390
             break;
392
             break;
391
-          case StreamState::STREAM_HEADER: // we could also transfer the filename in this packet, rather than handling it in the gcode
392
-            for (size_t i = 0; i < sizeof(stream_header); ++i) {
393
+          case StreamState::STREAM_HEADER: // The filename could also be in this packet, rather than handling it in the gcode
394
+            for (size_t i = 0; i < sizeof(stream_header); ++i)
393
               stream_header_bytes[i] = buffer[i];
395
               stream_header_bytes[i] = buffer[i];
394
-            }
396
+
395
             if (stream_header.token == 0x1234) {
397
             if (stream_header.token == 0x1234) {
396
               stream_state = StreamState::PACKET_RESET;
398
               stream_state = StreamState::PACKET_RESET;
397
               bytes_received = 0;
399
               bytes_received = 0;
398
               time_stream_start = millis();
400
               time_stream_start = millis();
399
-              CARD_ECHO_P("echo: Datastream initialized (");
400
-              CARD_ECHO_P(stream_header.filesize);
401
-              CARD_ECHOLN_P("Bytes expected)");
402
-              CARD_ECHO_P("so"); // confirm active stream and the maximum block size supported
403
-              CARD_CHAR_P(static_cast<uint8_t>(buffer_size & 0xFF));
404
-              CARD_CHAR_P(static_cast<uint8_t>((buffer_size >> 8) & 0xFF));
405
-              CARD_CHAR_P('\n');
401
+              SERIAL_ECHO("echo: Datastream initialized (");
402
+              SERIAL_ECHO(stream_header.filesize);
403
+              SERIAL_ECHOLN("Bytes expected)");
404
+              SERIAL_ECHO("so"); // confirm active stream and the maximum block size supported
405
+              SERIAL_CHAR(static_cast<uint8_t>(buffer_size & 0xFF));
406
+              SERIAL_CHAR(static_cast<uint8_t>((buffer_size >> 8) & 0xFF));
407
+              SERIAL_CHAR('\n');
406
             }
408
             }
407
             else {
409
             else {
408
-              CARD_ECHOLN_P("echo: Datastream initialization error (invalid token)");
410
+              SERIAL_ECHOLN("echo: Datastream initialization error (invalid token)");
409
               stream_state = StreamState::STREAM_FAILED;
411
               stream_state = StreamState::STREAM_FAILED;
410
             }
412
             }
411
             buffer_next_index = 0;
413
             buffer_next_index = 0;
421
                 stream_state = StreamState::PACKET_DATA;
423
                 stream_state = StreamState::PACKET_DATA;
422
               }
424
               }
423
               else {
425
               else {
424
-                CARD_ECHO_P("echo: Datastream packet out of order");
426
+                SERIAL_ECHO("echo: Datastream packet out of order");
425
                 stream_state = StreamState::PACKET_FLUSHRX;
427
                 stream_state = StreamState::PACKET_FLUSHRX;
426
               }
428
               }
427
             }
429
             }
433
               buffer[buffer_next_index] = data;
435
               buffer[buffer_next_index] = data;
434
             }
436
             }
435
             else {
437
             else {
436
-              CARD_ECHO_P("echo: Datastream packet data buffer overrun");
438
+              SERIAL_ECHO("echo: Datastream packet data buffer overrun");
437
               stream_state = StreamState::STREAM_FAILED;
439
               stream_state = StreamState::STREAM_FAILED;
438
               break;
440
               break;
439
             }
441
             }
458
               else {
460
               else {
459
                 if (bytes_received < stream_header.filesize) {
461
                 if (bytes_received < stream_header.filesize) {
460
                   stream_state = StreamState::PACKET_RESET;    // reset and receive next packet
462
                   stream_state = StreamState::PACKET_RESET;    // reset and receive next packet
461
-                  CARD_ECHOLN_P("ok");   // transmit confirm packet received and valid token
463
+                  SERIAL_ECHOLN("ok");   // transmit confirm packet received and valid token
462
                 }
464
                 }
463
                 else  {
465
                 else  {
464
                   stream_state = StreamState::STREAM_COMPLETE; // no more data required
466
                   stream_state = StreamState::STREAM_COMPLETE; // no more data required
465
                 }
467
                 }
466
                 if (card.write(buffer, buffer_next_index) < 0) {
468
                 if (card.write(buffer, buffer_next_index) < 0) {
467
                   stream_state = StreamState::STREAM_FAILED;
469
                   stream_state = StreamState::STREAM_FAILED;
468
-                  CARD_ECHO_P("echo: IO ERROR");
470
+                  SERIAL_ECHO("echo: IO ERROR");
469
                   break;
471
                   break;
470
                 };
472
                 };
471
               }
473
               }
472
             }
474
             }
473
             else {
475
             else {
474
-              CARD_ECHO_P("echo: Block(");
475
-              CARD_ECHO_P(packet.header.id);
476
-              CARD_ECHOLN_P(") Corrupt");
476
+              SERIAL_ECHO("echo: Block(");
477
+              SERIAL_ECHO(packet.header.id);
478
+              SERIAL_ECHOLN(") Corrupt");
477
               stream_state = StreamState::PACKET_FLUSHRX;
479
               stream_state = StreamState::PACKET_FLUSHRX;
478
             }
480
             }
479
             break;
481
             break;
481
             if (packet_retries < MAX_RETRIES) {
483
             if (packet_retries < MAX_RETRIES) {
482
               packet_retries ++;
484
               packet_retries ++;
483
               stream_state = StreamState::PACKET_RESET;
485
               stream_state = StreamState::PACKET_RESET;
484
-              CARD_ECHO_P("echo: Resend request ");
485
-              CARD_ECHOLN_P(packet_retries);
486
-              CARD_ECHOLN_P("rs"); // transmit resend packet token
486
+              SERIAL_ECHO("echo: Resend request ");
487
+              SERIAL_ECHOLN(packet_retries);
488
+              SERIAL_ECHOLN("rs"); // transmit resend packet token
487
             }
489
             }
488
             else {
490
             else {
489
               stream_state = StreamState::STREAM_FAILED;
491
               stream_state = StreamState::STREAM_FAILED;
499
             packet.timeout = millis() + STREAM_MAX_WAIT;
501
             packet.timeout = millis() + STREAM_MAX_WAIT;
500
             break;
502
             break;
501
           case StreamState::PACKET_TIMEOUT:
503
           case StreamState::PACKET_TIMEOUT:
502
-            CARD_ECHOLN_P("echo: Datastream timeout");
504
+            SERIAL_ECHOLN("echo: Datastream timeout");
503
             stream_state = StreamState::PACKET_RESEND;
505
             stream_state = StreamState::PACKET_RESEND;
504
             break;
506
             break;
505
           case StreamState::STREAM_COMPLETE:
507
           case StreamState::STREAM_COMPLETE:
506
             stream_state = StreamState::STREAM_RESET;
508
             stream_state = StreamState::STREAM_RESET;
507
             card.flag.binary_mode = false;
509
             card.flag.binary_mode = false;
508
             card.closefile();
510
             card.closefile();
509
-            CARD_ECHO_P("echo: ");
510
-            CARD_ECHO_P(card.filename);
511
-            CARD_ECHO_P(" transfer completed @ ");
512
-            CARD_ECHO_P(((bytes_received / (millis() - time_stream_start) * 1000) / 1024 ));
513
-            CARD_ECHOLN_P("KiB/s");
514
-            CARD_ECHOLN_P("sc"); // transmit stream complete token
511
+            SERIAL_ECHO("echo: ");
512
+            SERIAL_ECHO(card.filename);
513
+            SERIAL_ECHO(" transfer completed @ ");
514
+            SERIAL_ECHO(((bytes_received / (millis() - time_stream_start) * 1000) / 1024 ));
515
+            SERIAL_ECHOLN("KiB/s");
516
+            SERIAL_ECHOLN("sc"); // transmit stream complete token
515
             return;
517
             return;
516
           case StreamState::STREAM_FAILED:
518
           case StreamState::STREAM_FAILED:
517
             stream_state = StreamState::STREAM_RESET;
519
             stream_state = StreamState::STREAM_RESET;
518
             card.flag.binary_mode = false;
520
             card.flag.binary_mode = false;
519
             card.closefile();
521
             card.closefile();
520
             card.removeFile(card.filename);
522
             card.removeFile(card.filename);
521
-            CARD_ECHOLN_P("echo: File transfer failed");
522
-            CARD_ECHOLN_P("sf"); // transmit stream failed token
523
+            SERIAL_ECHOLN("echo: File transfer failed");
524
+            SERIAL_ECHOLN("sf"); // transmit stream failed token
523
             return;
525
             return;
524
         }
526
         }
525
       }
527
       }

+ 9
- 17
Marlin/src/gcode/sdcard/M20-M30_M32-M34_M524_M928.cpp Näytä tiedosto

50
  * M20: List SD card to serial output
50
  * M20: List SD card to serial output
51
  */
51
  */
52
 void GcodeSuite::M20() {
52
 void GcodeSuite::M20() {
53
-  #if NUM_SERIAL > 1
54
-    const int16_t port = command_queue_port[cmd_queue_index_r];
55
-  #endif
56
-
57
-  SERIAL_ECHOLNPGM_P(port, MSG_BEGIN_FILE_LIST);
53
+  SERIAL_ECHOLNPGM(MSG_BEGIN_FILE_LIST);
58
   card.ls(
54
   card.ls(
59
     #if NUM_SERIAL > 1
55
     #if NUM_SERIAL > 1
60
-      port
56
+      command_queue_port[cmd_queue_index_r]
61
     #endif
57
     #endif
62
   );
58
   );
63
-  SERIAL_ECHOLNPGM_P(port, MSG_END_FILE_LIST);
59
+  SERIAL_ECHOLNPGM(MSG_END_FILE_LIST);
64
 }
60
 }
65
 
61
 
66
 /**
62
 /**
165
  */
161
  */
166
 void GcodeSuite::M27() {
162
 void GcodeSuite::M27() {
167
   #if NUM_SERIAL > 1
163
   #if NUM_SERIAL > 1
168
-    const int16_t port = command_queue_port[cmd_queue_index_r];
164
+    const int16_t port = serial_port_index;
169
   #endif
165
   #endif
170
 
166
 
171
   if (parser.seen('C')) {
167
   if (parser.seen('C')) {
172
-    SERIAL_ECHOPGM_P(port, "Current file: ");
168
+    SERIAL_ECHOPGM("Current file: ");
173
     card.printFilename();
169
     card.printFilename();
174
   }
170
   }
175
 
171
 
197
 
193
 
198
   #if ENABLED(FAST_FILE_TRANSFER)
194
   #if ENABLED(FAST_FILE_TRANSFER)
199
 
195
 
200
-    #if NUM_SERIAL > 1
201
-      const int16_t port = command_queue_port[cmd_queue_index_r];
202
-    #endif
203
-
204
     bool binary_mode = false;
196
     bool binary_mode = false;
205
     char *p = parser.string_arg;
197
     char *p = parser.string_arg;
206
     if (p[0] == 'B' && NUMERIC(p[1])) {
198
     if (p[0] == 'B' && NUMERIC(p[1])) {
211
 
203
 
212
     // Binary transfer mode
204
     // Binary transfer mode
213
     if ((card.flag.binary_mode = binary_mode)) {
205
     if ((card.flag.binary_mode = binary_mode)) {
214
-      SERIAL_ECHO_START_P(port);
215
-      SERIAL_ECHO_P(port, " preparing to receive: ");
216
-      SERIAL_ECHOLN_P(port, p);
206
+      SERIAL_ECHO_START();
207
+      SERIAL_ECHO(" preparing to receive: ");
208
+      SERIAL_ECHOLN(p);
217
       card.openFile(p, false);
209
       card.openFile(p, false);
218
       #if NUM_SERIAL > 1
210
       #if NUM_SERIAL > 1
219
-        card.transfer_port = port;
211
+        card.transfer_port = command_queue_port[cmd_queue_index_r];
220
       #endif
212
       #endif
221
     }
213
     }
222
     else
214
     else

+ 2
- 2
Marlin/src/gcode/stats/M31.cpp Näytä tiedosto

42
   elapsed.toString(buffer);
42
   elapsed.toString(buffer);
43
   ui.set_status(buffer);
43
   ui.set_status(buffer);
44
 
44
 
45
-  SERIAL_ECHO_START_P(port);
46
-  SERIAL_ECHOLNPAIR_P(port, "Print time: ", buffer);
45
+  SERIAL_ECHO_START();
46
+  SERIAL_ECHOLNPAIR("Print time: ", buffer);
47
 }
47
 }

+ 3
- 3
Marlin/src/gcode/temperature/M105.cpp Näytä tiedosto

40
   #endif
40
   #endif
41
 
41
 
42
   #if HAS_TEMP_SENSOR
42
   #if HAS_TEMP_SENSOR
43
-    SERIAL_ECHOPGM_P(port, MSG_OK);
43
+    SERIAL_ECHOPGM(MSG_OK);
44
     thermalManager.print_heater_states(target_extruder
44
     thermalManager.print_heater_states(target_extruder
45
       #if NUM_SERIAL > 1
45
       #if NUM_SERIAL > 1
46
         , port
46
         , port
47
       #endif
47
       #endif
48
     );
48
     );
49
   #else // !HAS_TEMP_SENSOR
49
   #else // !HAS_TEMP_SENSOR
50
-    SERIAL_ERROR_MSG_P(port, MSG_ERR_NO_THERMISTORS);
50
+    SERIAL_ERROR_MSG(MSG_ERR_NO_THERMISTORS);
51
   #endif
51
   #endif
52
 
52
 
53
-  SERIAL_EOL_P(port);
53
+  SERIAL_EOL();
54
 }
54
 }

+ 347
- 385
Marlin/src/module/configuration_store.cpp
File diff suppressed because it is too large
Näytä tiedosto


+ 7
- 24
Marlin/src/module/configuration_store.h Näytä tiedosto

27
   #include "../HAL/shared/persistent_store_api.h"
27
   #include "../HAL/shared/persistent_store_api.h"
28
 #endif
28
 #endif
29
 
29
 
30
-#define ADD_PORT_ARG ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1
31
-
32
-#if ADD_PORT_ARG
33
-  #define PORTINIT_SOLO    const int8_t port=-1
34
-  #define PORTINIT_AFTER  ,const int8_t port=-1
35
-#else
36
-  #define PORTINIT_SOLO
37
-  #define PORTINIT_AFTER
38
-#endif
39
-
40
 class MarlinSettings {
30
 class MarlinSettings {
41
   public:
31
   public:
42
     MarlinSettings() { }
32
     MarlinSettings() { }
43
 
33
 
44
     static uint16_t datasize();
34
     static uint16_t datasize();
45
 
35
 
46
-    static void reset(PORTINIT_SOLO);
47
-    static bool save(PORTINIT_SOLO);    // Return 'true' if data was saved
36
+    static void reset();
37
+    static bool save();    // Return 'true' if data was saved
48
 
38
 
49
     FORCE_INLINE static bool init_eeprom() {
39
     FORCE_INLINE static bool init_eeprom() {
50
       reset();
40
       reset();
65
     #endif
55
     #endif
66
 
56
 
67
     #if ENABLED(EEPROM_SETTINGS)
57
     #if ENABLED(EEPROM_SETTINGS)
68
-      static bool load(PORTINIT_SOLO);      // Return 'true' if data was loaded ok
69
-      static bool validate(PORTINIT_SOLO);  // Return 'true' if EEPROM data is ok
58
+      static bool load();      // Return 'true' if data was loaded ok
59
+      static bool validate();  // Return 'true' if EEPROM data is ok
70
 
60
 
71
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
61
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
72
                                          // That can store is enabled
62
                                          // That can store is enabled
86
     #endif
76
     #endif
87
 
77
 
88
     #if DISABLED(DISABLE_M503)
78
     #if DISABLED(DISABLE_M503)
89
-      static void report(const bool forReplay=false
90
-        #if NUM_SERIAL > 1
91
-          , const int8_t port=-1
92
-        #endif
93
-      );
79
+      static void report(const bool forReplay=false);
94
     #else
80
     #else
95
       FORCE_INLINE
81
       FORCE_INLINE
96
       static void report(const bool forReplay=false) { UNUSED(forReplay); }
82
       static void report(const bool forReplay=false) { UNUSED(forReplay); }
109
                                           // live at the very end of the eeprom
95
                                           // live at the very end of the eeprom
110
       #endif
96
       #endif
111
 
97
 
112
-      static bool _load(PORTINIT_SOLO);
113
-      static bool size_error(const uint16_t size PORTINIT_AFTER);
98
+      static bool _load();
99
+      static bool size_error(const uint16_t size);
114
     #endif
100
     #endif
115
 };
101
 };
116
 
102
 
117
 extern MarlinSettings settings;
103
 extern MarlinSettings settings;
118
-
119
-#undef PORTINIT_SOLO
120
-#undef PORTINIT_AFTER

+ 16
- 23
Marlin/src/module/temperature.cpp Näytä tiedosto

2500
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
2500
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
2501
       , const float r
2501
       , const float r
2502
     #endif
2502
     #endif
2503
-    #if NUM_SERIAL > 1
2504
-      , const int8_t port=-1
2505
-    #endif
2506
     , const int8_t e=-3
2503
     , const int8_t e=-3
2507
   ) {
2504
   ) {
2508
     #if !(HAS_HEATED_BED && HAS_TEMP_HOTEND && HAS_TEMP_CHAMBER) && HOTENDS <= 1
2505
     #if !(HAS_HEATED_BED && HAS_TEMP_HOTEND && HAS_TEMP_CHAMBER) && HOTENDS <= 1
2509
       UNUSED(e);
2506
       UNUSED(e);
2510
     #endif
2507
     #endif
2511
 
2508
 
2512
-    SERIAL_CHAR_P(port, ' ');
2513
-    SERIAL_CHAR_P(port,
2509
+    SERIAL_CHAR(' ');
2510
+    SERIAL_CHAR(
2514
       #if HAS_TEMP_CHAMBER && HAS_HEATED_BED && HAS_TEMP_HOTEND
2511
       #if HAS_TEMP_CHAMBER && HAS_HEATED_BED && HAS_TEMP_HOTEND
2515
         e == -2 ? 'C' : e == -1 ? 'B' : 'T'
2512
         e == -2 ? 'C' : e == -1 ? 'B' : 'T'
2516
       #elif HAS_HEATED_BED && HAS_TEMP_HOTEND
2513
       #elif HAS_HEATED_BED && HAS_TEMP_HOTEND
2522
       #endif
2519
       #endif
2523
     );
2520
     );
2524
     #if HOTENDS > 1
2521
     #if HOTENDS > 1
2525
-      if (e >= 0) SERIAL_CHAR_P(port, '0' + e);
2522
+      if (e >= 0) SERIAL_CHAR('0' + e);
2526
     #endif
2523
     #endif
2527
-    SERIAL_CHAR_P(port, ':');
2528
-    SERIAL_ECHO_P(port, c);
2529
-    SERIAL_ECHOPAIR_P(port, " /" , t);
2524
+    SERIAL_CHAR(':');
2525
+    SERIAL_ECHO(c);
2526
+    SERIAL_ECHOPAIR(" /" , t);
2530
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
2527
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
2531
-      SERIAL_ECHOPAIR_P(port, " (", r / OVERSAMPLENR);
2532
-      SERIAL_CHAR_P(port, ')');
2528
+      SERIAL_ECHOPAIR(" (", r / OVERSAMPLENR);
2529
+      SERIAL_CHAR(')');
2533
     #endif
2530
     #endif
2534
     delay(2);
2531
     delay(2);
2535
   }
2532
   }
2536
 
2533
 
2537
-  void Temperature::print_heater_states(const uint8_t target_extruder
2538
-    #if NUM_SERIAL > 1
2539
-      , const int8_t port
2540
-    #endif
2541
-  ) {
2534
+  void Temperature::print_heater_states(const uint8_t target_extruder) {
2542
     #if HAS_TEMP_HOTEND
2535
     #if HAS_TEMP_HOTEND
2543
       print_heater_state(degHotend(target_extruder), degTargetHotend(target_extruder)
2536
       print_heater_state(degHotend(target_extruder), degTargetHotend(target_extruder)
2544
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
2537
         #if ENABLED(SHOW_TEMP_ADC_VALUES)
2579
         , e
2572
         , e
2580
       );
2573
       );
2581
     #endif
2574
     #endif
2582
-    SERIAL_ECHOPGM_P(port, " @:");
2583
-    SERIAL_ECHO_P(port, getHeaterPower(target_extruder));
2575
+    SERIAL_ECHOPGM(" @:");
2576
+    SERIAL_ECHO(getHeaterPower(target_extruder));
2584
     #if HAS_HEATED_BED
2577
     #if HAS_HEATED_BED
2585
-      SERIAL_ECHOPGM_P(port, " B@:");
2586
-      SERIAL_ECHO_P(port, getHeaterPower(-1));
2578
+      SERIAL_ECHOPGM(" B@:");
2579
+      SERIAL_ECHO(getHeaterPower(-1));
2587
     #endif
2580
     #endif
2588
     #if HOTENDS > 1
2581
     #if HOTENDS > 1
2589
       HOTEND_LOOP() {
2582
       HOTEND_LOOP() {
2590
-        SERIAL_ECHOPAIR_P(port, " @", e);
2591
-        SERIAL_CHAR_P(port, ':');
2592
-        SERIAL_ECHO_P(port, getHeaterPower(e));
2583
+        SERIAL_ECHOPAIR(" @", e);
2584
+        SERIAL_CHAR(':');
2585
+        SERIAL_ECHO(getHeaterPower(e));
2593
       }
2586
       }
2594
     #endif
2587
     #endif
2595
   }
2588
   }

+ 1
- 5
Marlin/src/module/temperature.h Näytä tiedosto

672
     #endif // HEATER_IDLE_HANDLER
672
     #endif // HEATER_IDLE_HANDLER
673
 
673
 
674
     #if HAS_TEMP_SENSOR
674
     #if HAS_TEMP_SENSOR
675
-      static void print_heater_states(const uint8_t target_extruder
676
-        #if NUM_SERIAL > 1
677
-          , const int8_t port = -1
678
-        #endif
679
-      );
675
+      static void print_heater_states(const uint8_t target_extruder);
680
       #if ENABLED(AUTO_REPORT_TEMPERATURES)
676
       #if ENABLED(AUTO_REPORT_TEMPERATURES)
681
         static uint8_t auto_report_temp_interval;
677
         static uint8_t auto_report_temp_interval;
682
         static millis_t next_temp_report_ms;
678
         static millis_t next_temp_report_ms;

+ 40
- 77
Marlin/src/sd/cardreader.cpp Näytä tiedosto

51
 char CardReader::filename[FILENAME_LENGTH], CardReader::longFilename[LONG_FILENAME_LENGTH];
51
 char CardReader::filename[FILENAME_LENGTH], CardReader::longFilename[LONG_FILENAME_LENGTH];
52
 int8_t CardReader::autostart_index;
52
 int8_t CardReader::autostart_index;
53
 
53
 
54
-#if ENABLED(FAST_FILE_TRANSFER)
55
-  #if NUM_SERIAL > 1
56
-    uint8_t CardReader::transfer_port;
57
-  #endif
54
+#if ENABLED(FAST_FILE_TRANSFER) && NUM_SERIAL > 1
55
+  int8_t CardReader::transfer_port;
58
 #endif
56
 #endif
59
 
57
 
60
 // private:
58
 // private:
160
 
158
 
161
 uint16_t nrFile_index;
159
 uint16_t nrFile_index;
162
 
160
 
163
-void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/
164
-  #if NUM_SERIAL > 1
165
-    , const int8_t port/*= -1*/
166
-  #endif
167
-) {
161
+void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/) {
168
   dir_t p;
162
   dir_t p;
169
   uint8_t cnt = 0;
163
   uint8_t cnt = 0;
170
 
164
 
197
       SdFile dir;
191
       SdFile dir;
198
       if (!dir.open(&parent, dosFilename, O_READ)) {
192
       if (!dir.open(&parent, dosFilename, O_READ)) {
199
         if (lsAction == LS_SerialPrint) {
193
         if (lsAction == LS_SerialPrint) {
200
-          SERIAL_ECHO_START_P(port);
201
-          SERIAL_ECHOPGM_P(port, MSG_SD_CANT_OPEN_SUBDIR);
202
-          SERIAL_ECHOLN_P(port, dosFilename);
194
+          SERIAL_ECHO_START();
195
+          SERIAL_ECHOPGM(MSG_SD_CANT_OPEN_SUBDIR);
196
+          SERIAL_ECHOLN(dosFilename);
203
         }
197
         }
204
       }
198
       }
205
-      lsDive(path, dir
206
-        #if NUM_SERIAL > 1
207
-          , NULL, port
208
-        #endif
209
-      );
199
+      lsDive(path, dir);
210
       // close() is done automatically by destructor of SdFile
200
       // close() is done automatically by destructor of SdFile
211
     }
201
     }
212
     else {
202
     else {
228
 
218
 
229
         case LS_SerialPrint:
219
         case LS_SerialPrint:
230
           createFilename(filename, p);
220
           createFilename(filename, p);
231
-          if (prepend) SERIAL_ECHO_P(port, prepend);
232
-          SERIAL_ECHO_P(port, filename);
233
-          SERIAL_CHAR_P(port, ' ');
234
-          SERIAL_ECHOLN_P(port, p.fileSize);
221
+          if (prepend) SERIAL_ECHO(prepend);
222
+          SERIAL_ECHO(filename);
223
+          SERIAL_CHAR(' ');
224
+          SERIAL_ECHOLN(p.fileSize);
235
           break;
225
           break;
236
 
226
 
237
         case LS_GetFilename:
227
         case LS_GetFilename:
248
   } // while readDir
238
   } // while readDir
249
 }
239
 }
250
 
240
 
251
-void CardReader::ls(
252
-  #if NUM_SERIAL > 1
253
-    const int8_t port
254
-  #endif
255
-) {
241
+void CardReader::ls() {
256
   lsAction = LS_SerialPrint;
242
   lsAction = LS_SerialPrint;
257
   root.rewind();
243
   root.rewind();
258
-  lsDive(NULL, root
259
-    #if NUM_SERIAL > 1
260
-      , NULL, port
261
-    #endif
262
-  );
244
+  lsDive(NULL, root);
263
 }
245
 }
264
 
246
 
265
 #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
247
 #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
267
   /**
249
   /**
268
    * Get a long pretty path based on a DOS 8.3 path
250
    * Get a long pretty path based on a DOS 8.3 path
269
    */
251
    */
270
-  void CardReader::printLongPath(char *path
271
-    #if NUM_SERIAL > 1
272
-      , const int8_t port/*= -1*/
273
-    #endif
274
-  ) {
252
+  void CardReader::printLongPath(char *path) {
275
     lsAction = LS_GetFilename;
253
     lsAction = LS_GetFilename;
276
 
254
 
277
     int i, pathLen = strlen(path);
255
     int i, pathLen = strlen(path);
278
 
256
 
279
-    // SERIAL_ECHOPGM_P(port, "Full Path: "); SERIAL_ECHOLN_P(port, path);
257
+    // SERIAL_ECHOPGM("Full Path: "); SERIAL_ECHOLN(path);
280
 
258
 
281
     // Zero out slashes to make segments
259
     // Zero out slashes to make segments
282
     for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0';
260
     for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0';
294
       // Go to the next segment
272
       // Go to the next segment
295
       while (path[++i]) { }
273
       while (path[++i]) { }
296
 
274
 
297
-      // SERIAL_ECHOPGM_P(port, "Looking for segment: "); SERIAL_ECHOLN_P(port, segment);
275
+      // SERIAL_ECHOPGM("Looking for segment: "); SERIAL_ECHOLN(segment);
298
 
276
 
299
       // Find the item, setting the long filename
277
       // Find the item, setting the long filename
300
       diveDir.rewind();
278
       diveDir.rewind();
301
-      lsDive(NULL, diveDir, segment
302
-        #if NUM_SERIAL > 1
303
-          , port
304
-        #endif
305
-      );
279
+      lsDive(NULL, diveDir, segment);
306
 
280
 
307
       // Print /LongNamePart to serial output
281
       // Print /LongNamePart to serial output
308
-      SERIAL_CHAR_P(port, '/');
309
-      SERIAL_ECHO_P(port, longFilename[0] ? longFilename : "???");
282
+      SERIAL_CHAR('/');
283
+      SERIAL_ECHO(longFilename[0] ? longFilename : "???");
310
 
284
 
311
       // If the filename was printed then that's it
285
       // If the filename was printed then that's it
312
       if (!flag.filenameIsDir) break;
286
       if (!flag.filenameIsDir) break;
313
 
287
 
314
-      // SERIAL_ECHOPGM_P(port, "Opening dir: "); SERIAL_ECHOLN_P(port, segment);
288
+      // SERIAL_ECHOPGM("Opening dir: "); SERIAL_ECHOLN(segment);
315
 
289
 
316
       // Open the sub-item as the new dive parent
290
       // Open the sub-item as the new dive parent
317
       SdFile dir;
291
       SdFile dir;
318
       if (!dir.open(&diveDir, segment, O_READ)) {
292
       if (!dir.open(&diveDir, segment, O_READ)) {
319
-        SERIAL_EOL_P(port);
320
-        SERIAL_ECHO_START_P(port);
321
-        SERIAL_ECHOPGM_P(port, MSG_SD_CANT_OPEN_SUBDIR);
322
-        SERIAL_ECHO_P(port, segment);
293
+        SERIAL_EOL();
294
+        SERIAL_ECHO_START();
295
+        SERIAL_ECHOPGM(MSG_SD_CANT_OPEN_SUBDIR);
296
+        SERIAL_ECHO(segment);
323
         break;
297
         break;
324
       }
298
       }
325
 
299
 
328
 
302
 
329
     } // while i<pathLen
303
     } // while i<pathLen
330
 
304
 
331
-    SERIAL_EOL_P(port);
305
+    SERIAL_EOL();
332
   }
306
   }
333
 
307
 
334
 #endif // LONG_FILENAME_HOST_SUPPORT
308
 #endif // LONG_FILENAME_HOST_SUPPORT
336
 /**
310
 /**
337
  * Echo the DOS 8.3 filename (and long filename, if any)
311
  * Echo the DOS 8.3 filename (and long filename, if any)
338
  */
312
  */
339
-void CardReader::printFilename(
340
-  #if NUM_SERIAL > 1
341
-    const int8_t port/*= -1*/
342
-  #endif
343
-) {
313
+void CardReader::printFilename() {
344
   if (file.isOpen()) {
314
   if (file.isOpen()) {
345
     char dosFilename[FILENAME_LENGTH];
315
     char dosFilename[FILENAME_LENGTH];
346
     file.getFilename(dosFilename);
316
     file.getFilename(dosFilename);
347
-    SERIAL_ECHO_P(port, dosFilename);
317
+    SERIAL_ECHO(dosFilename);
348
     #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
318
     #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
349
       getfilename(0, dosFilename);
319
       getfilename(0, dosFilename);
350
       if (longFilename[0]) {
320
       if (longFilename[0]) {
351
-        SERIAL_ECHO_P(port, ' ');
352
-        SERIAL_ECHO_P(port, longFilename);
321
+        SERIAL_ECHO(' ');
322
+        SERIAL_ECHO(longFilename);
353
       }
323
       }
354
     #endif
324
     #endif
355
   }
325
   }
356
   else
326
   else
357
-    SERIAL_ECHOPGM_P(port, "(no file)");
327
+    SERIAL_ECHOPGM("(no file)");
358
 
328
 
359
-  SERIAL_EOL_P(port);
329
+  SERIAL_EOL();
360
 }
330
 }
361
 
331
 
362
 void CardReader::initsd() {
332
 void CardReader::initsd() {
556
   }
526
   }
557
 }
527
 }
558
 
528
 
559
-void CardReader::report_status(
560
-  #if NUM_SERIAL > 1
561
-    const int8_t port/*= -1*/
562
-  #endif
563
-) {
529
+void CardReader::report_status() {
564
   if (isPrinting()) {
530
   if (isPrinting()) {
565
-    SERIAL_ECHOPGM_P(port, MSG_SD_PRINTING_BYTE);
566
-    SERIAL_ECHO_P(port, sdpos);
567
-    SERIAL_CHAR_P(port, '/');
568
-    SERIAL_ECHOLN_P(port, filesize);
531
+    SERIAL_ECHOPGM(MSG_SD_PRINTING_BYTE);
532
+    SERIAL_ECHO(sdpos);
533
+    SERIAL_CHAR('/');
534
+    SERIAL_ECHOLN(filesize);
569
   }
535
   }
570
   else
536
   else
571
-    SERIAL_ECHOLNPGM_P(port, MSG_SD_NOT_PRINTING);
537
+    SERIAL_ECHOLNPGM(MSG_SD_NOT_PRINTING);
572
 }
538
 }
573
 
539
 
574
 void CardReader::write_command(char *buf) {
540
 void CardReader::write_command(char *buf) {
1038
   uint8_t CardReader::auto_report_sd_interval = 0;
1004
   uint8_t CardReader::auto_report_sd_interval = 0;
1039
   millis_t CardReader::next_sd_report_ms;
1005
   millis_t CardReader::next_sd_report_ms;
1040
   #if NUM_SERIAL > 1
1006
   #if NUM_SERIAL > 1
1041
-    int8_t CardReader::serialport;
1007
+    int8_t CardReader::auto_report_port;
1042
   #endif
1008
   #endif
1043
 
1009
 
1044
   void CardReader::auto_report_sd_status() {
1010
   void CardReader::auto_report_sd_status() {
1045
     millis_t current_ms = millis();
1011
     millis_t current_ms = millis();
1046
     if (auto_report_sd_interval && ELAPSED(current_ms, next_sd_report_ms)) {
1012
     if (auto_report_sd_interval && ELAPSED(current_ms, next_sd_report_ms)) {
1047
       next_sd_report_ms = current_ms + 1000UL * auto_report_sd_interval;
1013
       next_sd_report_ms = current_ms + 1000UL * auto_report_sd_interval;
1048
-      report_status(
1049
-        #if NUM_SERIAL > 1
1050
-          serialport
1051
-        #endif
1052
-      );
1014
+      PORT_REDIRECT(auto_report_port);
1015
+      report_status();
1053
     }
1016
     }
1054
   }
1017
   }
1055
 #endif // AUTO_REPORT_SD_STATUS
1018
 #endif // AUTO_REPORT_SD_STATUS

+ 10
- 34
Marlin/src/sd/cardreader.h Näytä tiedosto

70
       const bool re_sort=false
70
       const bool re_sort=false
71
     #endif
71
     #endif
72
   );
72
   );
73
-  static void report_status(
74
-    #if NUM_SERIAL > 1
75
-      const int8_t port = -1
76
-    #endif
77
-  );
73
+  static void report_status();
78
   static void printingHasFinished();
74
   static void printingHasFinished();
79
-  static void printFilename(
80
-    #if NUM_SERIAL > 1
81
-      const int8_t port = -1
82
-    #endif
83
-  );
75
+  static void printFilename();
84
 
76
 
85
   #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
77
   #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
86
-    static void printLongPath(char *path
87
-      #if NUM_SERIAL > 1
88
-        , const int8_t port = -1
89
-      #endif
90
-    );
78
+    static void printLongPath(char *path);
91
   #endif
79
   #endif
92
 
80
 
93
   static void getfilename(uint16_t nr, const char* const match=NULL);
81
   static void getfilename(uint16_t nr, const char* const match=NULL);
95
 
83
 
96
   static void getAbsFilename(char *t);
84
   static void getAbsFilename(char *t);
97
 
85
 
98
-  static void ls(
99
-    #if NUM_SERIAL > 1
100
-      const int8_t port = -1
101
-    #endif
102
-  );
86
+  static void ls();
103
   static void chdir(const char *relpath);
87
   static void chdir(const char *relpath);
104
   static int8_t updir();
88
   static int8_t updir();
105
   static void setroot();
89
   static void setroot();
144
 
128
 
145
   #if ENABLED(AUTO_REPORT_SD_STATUS)
129
   #if ENABLED(AUTO_REPORT_SD_STATUS)
146
     static void auto_report_sd_status(void);
130
     static void auto_report_sd_status(void);
147
-    static inline void set_auto_report_interval(uint8_t v
148
-      #if NUM_SERIAL > 1
149
-        , int8_t port
150
-      #endif
151
-    ) {
131
+    static inline void set_auto_report_interval(const uint8_t v) {
152
       #if NUM_SERIAL > 1
132
       #if NUM_SERIAL > 1
153
-        serialport = port;
133
+        auto_report_port = serial_port_index;
154
       #endif
134
       #endif
155
       NOMORE(v, 60);
135
       NOMORE(v, 60);
156
       auto_report_sd_interval = v;
136
       auto_report_sd_interval = v;
167
 
147
 
168
   #if ENABLED(FAST_FILE_TRANSFER)
148
   #if ENABLED(FAST_FILE_TRANSFER)
169
     #if NUM_SERIAL > 1
149
     #if NUM_SERIAL > 1
170
-      static uint8_t transfer_port;
150
+      static int8_t transfer_port;
171
     #else
151
     #else
172
-      static constexpr uint8_t transfer_port = 0;
152
+      static constexpr int8_t transfer_port = SERIAL_PORT;
173
     #endif
153
     #endif
174
   #endif
154
   #endif
175
 
155
 
244
   static LsAction lsAction; //stored for recursion.
224
   static LsAction lsAction; //stored for recursion.
245
   static uint16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
225
   static uint16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
246
   static char *diveDirName;
226
   static char *diveDirName;
247
-  static void lsDive(const char *prepend, SdFile parent, const char * const match=NULL
248
-    #if NUM_SERIAL > 1
249
-      , const int8_t port = -1
250
-    #endif
251
-  );
227
+  static void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
252
 
228
 
253
   #if ENABLED(SDCARD_SORT_ALPHA)
229
   #if ENABLED(SDCARD_SORT_ALPHA)
254
     static void flush_presort();
230
     static void flush_presort();
258
     static uint8_t auto_report_sd_interval;
234
     static uint8_t auto_report_sd_interval;
259
     static millis_t next_sd_report_ms;
235
     static millis_t next_sd_report_ms;
260
     #if NUM_SERIAL > 1
236
     #if NUM_SERIAL > 1
261
-      static int8_t serialport;
237
+      static int8_t auto_report_port;
262
     #endif
238
     #endif
263
   #endif
239
   #endif
264
 };
240
 };

Loading…
Peruuta
Tallenna