MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / DoFilePrint

Method DoFilePrint

src/GCodes/GCodes.cpp:663–850  ·  view source on GitHub ↗

Try to continue with a print from file, returning true if we did anything significant

Source from the content-addressed store, hash-verified

661
662// Try to continue with a print from file, returning true if we did anything significant
663bool GCodes::DoFilePrint(GCodeBuffer& gb, const StringRef& reply) noexcept
664{
665#if HAS_SBC_INTERFACE
666 if (reprap.UsingSbcInterface())
667 {
668 if (gb.IsFileFinished())
669 {
670 if (gb.IsFileChannel() && gb.LatestMachineState().GetPrevious() == nullptr)
671 {
672 // Finished printing SD card file.
673 // We never get here if the file ends in M0 because CancelPrint gets called directly in that case.
674 // Don't close the file until all moves have been completed, in case the print gets paused.
675 // Also, this keeps the state as 'Printing' until the print really has finished.
676# if SUPPORT_ASYNC_MOVES
677 if (!DoSync(gb)) // wait until the other input stream has caught up
678 {
679 return false;
680 }
681# else
682 if (!LockCurrentMovementSystemAndWaitForStandstill(gb)) // wait until movement has finished and deferred command queue has caught up
683 {
684 return false;
685 }
686# endif
687 StopPrint(&gb, StopPrintReason::normalCompletion);
688 return true;
689 }
690
691 if (!gb.IsMacroFileClosed())
692 {
693 // Finished a macro or finished processing config.g
694 gb.MacroFileClosed();
695 CheckFinishedRunningConfigFile(gb);
696
697 // Pop the stack and notify the SBC that we have closed the file
698 Pop(gb, false);
699 gb.Init();
700 gb.LatestMachineState().firstCommandAfterRestart = false;
701
702 // Send a final code response
703 if (gb.GetState() == GCodeState::normal)
704 {
705 UnlockAll(gb);
706 if (!gb.LatestMachineState().lastCodeFromSbc || gb.LatestMachineState().macroStartedByCode)
707 {
708 HandleReply(gb, GCodeResult::ok, "");
709 }
710 CheckForDeferredPause(gb);
711 }
712 return true;
713 }
714 return false;
715 }
716 else
717 {
718 if (gb.LatestMachineState().waitingForAcknowledgement && gb.GetNormalInput() != nullptr)
719 {
720 if (gb.GetNormalInput()->FillBuffer(&gb))

Callers

nothing calls this directly

Calls 14

UsingSbcInterfaceMethod · 0.80
MacroFileClosedMethod · 0.80
GetMessageMethod · 0.80
IsReadyMethod · 0.80
GetPreviousMethod · 0.45
InitMethod · 0.45
GetStateMethod · 0.45
FillBufferMethod · 0.45
DecodeCommandMethod · 0.45
ReadFromFileMethod · 0.45
SetFinishedMethod · 0.45
FileEndedMethod · 0.45

Tested by

no test coverage detected