Browse Source

Fix Host Keepalive serial target (#21283)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Victor Oliveira 3 years ago
parent
commit
1b9ff68f8c
No account linked to committer's email address

+ 2
- 4
Marlin/src/HAL/ESP32/FlushableHardwareSerial.h View File

21
  */
21
  */
22
 #pragma once
22
 #pragma once
23
 
23
 
24
-#ifdef ARDUINO_ARCH_ESP32
25
-
26
 #include <HardwareSerial.h>
24
 #include <HardwareSerial.h>
25
+
26
+#include "../shared/Marduino.h"
27
 #include "../../core/serial_hook.h"
27
 #include "../../core/serial_hook.h"
28
 
28
 
29
 class FlushableHardwareSerial : public HardwareSerial {
29
 class FlushableHardwareSerial : public HardwareSerial {
32
 };
32
 };
33
 
33
 
34
 extern Serial0Type<FlushableHardwareSerial> flushableSerial;
34
 extern Serial0Type<FlushableHardwareSerial> flushableSerial;
35
-
36
-#endif // ARDUINO_ARCH_ESP32

+ 1
- 1
Marlin/src/core/serial.h View File

62
 //
62
 //
63
 // Serial redirection
63
 // Serial redirection
64
 //
64
 //
65
-#define SERIAL_ALL 0x7F
65
+#define SERIAL_ALL 0xFF
66
 #if HAS_MULTI_SERIAL
66
 #if HAS_MULTI_SERIAL
67
   #define _PORT_REDIRECT(n,p)   REMEMBER(n,multiSerial.portMask,p)
67
   #define _PORT_REDIRECT(n,p)   REMEMBER(n,multiSerial.portMask,p)
68
   #define _PORT_RESTORE(n,p)    RESTORE(n)
68
   #define _PORT_RESTORE(n,p)    RESTORE(n)

+ 1
- 1
Marlin/src/core/serial_hook.h View File

165
   RuntimeSerial(const bool e, Args... args) : BaseClassT(e), SerialT(args...), writeHook(0), eofHook(0), userPointer(0) {}
165
   RuntimeSerial(const bool e, Args... args) : BaseClassT(e), SerialT(args...), writeHook(0), eofHook(0), userPointer(0) {}
166
 };
166
 };
167
 
167
 
168
-// A class that's duplicating its output conditionally to 2 serial interface
168
+// A class that duplicates its output conditionally to 2 serial interfaces
169
 template <class Serial0T, class Serial1T, const uint8_t offset = 0, const uint8_t step = 1>
169
 template <class Serial0T, class Serial1T, const uint8_t offset = 0, const uint8_t step = 1>
