From a98238172859166db0581612094da2ab85d0c103 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Thu, 12 Aug 2021 08:52:32 +0200 Subject: [PATCH] Only start a new command if the previous one finished ... that means with or without an error and remember the Command's request message - to identify the responses --- src/main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 442d81e..ca3a603 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -219,8 +219,11 @@ void ReportRunningCommand() { } void PlanCommand(const mp::RequestMsg &rq) { - if (currentCommand->Error() == ErrorCode::OK) { - // we are allowed to start a new command as the previous one is in the OK finished state + if (currentCommand->State() == ProgressCode::OK) { + // We are allowed to start a new command as the previous one is in the OK finished state + // The previous command may be in an error state, but as long as it is in ProgressCode::OK (aka finished) + // we are safe here. It is the responsibility of the printer to ask for a command error code + // before issuing another one - if needed. switch (rq.code) { case mp::RequestMsgCodes::Cut: currentCommand = &logic::cutFilament; @@ -241,6 +244,7 @@ void PlanCommand(const mp::RequestMsg &rq) { currentCommand = &logic::noCommand; break; } + currentCommandRq = rq; // save the Current Command Request for indentification of responses currentCommand->Reset(rq.value); ReportCommandAccepted(rq, mp::ResponseMsgParamCodes::Accepted); } else {