diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index 34c683ce2..b57c549e8 100644 --- a/Firmware/Configuration_adv.h +++ b/Firmware/Configuration_adv.h @@ -69,6 +69,9 @@ // Keepalive period which is restarted with M79 #define M79_TIMEOUT 30 * 1000 // ms +// A timer which is restarted everytime a G-command is added to the command queue. +#define USB_TIMER_TIMEOUT 10 * 1000 // ms + //=========================================================================== //=============================Mechanical Settings=========================== //=========================================================================== diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 1774719b2..76aa4f531 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1733,7 +1733,7 @@ void loop() if (printingIsPaused() && saved_printing_type == PowerPanic::PRINT_TYPE_USB) { //keep believing that usb is being printed. Prevents accessing dangerous menus while pausing. usb_timer.start(); } - else if (usb_timer.expired(10000)) { //just need to check if it expired. Nothing else is needed to be done. + else if (usb_timer.expired(USB_TIMER_TIMEOUT)) { //just need to check if it expired. Nothing else is needed to be done. SetPrinterState(PrinterState::HostPrintingFinished); //set printer state to show LCD menu after finished SD print } @@ -9605,6 +9605,13 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s get_command(); } + if (blocks_queued() && GetPrinterState() == PrinterState::IsHostPrinting && usb_timer.expired((USB_TIMER_TIMEOUT) / 2)) + { + // Handle the case where planned moves may take a longer time to execute than the USB timer period. + // An example is the toolchange unload sequence generated by PrusaSlicer with default settings. + usb_timer.start(); + } + if(max_inactive_time && previous_millis_cmd.expired(max_inactive_time)) kill(PSTR("Inactivity Shutdown")); if(stepper_inactive_time && previous_millis_cmd.expired(stepper_inactive_time)) {