diff --git a/Firmware/Filament_sensor.cpp b/Firmware/Filament_sensor.cpp index 9f17eea19..5e16c809e 100644 --- a/Firmware/Filament_sensor.cpp +++ b/Firmware/Filament_sensor.cpp @@ -107,9 +107,17 @@ bool Filament_sensor::checkFilamentEvents() { } void Filament_sensor::triggerFilamentInserted() { - if (autoLoadEnabled && (eFilamentAction == FilamentAction::None) && - !(moves_planned() || IS_SD_PRINTING || usb_timer.running() || (lcd_commands_type == LcdCommands::Layer1Cal) || - eeprom_read_byte((uint8_t *)EEPROM_WIZARD_ACTIVE))) { + if (autoLoadEnabled + && (eFilamentAction == FilamentAction::None) + && (! MMU2::mmu2.Enabled() ) // quick and dirty hack to prevent spurious runouts while the MMU is in charge + && !( + moves_planned() + || IS_SD_PRINTING + || usb_timer.running() + || (lcd_commands_type == LcdCommands::Layer1Cal) + || eeprom_read_byte((uint8_t *)EEPROM_WIZARD_ACTIVE) + ) + ) { filAutoLoad(); } } diff --git a/Firmware/mmu2_protocol_logic.cpp b/Firmware/mmu2_protocol_logic.cpp index 535702a75..f135404c5 100644 --- a/Firmware/mmu2_protocol_logic.cpp +++ b/Firmware/mmu2_protocol_logic.cpp @@ -180,7 +180,10 @@ StepStatus StartSeq::Step() { break; case State::FilamentSensorStateSent: state = State::Ready; - return Finished; + logic->SwitchFromStartToIdle(); + return Processing; // Returning Finished is not a good idea in case of a fast error recovery + // - it tells the printer, that the command which experienced a protocol error and recovered successfully actually terminated. + // In such a case we must return "Processing" in order to keep the MMU state machine running and prevent the printer from executing next G-codes. break; case State::RecoveringProtocolError: // timer elapsed, clear the input buffer @@ -483,6 +486,14 @@ void ProtocolLogic::SwitchToIdle() { idle.Restart(); } +void ProtocolLogic::SwitchFromStartToIdle(){ + state = State::Running; + currentState = &idle; + idle.Restart(); + idle.SendQuery(); // force sending Q0 immediately + idle.state = Idle::State::QuerySent; +} + bool ProtocolLogic::Elapsed(uint32_t timeout) const { return _millis() >= (lastUARTActivityMs + timeout); } diff --git a/Firmware/mmu2_protocol_logic.h b/Firmware/mmu2_protocol_logic.h index 5f4689ba5..fa5437962 100644 --- a/Firmware/mmu2_protocol_logic.h +++ b/Firmware/mmu2_protocol_logic.h @@ -276,6 +276,7 @@ private: void LogError(const char *reason); void LogResponse(); void SwitchFromIdleToCommand(); + void SwitchFromStartToIdle(); enum class State : uint_fast8_t { Stopped, ///< stopped for whatever reason