From 6f89ec0f1949de0a36d5c537f696c466aab4610d Mon Sep 17 00:00:00 2001 From: Addio <59629419+AddioElectronics@users.noreply.github.com> Date: Fri, 21 Jul 2023 07:02:32 -0700 Subject: [PATCH] Fixed printer_smodel_check for MK3/S and possible older MMU machines (#4265) Fixed printer_smodel_check for non MMU machines Commit 136ef96 broke the compatibility check for MK3S without MMU. May have fixed bug for older MMU machines. Only comparing up to the length of the value from the g-code, would return equal on older MMU machines trying to run g-code sliced without the MMU. Unfortunately if that is a feature, it will cause the different printer warning. --- Firmware/util.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Firmware/util.cpp b/Firmware/util.cpp index fff8dd31d5..2b0dc56763 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -407,16 +407,19 @@ return pStrBegin; } void printer_smodel_check(const char *pStrPos, const char *actualPrinterSModel) { -char* pResult; -size_t nLength; - -pResult=code_string(pStrPos,&nLength); - -if(pResult != NULL) { - // Only compare first 6 chars on MK3|MK3S - if (strncmp_P(pResult, PSTR("MK3"), 3) == 0) nLength = 6; - if (strncmp_P(pResult, actualPrinterSModel, nLength) == 0) return; -} + char* pResult; + size_t nLength; + size_t aLength; + + pResult=code_string(pStrPos,&nLength); + if(pResult != NULL) { + aLength=strlen_P(actualPrinterSModel); + if(aLength > nLength) nLength = aLength; + + // Only compare first 6 chars on MK3|MK3S if string longer than 4 characters + if (nLength > 4 && strncmp_P(pResult, PSTR("MK3"), 3) == 0) nLength = 6; + if (strncmp_P(pResult, actualPrinterSModel, nLength) == 0) return; + } render_M862_warnings( _T(MSG_GCODE_DIFF_PRINTER_CONTINUE)