170
 struct MultiSerial : public SerialBase< MultiSerial<Serial0T, Serial1T, offset, step> > {
170
 struct MultiSerial : public SerialBase< MultiSerial<Serial0T, Serial1T, offset, step> > {
171
   typedef SerialBase< MultiSerial<Serial0T, Serial1T, offset, step> > BaseClassT;
171
   typedef SerialBase< MultiSerial<Serial0T, Serial1T, offset, step> > BaseClassT;

+ 1
- 0
Marlin/src/gcode/gcode.cpp View File

1067
     static millis_t next_busy_signal_ms = 0;
1067
     static millis_t next_busy_signal_ms = 0;
1068
     if (!autoreport_paused && host_keepalive_interval && busy_state != NOT_BUSY) {
1068
     if (!autoreport_paused && host_keepalive_interval && busy_state != NOT_BUSY) {
1069
       if (PENDING(ms, next_busy_signal_ms)) return;
1069
       if (PENDING(ms, next_busy_signal_ms)) return;
1070
+      PORT_REDIRECT(SERIAL_ALL);
1070
       switch (busy_state) {
1071
       switch (busy_state) {
1071
         case IN_HANDLER:
1072
         case IN_HANDLER:
1072
         case IN_PROCESS:
1073
         case IN_PROCESS:

+ 9
- 17
Marlin/src/gcode/queue.cpp View File

272
   SERIAL_ECHOLN(serial_state[serial_ind].last_N + 1);
272
   SERIAL_ECHOLN(serial_state[serial_ind].last_N + 1);
273
 }
273
 }
274
 
274
 
275
-// Multiserial already handle the dispatch to/from multiple port by itself
276
-inline bool serial_data_available(uint8_t index = SERIAL_ALL) {
277
-  if (index == SERIAL_ALL) {
278
-    for (index = 0; index < NUM_SERIAL; index++) {
279
-      const int a = SERIAL_IMPL.available(index);
280
-      #if BOTH(RX_BUFFER_MONITOR, RX_BUFFER_SIZE)
281
-        if (a > RX_BUFFER_SIZE - 2) {
282
-          PORT_REDIRECT(SERIAL_PORTMASK(index));
283
-          SERIAL_ERROR_MSG("RX BUF overflow, increase RX_BUFFER_SIZE: ", a);
284
-        }
285
-      #endif
286
-      if (a > 0) return true;
287
-    }
288
-    return false;
289
-  }
275
+inline bool serial_data_available(uint8_t index) {
290
   const int a = SERIAL_IMPL.available(index);
276
   const int a = SERIAL_IMPL.available(index);
291
   #if BOTH(RX_BUFFER_MONITOR, RX_BUFFER_SIZE)
277
   #if BOTH(RX_BUFFER_MONITOR, RX_BUFFER_SIZE)
292
     if (a > RX_BUFFER_SIZE - 2) {
278
     if (a > RX_BUFFER_SIZE - 2) {
294
       SERIAL_ERROR_MSG("RX BUF overflow, increase RX_BUFFER_SIZE: ", a);
280
       SERIAL_ERROR_MSG("RX BUF overflow, increase RX_BUFFER_SIZE: ", a);
295
     }
281
     }
296
   #endif
282
   #endif
297
-
298
   return a > 0;
283
   return a > 0;
299
 }
284
 }
300
 
285
 
286
+// Multiserial already handles dispatch to/from multiple ports
287
+inline bool any_serial_data_available() {
288
+  LOOP_L_N(p, NUM_SERIAL)
289
+    if (serial_data_available(p))
290
+      return true;
291
+}
292
+
301
 inline int read_serial(const uint8_t index) { return SERIAL_IMPL.read(index); }
293
 inline int read_serial(const uint8_t index) { return SERIAL_IMPL.read(index); }
302
 
294
 
303
 void GCodeQueue::gcode_line_error(PGM_P const err, const serial_index_t serial_ind) {
295
 void GCodeQueue::gcode_line_error(PGM_P const err, const serial_index_t serial_ind) {
409
   // send "wait" to indicate Marlin is still waiting.
401
   // send "wait" to indicate Marlin is still waiting.
410
   #if NO_TIMEOUTS > 0
402
   #if NO_TIMEOUTS > 0
411
     const millis_t ms = millis();
403
     const millis_t ms = millis();
412
-    if (ring_buffer.empty() && !serial_data_available() && ELAPSED(ms, last_command_time + NO_TIMEOUTS)) {
404
+    if (ring_buffer.empty() && !any_serial_data_available() && ELAPSED(ms, last_command_time + NO_TIMEOUTS)) {
413
       SERIAL_ECHOLNPGM(STR_WAIT);
405
       SERIAL_ECHOLNPGM(STR_WAIT);
414
       last_command_time = ms;
406
       last_command_time = ms;
415
     }
407
     }

+ 3
- 3
platformio.ini View File

424
 MORGAN_SCARA            = src_filter=+<src/gcode/scara>
424
 MORGAN_SCARA            = src_filter=+<src/gcode/scara>
425
 HAS_MICROSTEPS          = src_filter=+<src/gcode/control/M350_M351.cpp>
425
 HAS_MICROSTEPS          = src_filter=+<src/gcode/control/M350_M351.cpp>
426
 (ESP3D_)?WIFISUPPORT    = AsyncTCP, ESP Async WebServer
426
 (ESP3D_)?WIFISUPPORT    = AsyncTCP, ESP Async WebServer
427
-  ESP3DLib=https://github.com/luc-github/ESP3DLib.git
428
-  arduinoWebSockets=https://github.com/Links2004/arduinoWebSockets.git
429
-  ESP32SSDP=https://github.com/luc-github/ESP32SSDP.git
427
+  ESP3DLib=https://github.com/luc-github/ESP3DLib/archive/master.zip
428
+  arduinoWebSockets=links2004/WebSockets@2.3.4
429
+  luc-github/ESP32SSDP@^1.1.1
430
   lib_ignore=ESPAsyncTCP
430
   lib_ignore=ESPAsyncTCP
431
 
431
 
432
 #
432
 #

Loading…
Cancel
Save