An attempt at fixing the retry. Discussion needed.

This commit is contained in:
VintagePC 2022-06-26 13:58:25 -04:00 committed by D.R.racer
parent c412f062c8
commit 69c39e2281
4 changed files with 40 additions and 11 deletions

View File

@ -112,6 +112,7 @@ MMU2::MMU2()
, loadFilamentStarted(false) , loadFilamentStarted(false)
, unloadFilamentStarted(false) , unloadFilamentStarted(false)
, loadingToNozzle(false) , loadingToNozzle(false)
, inAutoRetry(false)
{ {
ResetRetryAttempts(); ResetRetryAttempts();
} }
@ -230,11 +231,14 @@ bool MMU2::RetryIfPossible(uint16_t ec){
SetButtonResponse(ButtonOperations::Retry); SetButtonResponse(ButtonOperations::Retry);
// check, that Retry is actually allowed on that operation // check, that Retry is actually allowed on that operation
if( ButtonAvailable(ec) != NoButton ){ if( ButtonAvailable(ec) != NoButton ){
inAutoRetry = true;
SERIAL_ECHOLNPGM("RetryButtonPressed"); SERIAL_ECHOLNPGM("RetryButtonPressed");
--retryAttempts; // "used" one retry attempt // We don't decrement until the button is acknowledged by the MMU.
//--retryAttempts; // "used" one retry attempt
return true; return true;
} }
} }
inAutoRetry = false;
return false; return false;
} }
@ -243,6 +247,14 @@ void MMU2::ResetRetryAttempts(){
retryAttempts = 3; retryAttempts = 3;
} }
void MMU2::DecrementRetryAttempts(){
if (inAutoRetry && retryAttempts)
{
SERIAL_ECHOLNPGM("DecrementRetryAttempts");
retryAttempts--;
}
}
bool MMU2::tool_change(uint8_t index) { bool MMU2::tool_change(uint8_t index) {
if( ! WaitForMMUReady()) if( ! WaitForMMUReady())
return false; return false;
@ -607,7 +619,8 @@ void MMU2::CheckUserInput(){
case Left: case Left:
case Middle: case Middle:
case Right: case Right:
SERIAL_ECHOLNPGM("CheckUserInput-btnLMR"); SERIAL_ECHOPGM("CheckUserInput-btnLMR ");
SERIAL_ECHOLN(btn);
ResumeHotendTemp(); // Recover the hotend temp before we attempt to do anything else... ResumeHotendTemp(); // Recover the hotend temp before we attempt to do anything else...
Button(btn); Button(btn);
break; break;
@ -655,7 +668,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
if (!nozzleTimeout.running()) if (!nozzleTimeout.running())
{ {
nozzleTimeout.start(); nozzleTimeout.start();
LogEchoEvent(" Cooling Timeout started"); LogEchoEvent("Cooling Timeout started");
} }
else if (nozzleTimeout.expired(DEFAULT_SAFETYTIMER_TIME_MINS*60*1000ul)) // mins->msec. TODO: do we use the global or have our own independent timeout else if (nozzleTimeout.expired(DEFAULT_SAFETYTIMER_TIME_MINS*60*1000ul)) // mins->msec. TODO: do we use the global or have our own independent timeout
{ {
@ -676,13 +689,20 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
// command/operation completed, let Marlin continue its work // command/operation completed, let Marlin continue its work
// the E may have some more moves to finish - wait for them // the E may have some more moves to finish - wait for them
ResumeUnpark(); // We can now travel back to the tower or wherever we were when we saved. ResumeUnpark(); // We can now travel back to the tower or wherever we were when we saved.
ResetRetryAttempts(); // Reset the retry counter.
st_synchronize(); st_synchronize();
return; return;
case VersionMismatch: // this basically means the MMU will be disabled until reconnected case VersionMismatch: // this basically means the MMU will be disabled until reconnected
CheckUserInput(); CheckUserInput();
return; return;
case CommunicationTimeout:
case CommandError: case CommandError:
// Don't proceed to the park/save if we are doing an autoretry.
if (inAutoRetry)
{
continue;
}
/* FALLTHRU */
case CommunicationTimeout:
case ProtocolError: case ProtocolError:
SaveAndPark(move_axes, turn_off_nozzle); // and wait for the user to resolve the problem SaveAndPark(move_axes, turn_off_nozzle); // and wait for the user to resolve the problem
CheckUserInput(); CheckUserInput();

View File

@ -168,10 +168,13 @@ public:
/// Automagically "press" a Retry button if we have any retry attempts left /// Automagically "press" a Retry button if we have any retry attempts left
bool RetryIfPossible(uint16_t ec); bool RetryIfPossible(uint16_t ec);
/// Reset the retryAttempts back to the default value /// Decrement the retry attempts, if in a retry.
void ResetRetryAttempts(); // Called by the MMU protocol when a sent button is acknowledged.
void DecrementRetryAttempts();
private: private:
/// Reset the retryAttempts back to the default value
void ResetRetryAttempts();
/// Perform software self-reset of the MMU (sends an X0 command) /// Perform software self-reset of the MMU (sends an X0 command)
void ResetX0(); void ResetX0();
@ -261,6 +264,8 @@ private:
bool loadingToNozzle; bool loadingToNozzle;
uint8_t retryAttempts; uint8_t retryAttempts;
bool inAutoRetry;
}; };
/// following Marlin's way of doing stuff - one and only instance of MMU implementation in the code base /// following Marlin's way of doing stuff - one and only instance of MMU implementation in the code base

View File

@ -261,10 +261,15 @@ StepStatus Command::Step() {
return ProcessFINDAReqSent(Processing, State::Wait); return ProcessFINDAReqSent(Processing, State::Wait);
case State::ButtonSent:{ case State::ButtonSent:{
// button is never confirmed ... may be it should be // button is never confirmed ... may be it should be
// auto expmsg = logic->ExpectingMessage(linkLayerTimeout); auto expmsg = logic->ExpectingMessage(linkLayerTimeout);
// if (expmsg != MessageReady) if (expmsg != MessageReady)
// return expmsg; return expmsg;
SendQuery(); if (logic->rsp.paramCode == ResponseMsgParamCodes::Accepted)
{
// Button was accepted, decrement the retry.
mmu2.DecrementRetryAttempts();
}
SendAndUpdateFilamentSensor();
} break; } break;
default: default:
return ProtocolError; return ProtocolError;

View File

@ -205,7 +205,6 @@ void ReportErrorHook(uint16_t ec, uint8_t res) {
// a button was pushed on the MMU and the LCD should // a button was pushed on the MMU and the LCD should
// dismiss the error screen until MMU raises a new error // dismiss the error screen until MMU raises a new error
ReportErrorHookState = ReportErrorHookStates::DISMISS_ERROR_SCREEN; ReportErrorHookState = ReportErrorHookStates::DISMISS_ERROR_SCREEN;
mmu2.ResetRetryAttempts();
} else { } else {
// attempt an automatic Retry button // attempt an automatic Retry button
if( ReportErrorHookState == ReportErrorHookStates::MONITOR_SELECTION ){ if( ReportErrorHookState == ReportErrorHookStates::MONITOR_SELECTION ){