Fix pause/resume when using M25/M601
Remove the conflicting and mostly useless card.paused flag (the printing is either paused, or not) and switch to isPrintPaused only which accounts for both cases (SD/USB) correctly. Fix M27/getStatus to show the current real status of the SD print. Synchronize the queue on M601, as required to precisely pause the print at the correct instruction. Alias M25 to M601, which when combined with PR #1899 fixes issue #1614. Guard against incorrect usage in M601, M602 and M603.
This commit is contained in:
parent
18eaf21baf
commit
dbe2ed4150
@ -396,7 +396,7 @@ extern uint16_t gcode_in_progress;
|
|||||||
extern LongTimer safetyTimer;
|
extern LongTimer safetyTimer;
|
||||||
|
|
||||||
#define PRINT_PERCENT_DONE_INIT 0xff
|
#define PRINT_PERCENT_DONE_INIT 0xff
|
||||||
#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsg::TempCal) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || card.paused || mmu_print_saved)
|
#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsg::TempCal) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || mmu_print_saved)
|
||||||
|
|
||||||
//! Beware - mcode_in_progress is set as soon as the command gets really processed,
|
//! Beware - mcode_in_progress is set as soon as the command gets really processed,
|
||||||
//! which is not the same as posting the M600 command into the command queue
|
//! which is not the same as posting the M600 command into the command queue
|
||||||
|
@ -5377,21 +5377,19 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
|
|||||||
card.openFile(strchr_pointer + 4,true);
|
card.openFile(strchr_pointer + 4,true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//! ### M24 - Start SD print
|
//! ### M24 - Start/resume SD print
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
case 24:
|
case 24:
|
||||||
if (!card.paused)
|
if (isPrintPaused)
|
||||||
failstats_reset_print();
|
lcd_resume_print();
|
||||||
card.startFileprint();
|
else
|
||||||
starttime=_millis();
|
{
|
||||||
|
failstats_reset_print();
|
||||||
|
card.startFileprint();
|
||||||
|
starttime=_millis();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//! ### M25 - Pause SD print
|
|
||||||
// ----------------------------------
|
|
||||||
case 25:
|
|
||||||
card.pauseSDPrint();
|
|
||||||
break;
|
|
||||||
|
|
||||||
//! ### M26 S\<index\> - Set SD index
|
//! ### M26 S\<index\> - Set SD index
|
||||||
//! Set position in SD card file to index in bytes.
|
//! Set position in SD card file to index in bytes.
|
||||||
//! This command is expected to be called after M23 and before M24.
|
//! This command is expected to be called after M23 and before M24.
|
||||||
@ -7246,26 +7244,34 @@ Sigma_Exit:
|
|||||||
break;
|
break;
|
||||||
#endif //FILAMENTCHANGEENABLE
|
#endif //FILAMENTCHANGEENABLE
|
||||||
|
|
||||||
|
//! ### M25 - Pause SD print
|
||||||
//! ### M601 - Pause print
|
//! ### M601 - Pause print
|
||||||
|
//! ### M125 - Pause print (TODO: not implemented)
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
case 25:
|
||||||
case 601:
|
case 601:
|
||||||
{
|
{
|
||||||
cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore
|
if (!isPrintPaused)
|
||||||
lcd_pause_print();
|
{
|
||||||
|
st_synchronize();
|
||||||
|
cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore
|
||||||
|
lcd_pause_print();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//! ### M602 - Resume print
|
//! ### M602 - Resume print
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
case 602: {
|
case 602: {
|
||||||
lcd_resume_print();
|
if (isPrintPaused)
|
||||||
|
lcd_resume_print();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//! ### M603 - Stop print
|
//! ### M603 - Stop print
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
case 603: {
|
case 603: {
|
||||||
lcd_print_stop();
|
Stop();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ CardReader::CardReader()
|
|||||||
sdpos = 0;
|
sdpos = 0;
|
||||||
sdprinting = false;
|
sdprinting = false;
|
||||||
cardOK = false;
|
cardOK = false;
|
||||||
paused = false;
|
|
||||||
saving = false;
|
saving = false;
|
||||||
logging = false;
|
logging = false;
|
||||||
autostart_atmillis=0;
|
autostart_atmillis=0;
|
||||||
@ -242,24 +241,13 @@ void CardReader::startFileprint()
|
|||||||
if(cardOK)
|
if(cardOK)
|
||||||
{
|
{
|
||||||
sdprinting = true;
|
sdprinting = true;
|
||||||
paused = false;
|
Stopped = false;
|
||||||
Stopped = false;
|
|
||||||
#ifdef SDCARD_SORT_ALPHA
|
#ifdef SDCARD_SORT_ALPHA
|
||||||
//flush_presort();
|
//flush_presort();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardReader::pauseSDPrint()
|
|
||||||
{
|
|
||||||
if(sdprinting)
|
|
||||||
{
|
|
||||||
sdprinting = false;
|
|
||||||
paused = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CardReader::openLogFile(const char* name)
|
void CardReader::openLogFile(const char* name)
|
||||||
{
|
{
|
||||||
logging = true;
|
logging = true;
|
||||||
@ -408,8 +396,6 @@ void CardReader::openFile(const char* name,bool read, bool replace_current/*=tru
|
|||||||
SERIAL_ECHOLN(name);
|
SERIAL_ECHOLN(name);
|
||||||
}
|
}
|
||||||
sdprinting = false;
|
sdprinting = false;
|
||||||
paused = false;
|
|
||||||
|
|
||||||
|
|
||||||
SdFile myDir;
|
SdFile myDir;
|
||||||
const char *fname=name;
|
const char *fname=name;
|
||||||
@ -492,24 +478,27 @@ uint32_t CardReader::getFileSize()
|
|||||||
|
|
||||||
void CardReader::getStatus()
|
void CardReader::getStatus()
|
||||||
{
|
{
|
||||||
if(sdprinting){
|
if(sdprinting)
|
||||||
SERIAL_PROTOCOL(longFilename);
|
{
|
||||||
SERIAL_PROTOCOLPGM("\n");
|
if (isPrintPaused) {
|
||||||
SERIAL_PROTOCOLRPGM(_N("SD printing byte "));////MSG_SD_PRINTING_BYTE
|
SERIAL_PROTOCOLLNPGM("SD print paused");
|
||||||
SERIAL_PROTOCOL(sdpos);
|
}
|
||||||
SERIAL_PROTOCOLPGM("/");
|
else if (saved_printing) {
|
||||||
SERIAL_PROTOCOLLN(filesize);
|
SERIAL_PROTOCOLLNPGM("Print saved");
|
||||||
uint16_t time = _millis()/60000 - starttime/60000;
|
}
|
||||||
SERIAL_PROTOCOL(itostr2(time/60));
|
else {
|
||||||
SERIAL_PROTOCOL(':');
|
SERIAL_PROTOCOL(longFilename);
|
||||||
SERIAL_PROTOCOL(itostr2(time%60));
|
SERIAL_PROTOCOLPGM("\n");
|
||||||
SERIAL_PROTOCOLPGM("\n");
|
SERIAL_PROTOCOLRPGM(_N("SD printing byte "));////MSG_SD_PRINTING_BYTE
|
||||||
}
|
SERIAL_PROTOCOL(sdpos);
|
||||||
else if (paused) {
|
SERIAL_PROTOCOLPGM("/");
|
||||||
SERIAL_PROTOCOLLNPGM("SD print paused");
|
SERIAL_PROTOCOLLN(filesize);
|
||||||
}
|
uint16_t time = _millis()/60000 - starttime/60000;
|
||||||
else if (saved_printing) {
|
SERIAL_PROTOCOL(itostr2(time/60));
|
||||||
SERIAL_PROTOCOLLNPGM("Print saved");
|
SERIAL_PROTOCOL(':');
|
||||||
|
SERIAL_PROTOCOL(itostr2(time%60));
|
||||||
|
SERIAL_PROTOCOLPGM("\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SERIAL_PROTOCOLLNPGM("Not SD printing");
|
SERIAL_PROTOCOLLNPGM("Not SD printing");
|
||||||
|
@ -25,7 +25,6 @@ public:
|
|||||||
void closefile(bool store_location=false);
|
void closefile(bool store_location=false);
|
||||||
void release();
|
void release();
|
||||||
void startFileprint();
|
void startFileprint();
|
||||||
void pauseSDPrint();
|
|
||||||
uint32_t getFileSize();
|
uint32_t getFileSize();
|
||||||
void getStatus();
|
void getStatus();
|
||||||
void printingHasFinished();
|
void printingHasFinished();
|
||||||
@ -75,7 +74,6 @@ public:
|
|||||||
bool logging;
|
bool logging;
|
||||||
bool sdprinting ;
|
bool sdprinting ;
|
||||||
bool cardOK ;
|
bool cardOK ;
|
||||||
bool paused ;
|
|
||||||
char filename[13];
|
char filename[13];
|
||||||
uint16_t modificationTime, modificationDate;
|
uint16_t modificationTime, modificationDate;
|
||||||
uint32_t cluster, position;
|
uint32_t cluster, position;
|
||||||
|
@ -4108,7 +4108,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) {
|
|||||||
{
|
{
|
||||||
prusa_statistics_case0(15);
|
prusa_statistics_case0(15);
|
||||||
}
|
}
|
||||||
else if (isPrintPaused || card.paused)
|
else if (isPrintPaused)
|
||||||
{
|
{
|
||||||
prusa_statistics_case0(14);
|
prusa_statistics_case0(14);
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) {
|
|||||||
SERIAL_ECHOLN("}");
|
SERIAL_ECHOLN("}");
|
||||||
status_number = 15;
|
status_number = 15;
|
||||||
}
|
}
|
||||||
else if (isPrintPaused || card.paused)
|
else if (isPrintPaused)
|
||||||
{
|
{
|
||||||
SERIAL_ECHO("{");
|
SERIAL_ECHO("{");
|
||||||
prusa_stat_printerstatus(14);
|
prusa_stat_printerstatus(14);
|
||||||
@ -490,7 +490,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) {
|
|||||||
{
|
{
|
||||||
prusa_statistics_case0(15);
|
prusa_statistics_case0(15);
|
||||||
}
|
}
|
||||||
else if (isPrintPaused || card.paused)
|
else if (isPrintPaused)
|
||||||
{
|
{
|
||||||
prusa_statistics_case0(14);
|
prusa_statistics_case0(14);
|
||||||
}
|
}
|
||||||
@ -753,7 +753,6 @@ TEST_CASE("Prusa_statistics test", "[prusa_stats]")
|
|||||||
SERIALS_RESET();
|
SERIALS_RESET();
|
||||||
|
|
||||||
isPrintPaused = 0;
|
isPrintPaused = 0;
|
||||||
card.paused = 0;
|
|
||||||
IS_SD_PRINTING = 1;
|
IS_SD_PRINTING = 1;
|
||||||
old_code::prusa_statistics(test_codes[i],0);
|
old_code::prusa_statistics(test_codes[i],0);
|
||||||
new_code::prusa_statistics(test_codes[i],0);
|
new_code::prusa_statistics(test_codes[i],0);
|
||||||
|
Loading…
Reference in New Issue
Block a user