Fixed a couple of stupid bugs in new buffer management; Set make block profile to default to 2 USB ports

This commit is contained in:
Alden Hart
2016-12-08 12:27:29 -05:00
parent 2ab3183a82
commit dd0ff106ca
4 changed files with 56 additions and 88 deletions
+10 -41
View File
@@ -672,7 +672,7 @@ void mp_planner_time_accounting()
* Functions Provided:
* _clear_buffer(bf) Zero the contents of a buffer
*
* mp_init_buffers() Initialize or reset buffers
* mp_init_buffers() Initialize and reset buffers in all planner queues
*
* mp_get_prev_buffer(bf) Return pointer to the previous buffer in the linked list
* mp_get_next_buffer(bf) Return pointer to the next buffer in the linked list
@@ -706,13 +706,10 @@ void mp_planner_time_accounting()
// Also clears unlocked, so the buffer cannot be used
static inline void _clear_buffer(mpBuf_t *bf)
{
// Note: bf->bf_func is the first address we wish to clear as we must preserve
// the pointers and buffer number during interrupts
// We'll have to figure something else out for C, sorry.
bf->reset();
}
bf->reset(); // Call a reset method on the buffer object.
} // We'll need something else for C - like bring the method code back into this function.
// initialize a single planner queue
void _init_planner_queue(uint8_t q, mpBuf_t *pool, uint8_t size)
{
mpBuf_t *pv, *nx;
@@ -731,37 +728,15 @@ void _init_planner_queue(uint8_t q, mpBuf_t *pool, uint8_t size)
b->buffers_available = size;
pv = &b->bf[size-1];
for (i=0; i < size-1; i++) {
for (i=0; i < size; i++) {
b->bf[i].buffer_number = i; // number is for diagnostics only (otherwise not used)
nx_i = ((i<size-1) ? (i+1) : 0); // buffer increment & wrap
nx = &b->bf[nx_i];
b->bf[i].nx = nx; // setup circular list pointers
b->bf[i].pv = pv;
pv = &b->bf[i];
/*=======
//memset(&mb, 0, sizeof(mb)); // clear all values, pointers and status
mb.magic_start = MAGICNUM;
mb.magic_end = MAGICNUM;
mb.w = &mb.bf[0]; // init all buffer pointers
mb.r = &mb.bf[0];
pv = &mb.bf[PLANNER_BUFFER_POOL_SIZE-1];
for (uint8_t i=0; i < PLANNER_BUFFER_POOL_SIZE; i++) {
_clear_buffer(&mb.bf[i]);
uint8_t nx_i = ((i<(PLANNER_BUFFER_POOL_SIZE-1))?(i+1):0); // buffer incr & wrap
mb.bf[i].buffer_number = i; //+++++ number it for diagnostics only (otherwise not used)
nx = &mb.bf[nx_i];
mb.bf[i].nx = nx; // setup ring pointers
mb.bf[i].pv = pv;
pv = &mb.bf[i];
>>refs/heads/dev-168-gquadratic
*/
}
b->bf[size-1].nx = pool;
}
void mp_init_buffers(void)
@@ -777,7 +752,6 @@ void mp_init_buffers(void)
/*
* These GET functions are defined here but we use the macros in planner.h instead
*
mpBuf_t * mp_get_prev_buffer(const mpBuf_t *bf) { return (bf->pv); }
mpBuf_t * mp_get_next_buffer(const mpBuf_t *bf) { return (bf->nx); }
*/
@@ -828,9 +802,8 @@ void mp_commit_write_buffer(const blockType block_type)
}
} else {
if ((mp.planner_state > PLANNER_STARTUP) && (cm.hold_state == FEEDHOLD_OFF)) {
// NB: BEWARE! the exec may result in the planner buffer being
// NB: BEWARE! the requested exec may result in the planner buffer being
// processed IMMEDIATELY and then freed - invalidating the contents
// st_request_plan_move(); // ++++ request an exec if the runtime is not busy
st_request_forward_plan(); // request an exec if the runtime is not busy
}
}
@@ -860,16 +833,16 @@ mpBuf_t * mp_get_run_buffer()
bool mp_free_run_buffer() // EMPTY current run buffer & advance to the next
{
mpQueue_t *q = &mb.q[mb.active_q];
mpBuf_t *r_now = q->r; // this is to avoid a race condition when clearing the buffer
_audit_buffers(); // ++++diagnostic audit for buffer chain integrity (only runs in DEBUG mode)
q->r = q->r->nx; // advance to next run buffer
_clear_buffer(q->r); // clear it out (& reset unlocked and set MP_BUFFER_EMPTY)
_clear_buffer(r_now); // clear out the old buffer (& reset unlocked and set MP_BUFFER_EMPTY)
q->buffers_available++;
qr_request_queue_report(-1); // request a QR and add to the "removed buffers" count
return (q->w == q->r); // return true if the queue emptied
}
/* UNUSED FUNCTIONS - left in for completeness and for reference
@@ -926,8 +899,6 @@ void mp_dump_planner(mpBuf_t *bf_start) // starting at bf
#warning DEBUG TRAPS ENABLED
#pragma GCC optimize ("O0")
//static void _planner_report(const char *msg)
//{
// rpt_exception(STAT_PLANNER_ASSERTION_FAILURE, msg);
@@ -1030,8 +1001,6 @@ static void _audit_buffers()
__enable_irq();
}
#pragma GCC reset_options
#else
static void _audit_buffers()
+5 -6
View File
@@ -308,7 +308,6 @@ typedef enum {
*/
struct mpBuffer_to_clear {
// Note: _clear_buffer() zeros all data from this point down
stat_t (*bf_func)(struct mpBuffer *bf); // callback to buffer exec function
cm_exec_t cm_func; // callback to canonical machine execution function
@@ -336,10 +335,9 @@ struct mpBuffer_to_clear {
float block_time; // computed move time for entire block (move)
float override_factor; // feed rate or rapid override factor for this block ("override" is a reserved word)
// We are removing all entry_* values.
// To get the entry_* values, look at pv->exit_* or mr.exit_*
// *** SEE NOTES ON THESE VARIABLES, in aline() ***
// We removed all entry_* values.
// To get the entry_* values, look at pv->exit_* or mr.exit_*
float cruise_velocity; // cruise velocity requested & achieved
float exit_velocity; // exit velocity requested for the move
// is also the entry velocity of the *next* move
@@ -361,9 +359,10 @@ struct mpBuffer_to_clear {
GCodeState_t gm; // Gcode model state - passed from model, used by planner and runtime
// cleasr the above structure
void reset() {
//memset((void *)(this), 0, sizeof(mpBuffer_to_clear));
//memset((void *)(this), 0, sizeof(mpBuffer_to_clear)); // slower on the M3. Test for M7
bf_func = nullptr;
cm_func = nullptr;
+8 -9
View File
@@ -58,11 +58,6 @@
// *** Machine configuration settings *** //
#ifndef USB_SERIAL_PORTS_EXPOSED
#define USB_SERIAL_PORTS_EXPOSED 1 // Valid options are 1 or 2, only!
#endif
#ifndef JUNCTION_INTEGRATION_TIME
#define JUNCTION_INTEGRATION_TIME 0.75 // {jt: cornering - between 0.05 and 2.00 (max)
#endif
@@ -129,16 +124,20 @@
// *** Communications and Reporting Settings *** //
#ifndef TEXT_VERBOSITY
#define TEXT_VERBOSITY TV_VERBOSE // {tv: TV_SILENT, TV_VERBOSE
#ifndef USB_SERIAL_PORTS_EXPOSED
#define USB_SERIAL_PORTS_EXPOSED 1 // Valid options are 1 or 2, only!
#endif
#ifndef XIO_ENABLE_FLOW_CONTROL
#define XIO_ENABLE_FLOW_CONTROL FLOW_CONTROL_RTS // {ex: FLOW_CONTROL_OFF, FLOW_CONTROL_XON, FLOW_CONTROL_RTS
#endif
#ifndef COMM_MODE
#define COMM_MODE JSON_MODE // {ej: TEXT_MODE, JSON_MODE
#endif
#ifndef XIO_ENABLE_FLOW_CONTROL
#define XIO_ENABLE_FLOW_CONTROL FLOW_CONTROL_RTS // FLOW_CONTROL_OFF, FLOW_CONTROL_XON, FLOW_CONTROL_RTS
#ifndef TEXT_VERBOSITY
#define TEXT_VERBOSITY TV_VERBOSE // {tv: TV_SILENT, TV_VERBOSE
#endif
#ifndef JSON_VERBOSITY
+33 -32
View File
@@ -34,24 +34,25 @@
// Machine configuration settings
#define JUNCTION_INTEGRATION_TIME 0.75 // cornering - between 0.10 and 2.00 (higher is faster)
#define CHORDAL_TOLERANCE 0.1 // chordal tolerance for arcs (in mm)
#define JUNCTION_INTEGRATION_TIME 0.75 // cornering - between 0.10 and 2.00 (higher is faster)
#define CHORDAL_TOLERANCE 0.1 // chordal tolerance for arcs (in mm)
#define SOFT_LIMIT_ENABLE 0 // 0=off, 1=on
#define HARD_LIMIT_ENABLE 0 // 0=off, 1=on
#define SAFETY_INTERLOCK_ENABLE 1 // 0=off, 1=on
#define SOFT_LIMIT_ENABLE 0 // 0=off, 1=on
#define HARD_LIMIT_ENABLE 0 // 0=off, 1=on
#define SAFETY_INTERLOCK_ENABLE 1 // 0=off, 1=on
#define SPINDLE_ENABLE_POLARITY 1 // 0=active low, 1=active high
#define SPINDLE_DIR_POLARITY 0 // 0=clockwise is low, 1=clockwise is high
#define SPINDLE_ENABLE_POLARITY 1 // 0=active low, 1=active high
#define SPINDLE_DIR_POLARITY 0 // 0=clockwise is low, 1=clockwise is high
#define SPINDLE_PAUSE_ON_HOLD true
#define SPINDLE_DWELL_TIME 1.0
#define COOLANT_MIST_POLARITY 1 // 0=active low, 1=active high
#define COOLANT_FLOOD_POLARITY 1 // 0=active low, 1=active high
#define COOLANT_MIST_POLARITY 1 // 0=active low, 1=active high
#define COOLANT_FLOOD_POLARITY 1 // 0=active low, 1=active high
#define COOLANT_PAUSE_ON_HOLD false
// Communications and reporting settings
#define USB_SERIAL_PORTS_EXPOSED 2 // Valid options are 1 or 2, only!
#define COMM_MODE JSON_MODE // one of: TEXT_MODE, JSON_MODE
#define TEXT_VERBOSITY TV_VERBOSE // one of: TV_SILENT, TV_VERBOSE
@@ -59,8 +60,8 @@
#define QUEUE_REPORT_VERBOSITY QR_OFF // one of: QR_OFF, QR_SINGLE, QR_TRIPLE
#define STATUS_REPORT_VERBOSITY SR_FILTERED // one of: SR_OFF, SR_FILTERED, SR_VERBOSE
#define STATUS_REPORT_MIN_MS 100 // milliseconds - enforces a viable minimum
#define STATUS_REPORT_INTERVAL_MS 250 // milliseconds - set $SV=0 to disable
#define STATUS_REPORT_MIN_MS 100 // milliseconds - enforces a viable minimum
#define STATUS_REPORT_INTERVAL_MS 250 // milliseconds - set $SV=0 to disable
//#define STATUS_REPORT_DEFAULTS
//"line","posx","posy","posz","posa","bcr","feed","vel","unit","coor","dist","admo","frmo","momo","stat"
@@ -81,14 +82,14 @@
// *** motor settings ************************************************************************************
#define MOTOR_POWER_MODE MOTOR_POWERED_IN_CYCLE // default motor power mode (see cmMotorPowerMode in stepper.h)
#define MOTOR_POWER_TIMEOUT 2.00 // motor power timeout in seconds
#define MOTOR_POWER_TIMEOUT 2.00 // motor power timeout in seconds
#define M1_MOTOR_MAP AXIS_X // 1ma
#define M1_STEP_ANGLE 1.8 // 1sa
#define M1_TRAVEL_PER_REV 36.576 // 1tr 2.032mm pitch * 18 teeth per revolution
#define M1_MICROSTEPS 8 // 1mi 1,2,4,8
#define M1_POLARITY 0 // 1po 0=normal, 1=reversed
#define M1_POWER_MODE MOTOR_POWER_MODE // 1pm TRUE=low power idle enabled
#define M1_MOTOR_MAP AXIS_X // 1ma
#define M1_STEP_ANGLE 1.8 // 1sa
#define M1_TRAVEL_PER_REV 36.576 // 1tr 2.032mm pitch * 18 teeth per revolution
#define M1_MICROSTEPS 8 // 1mi 1,2,4,8
#define M1_POLARITY 0 // 1po 0=normal, 1=reversed
#define M1_POWER_MODE MOTOR_POWER_MODE // 1pm TRUE=low power idle enabled
#define M1_POWER_LEVEL 0.4
#define M2_MOTOR_MAP AXIS_Y
@@ -99,7 +100,7 @@
#define M2_POWER_MODE MOTOR_POWER_MODE
#define M2_POWER_LEVEL 0.4
#define M3_MOTOR_MAP AXIS_Z // Imaginary Z axis. FOr testing
#define M3_MOTOR_MAP AXIS_Z // Imaginary Z axis. For testing
#define M3_STEP_ANGLE 1.8
#define M3_TRAVEL_PER_REV 1.25
#define M3_MICROSTEPS 8
@@ -111,19 +112,19 @@
#define JERK_MAX 5000
#define X_AXIS_MODE AXIS_STANDARD // xam see canonical_machine.h cmAxisMode for valid values
#define X_VELOCITY_MAX 40000 // xvm G0 max velocity in mm/min
#define X_FEEDRATE_MAX X_VELOCITY_MAX // xfr G1 max feed rate in mm/min
#define X_TRAVEL_MIN 0 // xtn minimum travel for soft limits
#define X_TRAVEL_MAX 420 // xtm travel between switches or crashes
#define X_JERK_MAX JERK_MAX // xjm jerk * 1,000,000
#define X_JERK_HIGH_SPEED 20000 // xjh
#define X_HOMING_INPUT 1 // xhi input used for homing or 0 to disable
#define X_HOMING_DIRECTION 0 // xhd 0=search moves negative, 1= search moves positive
#define X_SEARCH_VELOCITY 3000 // xsv minus means move to minimum switch
#define X_LATCH_VELOCITY 100 // xlv mm/min
#define X_LATCH_BACKOFF 4 // xlb mm
#define X_ZERO_BACKOFF 2 // xzb mm
#define X_AXIS_MODE AXIS_STANDARD // xam see canonical_machine.h cmAxisMode for valid values
#define X_VELOCITY_MAX 40000 // xvm G0 max velocity in mm/min
#define X_FEEDRATE_MAX X_VELOCITY_MAX // xfr G1 max feed rate in mm/min
#define X_TRAVEL_MIN 0 // xtn minimum travel for soft limits
#define X_TRAVEL_MAX 420 // xtm travel between switches or crashes
#define X_JERK_MAX JERK_MAX // xjm jerk * 1,000,000
#define X_JERK_HIGH_SPEED 20000 // xjh
#define X_HOMING_INPUT 1 // xhi input used for homing or 0 to disable
#define X_HOMING_DIRECTION 0 // xhd 0=search moves negative, 1= search moves positive
#define X_SEARCH_VELOCITY 3000 // xsv minus means move to minimum switch
#define X_LATCH_VELOCITY 100 // xlv mm/min
#define X_LATCH_BACKOFF 4 // xlb mm
#define X_ZERO_BACKOFF 2 // xzb mm
#define Y_AXIS_MODE AXIS_STANDARD
#define Y_VELOCITY_MAX 40000