My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

queue.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * queue.h - The G-code command queue, which holds commands before they
  25. * go to the parser and dispatcher.
  26. */
  27. #include "../inc/MarlinConfig.h"
  28. /**
  29. * GCode line number handling. Hosts may include line numbers when sending
  30. * commands to Marlin, and lines will be checked for sequentiality.
  31. * M110 N<int> sets the current line number.
  32. */
  33. extern long gcode_LastN, Stopped_gcode_LastN;
  34. /**
  35. * GCode Command Queue
  36. * A simple ring buffer of BUFSIZE command strings.
  37. *
  38. * Commands are copied into this buffer by the command injectors
  39. * (immediate, serial, sd card) and they are processed sequentially by
  40. * the main loop. The gcode.process_next_command method parses the next
  41. * command and hands off execution to individual handler functions.
  42. */
  43. extern uint8_t commands_in_queue, // Count of commands in the queue
  44. cmd_queue_index_r; // Ring buffer read position
  45. extern char command_queue[BUFSIZE][MAX_CMD_SIZE];
  46. /*
  47. * The port that the command was received on
  48. */
  49. #if NUM_SERIAL > 1
  50. extern int16_t command_queue_port[BUFSIZE];
  51. #endif
  52. /**
  53. * Initialization of queue for setup()
  54. */
  55. void queue_setup();
  56. /**
  57. * Clear the Marlin command queue
  58. */
  59. void clear_command_queue();
  60. /**
  61. * Clear the serial line and request a resend of
  62. * the next expected line number.
  63. */
  64. void flush_and_request_resend();
  65. /**
  66. * Send an "ok" message to the host, indicating
  67. * that a command was successfully processed.
  68. *
  69. * If ADVANCED_OK is enabled also include:
  70. * N<int> Line number of the command, if any
  71. * P<int> Planner space remaining
  72. * B<int> Block queue space remaining
  73. */
  74. void ok_to_send();
  75. /**
  76. * Record one or many commands to run from program memory.
  77. * Aborts the current queue, if any.
  78. * Note: drain_injected_commands_P() must be called repeatedly to drain the commands afterwards
  79. */
  80. void enqueue_and_echo_commands_P(PGM_P const pgcode);
  81. /**
  82. * Enqueue with Serial Echo
  83. */
  84. bool enqueue_and_echo_command(const char* cmd);
  85. #define HAS_LCD_QUEUE_NOW (ENABLED(MALYAN_LCD) || (HAS_LCD_MENU && (ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(PID_AUTOTUNE_MENU) || ENABLED(ADVANCED_PAUSE_FEATURE))))
  86. #define HAS_QUEUE_NOW (ENABLED(SDSUPPORT) || HAS_LCD_QUEUE_NOW)
  87. #if HAS_QUEUE_NOW
  88. /**
  89. * Enqueue and return only when commands are actually enqueued
  90. */
  91. void enqueue_and_echo_command_now(const char* cmd);
  92. #if HAS_LCD_QUEUE_NOW
  93. /**
  94. * Enqueue from program memory and return only when commands are actually enqueued
  95. */
  96. void enqueue_and_echo_commands_now_P(PGM_P const cmd);
  97. #endif
  98. #endif
  99. /**
  100. * Add to the circular command queue the next command from:
  101. * - The command-injection queue (injected_commands_P)
  102. * - The active serial input (usually USB)
  103. * - The SD card file being actively printed
  104. */
  105. void get_available_commands();
  106. /**
  107. * Get the next command in the queue, optionally log it to SD, then dispatch it
  108. */
  109. void advance_command_queue();