If an old firmware is detected, make sure the protocol is actually stopped

The printer shouldn't continue endlessly asking for a version if an old MMU is detected.
Also if the protocol is supposed to be turned off, it
shouldn't be sending S0 queries.
This commit is contained in:
Guðni Már Gilbert 2022-12-12 21:21:54 +00:00 committed by DRracer
parent 9f3f0baa47
commit eb8ec9f8b9
1 changed files with 3 additions and 8 deletions

View File

@ -124,8 +124,6 @@ struct OldMMUFWDetector {
return State::MatchingPart;
} else if(ok == 1 && c == 'k'){
++ok;
return State::MatchingPart;
} else if(ok == 2 && c == '\n'){
return State::Matched;
}
return State::SomethingElse;
@ -154,10 +152,8 @@ StepStatus ProtocolLogic::ExpectingMessage() {
// consume old MMU FW's data if any -> avoid confusion of protocol decoder
auto old = oldMMUh4x0r.Detect(c);
if( old == OldMMUFWDetector::State::Matched ){
// hack bad FW version - BEWARE - we silently assume that the first query is an "S0"
// The old MMU FW responds with "ok\n" and we fake the response to a bad FW version at this spot
rsp = ResponseMsg(RequestMsg(RequestMsgCodes::Version, 0), ResponseMsgParamCodes::Accepted, 0);
return MessageReady;
// Old MMU FW 1.0.6 detected. Firmwares are incompatible.
return VersionMismatch;
} else if( old == OldMMUFWDetector::State::MatchingPart ){
break;
}
@ -171,7 +167,7 @@ StepStatus ProtocolLogic::ExpectingMessage() {
if (bytesConsumed != 0) {
RecordUARTActivity(); // something has happened on the UART, update the timeout record
return Processing; // consumed some bytes, but message still not ready
} else if (Elapsed(linkLayerTimeout)) {
} else if (Elapsed(linkLayerTimeout) && currentScope != Scope::Stopped) {
return CommunicationTimeout;
}
return Processing;
@ -794,7 +790,6 @@ StepStatus ProtocolLogic::Step() {
break;
case VersionMismatch:
LogError(PSTR("Version mismatch"));
Stop(); // cannot continue
break;
case ProtocolError:
currentStatus = HandleProtocolError();