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

Method SpinGCodeBuffer

src/GCodes/GCodes.cpp:505–560  ·  view source on GitHub ↗

Do some work on an input channel, returning true if we did something significant

Source from the content-addressed store, hash-verified

503
504// Do some work on an input channel, returning true if we did something significant
505bool GCodes::SpinGCodeBuffer(GCodeBuffer& gb) noexcept
506{
507 // Set up a buffer for the reply
508 String<GCodeReplyLength> reply;
509 bool result;
510
511 MutexLocker gbLock(gb.mutex);
512 if (gb.GetState() == GCodeState::normal)
513 {
514 if (gb.LatestMachineState().messageAcknowledged)
515 {
516 const bool shouldAbort = gb.LatestMachineState().messageShouldAbort;
517 gb.PopState(true); // this could fail if the current macro has already been aborted
518
519 if (shouldAbort)
520 {
521 if (gb.LatestMachineState().GetPrevious() == nullptr)
522 {
523#if HAS_SBC_INTERFACE
524 if (reprap.UsingSbcInterface())
525 {
526 gb.AbortFile(false);
527 }
528#endif
529 StopPrint(nullptr, StopPrintReason::userCancelled);
530 }
531 else
532 {
533 FileMacroCyclesReturn(gb);
534 }
535 }
536 result = shouldAbort;
537 }
538 else
539 {
540 result = StartNextGCode(gb, reply.GetRef());
541 }
542 }
543 else
544 {
545 RunStateMachine(gb, reply.GetRef()); // execute the state machine
546 result = true; // assume we did something useful (not necessarily true, e.g. could be waiting for movement to stop)
547 }
548
549 if ((gb.IsExecuting()
550#if HAS_SBC_INTERFACE
551 || gb.IsSendRequested() || gb.IsExecutingOnSbc()
552#endif
553 ) || (gb.IsWaitingForTemperatures()) // this is needed to get reports sent when the GB is waiting for temperatures to be reached
554 )
555 {
556 CheckReportDue(gb, reply.GetRef());
557 }
558
559 return result;
560}
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.

Callers

nothing calls this directly

Calls 6

PopStateMethod · 0.80
UsingSbcInterfaceMethod · 0.80
AbortFileMethod · 0.80
GetStateMethod · 0.45
GetPreviousMethod · 0.45

Tested by

no test coverage detected