-/*
+/*
This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl) with additions from Sungeun K. Jeon (https://github.com/chamnit/grbl)
Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
*/
using namespace std;
// Clean up the vector of commands in the block we are about to replace
// It is quite strange to do this here, we really should do it inside Block->pop_and_execute_gcode
// but that function is called inside an interrupt and thus can break everything if the interrupt was trigerred during a memory access
- //Block* block = this->queue.get_ref( this->queue.size()-1 );
+
+ // Take the next untaken block on the queue ( the one after the last one )
Block* block = this->queue.get_ref( this->queue.size() );
+ // Then clean it up
if( block->player == this ){
- for(short index=0; index<block->gcodes.size(); index++){
- block->gcodes.pop_back();
- }
+ for(unsigned int index=0; index<block->gcodes.size(); index++){
+ block->gcodes.pop_back();
+ }
}
- // Create a new virgin Block in the queue
+ // Create a new virgin Block in the queue
this->queue.push_back(Block());
block = this->queue.get_ref( this->queue.size()-1 );
+ while( block == NULL ){
+ block = this->queue.get_ref( this->queue.size()-1 );
+ }
block->is_ready = false;
block->initial_rate = -2;
block->final_rate = -2;
if( this->current_block != NULL ){ this->looking_for_new_block = false; return; }
- // Return if queue is empty
+ // Return if queue is empty
if( this->queue.size() == 0 ){
- this->current_block = NULL;
- // TODO : ON_QUEUE_EMPTY event
+ this->current_block = NULL;
+ // TODO : ON_QUEUE_EMPTY event
this->looking_for_new_block = false;
- return;
+ return;
}
// Get a new block