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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. * Initialization of queue for setup()
  49. */
  50. void queue_setup();
  51. /**
  52. * Clear the Marlin command queue
  53. */
  54. void clear_command_queue();
  55. /**
  56. * Clear the serial line and request a resend of
  57. * the next expected line number.
  58. */
  59. void flush_and_request_resend();
  60. /**
  61. * Send an "ok" message to the host, indicating
  62. * that a command was successfully processed.
  63. *
  64. * If ADVANCED_OK is enabled also include:
  65. * N<int> Line number of the command, if any
  66. * P<int> Planner space remaining
  67. * B<int> Block queue space remaining
  68. */
  69. void ok_to_send();
  70. /**
  71. * Record one or many commands to run from program memory.
  72. * Aborts the current queue, if any.
  73. * Note: drain_injected_commands_P() must be called repeatedly to drain the commands afterwards
  74. */
  75. void enqueue_and_echo_commands_P(const char * const pgcode);
  76. /**
  77. * Enqueue with Serial Echo
  78. */
  79. bool enqueue_and_echo_command(const char* cmd, bool say_ok=false);
  80. /**
  81. * Add to the circular command queue the next command from:
  82. * - The command-injection queue (injected_commands_P)
  83. * - The active serial input (usually USB)
  84. * - The SD card file being actively printed
  85. */
  86. void get_available_commands();
  87. /**
  88. * Get the next command in the queue, optionally log it to SD, then dispatch it
  89. */
  90. void advance_command_queue();
  91. #endif // GCODE_QUEUE_H