Start a new gcode, or continue to execute one that has already been started. Return true if we found something significant to do.
| 561 | |
| 562 | // Start a new gcode, or continue to execute one that has already been started. Return true if we found something significant to do. |
| 563 | bool GCodes::StartNextGCode(GCodeBuffer& gb, const StringRef& reply) noexcept |
| 564 | { |
| 565 | // There are special rules for fileGCode because it needs to suspend when paused: |
| 566 | // - if the pause state is paused or resuming, don't execute |
| 567 | // - if the state is pausing then don't execute, unless we are executing a macro (because it could be the pause macro or filament change macro) |
| 568 | // - if there is a deferred pause pending, don't execute once we have finished the current macro |
| 569 | if ( gb.IsFileChannel() |
| 570 | && ( pauseState > PauseState::pausing // paused or resuming |
| 571 | || (!gb.IsDoingFileMacro() && (deferredPauseCommandPending != nullptr || pauseState == PauseState::pausing)) |
| 572 | ) |
| 573 | ) |
| 574 | { |
| 575 | // We are paused or pausing, so don't process any more gcodes from the file being printed. |
| 576 | // There is a potential issue here if fileGCode holds any locks, so unlock everything. |
| 577 | UnlockAll(gb); |
| 578 | } |
| 579 | else if (gb.IsReady() || gb.IsExecuting()) |
| 580 | { |
| 581 | gb.SetFinished(ActOnCode(gb, reply)); |
| 582 | return true; |
| 583 | } |
| 584 | else if (gb.IsDoingFile()) |
| 585 | { |
| 586 | return DoFilePrint(gb, reply); |
| 587 | } |
| 588 | else if (&gb == AutoPauseGCode() && !gb.LatestMachineState().waitingForAcknowledgement) |
| 589 | { |
| 590 | if (Event::StartProcessing()) |
| 591 | { |
| 592 | ProcessEvent(gb); // call out to separate function to avoid increasing stack usage of this function |
| 593 | } |
| 594 | } |
| 595 | else if (&gb == DaemonGCode() |
| 596 | #if SUPPORT_REMOTE_COMMANDS |
| 597 | && !CanInterface::InExpansionMode() // looking for the daemon.g file increases the loop time too much |
| 598 | #endif |
| 599 | ) |
| 600 | { |
| 601 | // Check whether the daemon really is idle and not executing daemon.g, not just waiting for a M291 acknowledgement or something else |
| 602 | if ( !reprap.IsProcessingConfig() |
| 603 | && gb.LatestMachineState().GetPrevious() == nullptr |
| 604 | && !gb.LatestMachineState().DoingFile() |
| 605 | ) |
| 606 | { |
| 607 | // Delay 1 or 10 seconds, then try to open and run daemon.g. No error if it is not found. |
| 608 | if (gb.DoDwellTime((daemonRunning) ? 10000 : 1000)) |
| 609 | { |
| 610 | daemonRunning = true; |
| 611 | return DoFileMacro(gb, DAEMON_G, false, AsyncSystemMacroCode); |
| 612 | } |
| 613 | } |
| 614 | } |
| 615 | else |
| 616 | { |
| 617 | const bool gotCommand = |
| 618 | #if HAS_SBC_INTERFACE |
| 619 | // Two SBC-mode guards on accepting input here: |
| 620 | // - IsExecutingOnSbc: a code has been handed to DSF for processing (see SendToSbc), so don't |
nothing calls this directly
no test coverage detected