Tune Interrupted state based on unit tests

Now finally the printer can restart ToolChange if MMU restarted.
This commit is contained in:
D.R.racer 2022-11-18 17:31:46 +01:00 committed by DRracer
parent ffbd95b482
commit fe11b7a247
2 changed files with 19 additions and 3 deletions

View File

@ -311,7 +311,7 @@ void MMU2::update_tool_change_counter_eeprom() {
reset_toolchange_counter();
}
void MMU2::MMU2::ToolChangeCommon(uint8_t slot){
void MMU2::ToolChangeCommon(uint8_t slot){
tool_change_extruder = slot;
do {
for(;;) {
@ -320,10 +320,15 @@ void MMU2::MMU2::ToolChangeCommon(uint8_t slot){
break;
// otherwise: failed to perform the command - unload first and then let it run again
unload();
// if we run out of retries, we must do something ... may be raise an error screen and allow the user to do something
// but honestly - if the MMU restarts during every toolchange,
// something else is seriously broken and stopping a print is probably our best option.
}
// reset current position to whatever the planner thinks it is
plan_set_e_position(current_position[E_AXIS]);
} while (0); // while not successfully fed into etruder's PTFE tube
// when we run out of feeding retries, we should call an unload + cut before trying again.
// + we need some error screen report
extruder = slot; //filament change is finished
SpoolJoin::spooljoin.setSlot(slot);

View File

@ -347,9 +347,12 @@ StepStatus ProtocolLogic::ProcessCommandQueryResponse() {
if( ReqMsg().code == rsp.request.code && ReqMsg().value == rsp.request.value ){
progressCode = ProgressCode::OK;
scopeState = ScopeState::Ready;
rq = RequestMsg(RequestMsgCodes::unknown, 0); // clear the successfully finished request
return Finished;
} else {
// got response to some other command - the originally issued command was interrupted!
static const char intr[] PROGMEM = "Intr2"; // @@TODO clean up
MMU2_ERROR_MSGRPGM(intr);
return Interrupted;
}
default:
@ -437,11 +440,19 @@ StepStatus ProtocolLogic::IdleStep() {
buttonCode = static_cast<Buttons>(rsp.paramValue);
StartReading8bitRegisters();
return ButtonPushed;
case ResponseMsgParamCodes::Finished:
if( ReqMsg().code != RequestMsgCodes::unknown ){
// got reset while doing some other command - the originally issued command was interrupted!
// this must be solved by the upper layer, protocol logic doesn't have all the context (like unload before trying again)
static const char intr[] PROGMEM = "Intr1"; // @@TODO cleanup
MMU2_ERROR_MSGRPGM(intr);
IdleRestart();
return Interrupted;
}
[[fallthrough]];
case ResponseMsgParamCodes::Processing:
// @@TODO we may actually use this branch to report progress of manual operation on the MMU
// The MMU sends e.g. X0 P27 after its restart when the user presses an MMU button to move the Selector
// For now let's behave just like "finished"
case ResponseMsgParamCodes::Finished:
errorCode = ErrorCode::OK;
break;
default: