Try to queue the command in the passed GCodeBuffer. If successful, return true to indicate it has been queued. If the queue is full, return false. Caller will wait for space to become available.
| 105 | // If successful, return true to indicate it has been queued. |
| 106 | // If the queue is full, return false. Caller will wait for space to become available. |
| 107 | bool GCodeQueue::QueueCode(const GCodeBuffer &gb) noexcept |
| 108 | { |
| 109 | // Can we queue this code somewhere? |
| 110 | if (freeItems == nullptr) |
| 111 | { |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | // Unlink a free element and assign gb's code to it |
| 116 | QueuedCode * const code = _ecv_not_null(freeItems); |
| 117 | freeItems = code->next; |
| 118 | code->AssignFrom(gb); |
| 119 | code->executeAtMove = reprap.GetMove().GetScheduledMoves(); |
| 120 | code->next = nullptr; |
| 121 | |
| 122 | // Append it to the list of queued codes |
| 123 | if (queuedItems == nullptr) |
| 124 | { |
| 125 | queuedItems = code; |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | QueuedCode * last = _ecv_not_null(queuedItems); |
| 130 | while (last->Next() != nullptr) |
| 131 | { |
| 132 | last = _ecv_not_null(last->Next()); |
| 133 | } |
| 134 | last->next = code; |
| 135 | } |
| 136 | |
| 137 | return true; |
| 138 | } |
| 139 | |
| 140 | bool GCodeQueue::FillBuffer(GCodeBuffer *gb) noexcept |
| 141 | { |
no test coverage detected