From 6d465321b5af2e685a81d18e9195fdcb3d02586c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 9 Apr 2016 16:58:17 -0700 Subject: [PATCH] Adjust timeout code in host_keepalive --- Marlin/Marlin_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index c8b909078..3759a07b7 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -456,7 +456,7 @@ static bool send_ok[BUFSIZE]; }; static MarlinBusyState busy_state = NOT_BUSY; - static millis_t next_busy_signal_ms = -1; + static millis_t prev_busy_signal_ms = -1; uint8_t host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL; #define KEEPALIVE_STATE(n) do{ busy_state = n; }while(0) #else @@ -2279,8 +2279,8 @@ void unknown_command_error() { */ void host_keepalive() { millis_t ms = millis(); - if (busy_state != NOT_BUSY) { - if (ms < next_busy_signal_ms) return; + if (host_keepalive_interval && busy_state != NOT_BUSY) { + if (ms - prev_busy_signal_ms < 1000UL * host_keepalive_interval) return; switch (busy_state) { case IN_HANDLER: case IN_PROCESS: @@ -2299,7 +2299,7 @@ void unknown_command_error() { break; } } - next_busy_signal_ms = host_keepalive_interval ? ms + 1000UL * host_keepalive_interval : -1; + prev_busy_signal_ms = ms; } #endif //HOST_KEEPALIVE_FEATURE