Merge pull request #3794 from gudnimg/fix-m862-q

Fix undefined pointer in `M862.2 Q` and `M862.3 Q`
This commit is contained in:
3d-gussner 2022-12-07 13:04:45 +01:00 committed by GitHub
commit 96e4881da5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 30 deletions

View File

@ -5,6 +5,3 @@ const uint16_t _nPrinterType PROGMEM=PRINTER_TYPE;
const char _sPrinterName[] PROGMEM=PRINTER_NAME;
const uint16_t _nPrinterMmuType PROGMEM=PRINTER_MMU_TYPE;
const char _sPrinterMmuName[] PROGMEM=PRINTER_MMU_NAME;
uint16_t nPrinterType;
PGM_P sPrinterName;

View File

@ -12,8 +12,6 @@ extern const uint16_t _nPrinterType;
extern const char _sPrinterName[] PROGMEM;
extern const uint16_t _nPrinterMmuType;
extern const char _sPrinterMmuName[] PROGMEM;
extern uint16_t nPrinterType;
extern PGM_P sPrinterName;
// Firmware version
#define FW_MAJOR 3

View File

@ -8049,27 +8049,27 @@ Sigma_Exit:
else if(code_seen('Q'))
SERIAL_PROTOCOLLN((float)eeprom_read_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM)/1000.0);
break;
case ClPrintChecking::_Model: // ~ .2
case ClPrintChecking::_Model: { // ~ .2
uint16_t type = nPrinterType(MMU2::mmu2.Enabled());
if(code_seen('P'))
{
uint16_t nPrinterModel;
nPrinterModel=(uint16_t)code_value_long();
// based on current state of MMU (active/stopped/connecting) perform a runtime update of the printer type
fSetMmuMode(MMU2::mmu2.Enabled());
printer_model_check(nPrinterModel);
printer_model_check(nPrinterModel, type);
}
else if(code_seen('Q'))
SERIAL_PROTOCOLLN(nPrinterType);
break;
case ClPrintChecking::_Smodel: // ~ .3
SERIAL_PROTOCOLLN(type);
} break;
case ClPrintChecking::_Smodel: { // ~ .3
const char *type = sPrinterType(MMU2::mmu2.Enabled());
if(code_seen('P'))
{
fSetMmuMode(MMU2::mmu2.Enabled());
printer_smodel_check(strchr_pointer);
printer_smodel_check(strchr_pointer, type);
}
else if(code_seen('Q'))
SERIAL_PROTOCOLLNRPGM(sPrinterName);
break;
SERIAL_PROTOCOLLNRPGM(type);
} break;
case ClPrintChecking::_Version: // ~ .4
if(code_seen('P'))
fw_version_check(++strchr_pointer);

View File

@ -328,15 +328,15 @@ void nozzle_diameter_check(uint16_t nDiameter) {
}
}
void printer_model_check(uint16_t nPrinterModel) {
void printer_model_check(uint16_t nPrinterModel, uint16_t actualPrinterModel) {
if (oCheckModel == ClCheckModel::_None)
return;
if (nPrinterModel == nPrinterType)
if (nPrinterModel == actualPrinterModel)
return;
// SERIAL_ECHO_START;
// SERIAL_ECHOLNPGM("Printer model differs from the G-code ...");
// SERIAL_ECHOPGM("actual : ");
// SERIAL_ECHOLN(nPrinterType);
// SERIAL_ECHOLN(actualPrinterModel);
// SERIAL_ECHOPGM("expected: ");
// SERIAL_ECHOLN(nPrinterModel);
switch (oCheckModel) {
@ -470,16 +470,16 @@ if(!pStrEnd)
return pStrBegin;
}
void printer_smodel_check(const char *pStrPos) {
void printer_smodel_check(const char *pStrPos, const char *actualPrinterSModel) {
char* pResult;
size_t nLength,nPrinterNameLength;
nPrinterNameLength = strlen_P(sPrinterName);
nPrinterNameLength = strlen_P(actualPrinterSModel);
pResult=code_string(pStrPos,&nLength);
if(pResult != NULL && nLength == nPrinterNameLength) {
// Only compare them if the lengths match
if (strncmp_P(pResult, sPrinterName, nLength) == 0) return;
if (strncmp_P(pResult, actualPrinterSModel, nLength) == 0) return;
}
switch(oCheckModel)
@ -501,13 +501,21 @@ lcd_update_enable(true); // display / status-line recovery
}
}
void fSetMmuMode(bool bMMu) {
uint16_t nPrinterType(bool bMMu) {
if (bMMu) {
nPrinterType = pgm_read_word(&_nPrinterMmuType);
sPrinterName = _sPrinterMmuName;
} else {
nPrinterType = pgm_read_word(&_nPrinterType);
sPrinterName = _sPrinterName;
return pgm_read_word(&_nPrinterMmuType);
}
else {
return pgm_read_word(&_nPrinterType);
}
}
const char *sPrinterType(bool bMMu) {
if (bMMu) {
return _sPrinterMmuName;
}
else {
return _sPrinterName;
}
}

View File

@ -87,12 +87,13 @@ extern ClCheckGcode oCheckGcode;
void fCheckModeInit();
void nozzle_diameter_check(uint16_t nDiameter);
void printer_model_check(uint16_t nPrinterModel);
void printer_smodel_check(const char* pStrPos);
void printer_model_check(uint16_t nPrinterModel, uint16_t actualPrinterModel);
void printer_smodel_check(const char *pStrPos, const char *actualPrinterSModel);
void fw_version_check(const char *pVersion);
void gcode_level_check(uint16_t nGcodeLevel);
void fSetMmuMode(bool bMMu);
uint16_t nPrinterType(bool bMMu);
const char *sPrinterType(bool bMMu);
#define IP4_STR_SIZE 16
extern void ip4_to_str(char* dest, uint8_t* IP);