MCPcopy Create free account
hub / github.com/MarlinFirmware/Marlin / advance

Method advance

Marlin/src/gcode/queue.cpp:641–706  ·  view source on GitHub ↗

* Get the next command in the queue, optionally log it to SD, then dispatch it */

Source from the content-addressed store, hash-verified

639 * Get the next command in the queue, optionally log it to SD, then dispatch it
640 */
641void GCodeQueue::advance() {
642
643 // Process immediate commands
644 if (process_injected_command_P() || process_injected_command()) return;
645
646 // Return if the G-code buffer is empty
647 if (ring_buffer.empty()) {
648 #if ENABLED(BUFFER_MONITORING)
649 if (!command_buffer_empty) {
650 command_buffer_empty = true;
651 command_buffer_underruns++;
652 command_buffer_empty_at = millis();
653 }
654 #endif
655 return;
656 }
657
658 #if ENABLED(BUFFER_MONITORING)
659 if (command_buffer_empty) {
660 command_buffer_empty = false;
661 const millis_t command_buffer_empty_duration = millis() - command_buffer_empty_at;
662 NOLESS(max_command_buffer_empty_duration, command_buffer_empty_duration);
663 }
664 #endif
665
666 #if HAS_MEDIA
667
668 if (card.flag.saving) {
669 char * const cmd = ring_buffer.peek_next_command_string();
670 if (is_M29(cmd)) {
671 // M29 closes the file
672 card.closefile();
673 SERIAL_ECHOLNPGM(STR_FILE_SAVED);
674
675 #if !defined(__AVR__) || !defined(USBCON)
676 #if ENABLED(SERIAL_STATS_DROPPED_RX)
677 SERIAL_ECHOLNPGM("Dropped bytes: ", MYSERIAL1.dropped());
678 #endif
679 #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
680 SERIAL_ECHOLNPGM("Max RX Queue Size: ", MYSERIAL1.rxMaxEnqueued());
681 #endif
682 #endif
683
684 ok_to_send();
685 }
686 else {
687 // Write the string from the read buffer to SD
688 card.write_command(cmd);
689 if (card.flag.logging)
690 gcode.process_next_command(); // The card is saving because it's logging
691 else
692 ok_to_send();
693 }
694 }
695 else
696 gcode.process_next_command();
697
698 #else

Callers 2

loopFunction · 0.80
chart.min.jsFile · 0.80

Calls 11

NOLESSFunction · 0.85
is_M29Function · 0.85
closefileMethod · 0.80
write_commandMethod · 0.80
process_next_commandMethod · 0.80
advance_rMethod · 0.80
millisFunction · 0.50
emptyMethod · 0.45
droppedMethod · 0.45
rxMaxEnqueuedMethod · 0.45

Tested by

no test coverage detected