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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. /**
  23. * queue.h - The G-code command queue, which holds commands before they
  24. * go to the parser and dispatcher.
  25. */
  26. #ifndef GCODE_QUEUE_H
  27. #define GCODE_QUEUE_H
  28. #include "../inc/MarlinConfig.h"
  29. /**
  30. * GCode line number handling. Hosts may include line numbers when sending
  31. * commands to Marlin, and lines will be checked for sequentiality.
  32. * M110 N<int> sets the current line number.
  33. */
  34. extern long gcode_LastN, Stopped_gcode_LastN;
  35. /**
  36. * GCode Command Queue
  37. * A simple ring buffer of BUFSIZE command strings.
  38. *
  39. * Commands are copied into this buffer by the command injectors
  40. * (immediate, serial, sd card) and they are processed sequentially by
  41. * the main loop. The gcode.process_next_command method parses the next
  42. * command and hands off execution to individual handler functions.
  43. */
  44. extern uint8_t commands_in_queue, // Count of commands in the queue
  45. cmd_queue_index_r; // Ring buffer read position
  46. extern char command_queue[BUFSIZE][MAX_CMD_SIZE];
  47. /*
  48. * The port that the command was received on
  49. */
  50. #if NUM_SERIAL > 1
  51. extern int16_t command_queue_port[BUFSIZE];
  52. #endif
  53. /**
  54. * Initialization of queue for setup()
  55. */
  56. void queue_setup();
  57. /**
  58. * Clear the Marlin command queue
  59. */
  60. void clear_command_queue();
  61. /**
  62. * Clear the serial line and request a resend of
  63. * the next expected line number.
  64. */
  65. void flush_and_request_resend();
  66. /**
  67. * Send an "ok" message to the host, indicating
  68. * that a command was successfully processed.
  69. *
  70. * If ADVANCED_OK is enabled also include:
  71. * N<int> Line number of the command, if any
  72. * P<int> Planner space remaining
  73. * B<int> Block queue space remaining
  74. */
  75. void ok_to_send();
  76. /**
  77. * Record one or many commands to run from program memory.
  78. * Aborts the current queue, if any.
  79. * Note: drain_injected_commands_P() must be called repeatedly to drain the commands afterwards
  80. */
  81. void enqueue_and_echo_commands_P(const char * const pgcode);
  82. /**
  83. * Enqueue with Serial Echo
  84. */
  85. bool enqueue_and_echo_command(const char* cmd);
  86. #define HAS_LCD_QUEUE_NOW (ENABLED(MALYAN_LCD) || (ENABLED(ULTIPANEL) && (ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(PID_AUTOTUNE_MENU) || ENABLED(ADVANCED_PAUSE_FEATURE))))
  87. #define HAS_QUEUE_NOW (ENABLED(SDSUPPORT) || HAS_LCD_QUEUE_NOW)
  88. #if HAS_QUEUE_NOW
  89. /**
  90. * Enqueue and return only when commands are actually enqueued
  91. */
  92. void enqueue_and_echo_command_now(const char* cmd);
  93. #if HAS_LCD_QUEUE_NOW
  94. /**
  95. * Enqueue from program memory and return only when commands are actually enqueued
  96. */
  97. void enqueue_and_echo_commands_now_P(const char * const cmd);
  98. #endif
  99. #endif
  100. /**
  101. * Add to the circular command queue the next command from:
  102. * - The command-injection queue (injected_commands_P)
  103. * - The active serial input (usually USB)
  104. * - The SD card file being actively printed
  105. */
  106. void get_available_commands();
  107. /**
  108. * Get the next command in the queue, optionally log it to SD, then dispatch it
  109. */
  110. void advance_command_queue();
  111. #endif // GCODE_QUEUE_H