Do *not* shorten the current command in printer_smodel_check

printer_smodel_check was incorrectly substituting the final " with a
null in the command to simplify the model string comparison, but in
doing so was also corrupting the next pop from the cmdqueue.

We can modify the current strchr_pointer as long as we *don't* change
it's length. This can cause an incorrect extra read from the queue,
resulting in the last command to be completely ignored.
This commit is contained in:
Yuri D'Elia 2022-08-06 23:15:46 +02:00
parent 68c04ca2f6
commit 4f22de2333
2 changed files with 4 additions and 5 deletions

View File

@ -431,7 +431,7 @@ lcd_update_enable(true); // display / status-line recovery
#define GCODE_DELIMITER '"'
#define ELLIPSIS "..."
char* code_string(char* pStr,size_t* nLength)
char* code_string(const char* pStr,size_t* nLength)
{
char* pStrBegin;
char* pStrEnd;
@ -444,11 +444,10 @@ pStrEnd=strchr(pStrBegin,GCODE_DELIMITER);
if(!pStrEnd)
return(NULL);
*nLength=pStrEnd-pStrBegin;
pStrBegin[*nLength] = '\0';
return pStrBegin;
}
void printer_smodel_check(char* pStrPos)
void printer_smodel_check(const char* pStrPos)
{
char* pResult;
size_t nLength,nPrinterNameLength;
@ -458,7 +457,7 @@ pResult = code_string(pStrPos,&nLength);
if(pResult != NULL && nLength == nPrinterNameLength) {
// Only compare them if the lengths match
if (strcmp_P(pResult, sPrinterName) == 0) return;
if (strncmp_P(pResult, sPrinterName, nLength) == 0) return;
}
switch(oCheckModel)

View File

@ -104,7 +104,7 @@ extern ClCheckGcode oCheckGcode;
void fCheckModeInit();
void nozzle_diameter_check(uint16_t nDiameter);
void printer_model_check(uint16_t nPrinterModel);
void printer_smodel_check(char* pStrPos);
void printer_smodel_check(const char* pStrPos);
void fw_version_check(const char *pVersion);
void gcode_level_check(uint16_t nGcodeLevel);