Fixed some naming on the debug traps; changed detection threshold for “zero length moves” from 1/100 micron to 1/10th micron

This commit is contained in:
Alden Hart
2017-02-20 10:50:34 -05:00
parent 5810eda239
commit 5363980d9f
7 changed files with 33 additions and 34 deletions
+1 -1
View File
@@ -230,7 +230,7 @@ stat_t cm_shutdown(const stat_t status, const char *msg)
stat_t cm_panic(const stat_t status, const char *msg)
{
__debug_trap(msg);
debug_trap(msg);
if (cm->machine_state == MACHINE_PANIC) { // only do this once
return (STAT_OK);
+2 -2
View File
@@ -73,7 +73,7 @@
<InterfaceName>SWD</InterfaceName>
</ToolOptions>
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
<ToolNumber>J41800036434</ToolNumber>
<ToolNumber>J41800030015</ToolNumber>
<ToolName>Atmel-ICE</ToolName>
</com_atmel_avrdbg_tool_atmelice>
<UseGdb>True</UseGdb>
@@ -100,7 +100,7 @@
<HWProgramCounterSampling>True</HWProgramCounterSampling>
</PercepioTrace>
<preserveEEPROM>true</preserveEEPROM>
<avrtoolserialnumber>J41800036434</avrtoolserialnumber>
<avrtoolserialnumber>J41800030015</avrtoolserialnumber>
<avrdeviceexpectedsignature>0x284E0A60</avrdeviceexpectedsignature>
<avrtoolinterfaceclock>10000000</avrtoolinterfaceclock>
<custom>
+13 -14
View File
@@ -166,10 +166,10 @@ static stat_t _plan_aline(mpBuf_t *bf, float entry_velocity)
mpBlockRuntimeBuf_t* block = mr->p; // set a local planning block so it doesn't change on you
mp_calculate_ramps(block, bf, entry_velocity); // (which it will if you don't do this)
__debug_trap_if_true((block->exit_velocity > block->cruise_velocity),
debug_trap_if_true((block->exit_velocity > block->cruise_velocity),
"_plan_line() exit velocity > cruise velocity after calculate_ramps()");
__debug_trap_if_true((block->head_length < 0.00001 && block->body_length < 0.00001 && block->tail_length < 0.00001),
debug_trap_if_true((block->head_length < 0.00001 && block->body_length < 0.00001 && block->tail_length < 0.00001),
"_plan_line() zero or negative length block after calculate_ramps()");
bf->buffer_state = MP_BUFFER_PLANNED; //...here
@@ -256,28 +256,28 @@ stat_t mp_exec_move()
// first-time operations
if (bf->buffer_state != MP_BUFFER_RUNNING) {
if ((bf->buffer_state < MP_BUFFER_PREPPED) && (cm->motion_state == MOTION_RUN)) {
__debug_trap("mp_exec_move() buffer is not prepped"); // IMPORTANT: can't rpt_exception from here!
debug_trap("mp_exec_move() buffer is not prepped. Starvation"); // IMPORTANT: can't rpt_exception from here!
st_prep_null();
return (STAT_NOOP);
}
if (bf->nx->buffer_state < MP_BUFFER_PREPPED) {
if ((bf->nx->buffer_state < MP_BUFFER_PREPPED) && (bf->nx->buffer_state > MP_BUFFER_EMPTY)) {
// This detects buffer starvation, but also can be a single-line "jog" or command
// rpt_exception(42, "mp_exec_move() next buffer is empty");
// ^^^ CAUSES A CRASH. We can't rpt_exception from here!
debug_trap("mp_exec_move() no buffer prepped - starvation");
}
if (bf->buffer_state == MP_BUFFER_PREPPED) {
if (cm->motion_state == MOTION_RUN) {
__debug_trap("mp_exec_move() don't have a block planned"); // IMPORTANT: can't rpt_exception from here!
}
// We need to have it planned. We don't want to do this here, as it
// might already be happening in a lower interrupt.
debug_trap_if_true((cm->motion_state == MOTION_RUN), "mp_exec_move() buffer prepped but not planned");
// IMPORTANT: can't rpt_exception from here!
// We need to have it planned. We don't want to do this here,
// as it might already be happening in a lower interrupt.
st_request_forward_plan();
return (STAT_NOOP);
}
if (bf->buffer_state == MP_BUFFER_PLANNED) {
bf->buffer_state = MP_BUFFER_RUNNING; // must precede mp_planner_time_acccounting()
bf->buffer_state = MP_BUFFER_RUNNING; // must precede mp_planner_time_acccounting()
} else {
return (STAT_NOOP);
}
@@ -289,7 +289,6 @@ stat_t mp_exec_move()
// (and have called mp_exec_aline via bf->bf_func).
// This also allows mp_exec_aline to advance mr->p first.
if (bf->nx->buffer_state >= MP_BUFFER_PREPPED) {
// if (bf->nx->buffer_state == MP_BUFFER_PREPPED) {
st_request_forward_plan();
}
@@ -877,7 +876,7 @@ static stat_t _exec_aline_head(mpBuf_t *bf)
_init_forward_diffs(mr->entry_velocity, mr->r->cruise_velocity); // <-- sets inital segment_velocity
}
if (mr->segment_time < MIN_SEGMENT_TIME) {
__debug_trap("mr->segment_time < MIN_SEGMENT_TIME (head)");
debug_trap("mr->segment_time < MIN_SEGMENT_TIME (head)");
return(STAT_OK); // exit without advancing position, say we're done
}
mr->section = SECTION_HEAD;
@@ -922,7 +921,7 @@ static stat_t _exec_aline_body(mpBuf_t *bf)
mr->segment_velocity = mr->r->cruise_velocity;
mr->segment_count = (uint32_t)mr->segments;
if (mr->segment_time < MIN_SEGMENT_TIME) {
__debug_trap("mr->segment_time < MIN_SEGMENT_TIME (body)");
debug_trap("mr->segment_time < MIN_SEGMENT_TIME (body)");
return(STAT_OK); // exit without advancing position, say we're done
}
@@ -963,7 +962,7 @@ static stat_t _exec_aline_tail(mpBuf_t *bf)
_init_forward_diffs(mr->r->cruise_velocity, mr->r->exit_velocity); // <-- sets inital segment_velocity
}
if (mr->segment_time < MIN_SEGMENT_TIME) {
__debug_trap("mr->segment_time < MIN_SEGMENT_TIME (tail)");
debug_trap("mr->segment_time < MIN_SEGMENT_TIME (tail)");
return(STAT_OK); // exit without advancing position, say we're done
// return(STAT_MINIMUM_TIME_MOVE); // exit without advancing position
}
+2 -2
View File
@@ -200,8 +200,8 @@ stat_t mp_aline(GCodeState_t* gm_in)
length = sqrt(length_square);
// exit if the move has zero movement. At all.
// if (fp_ZERO(length)) {
if (length < 0.00002) { // this value is 2x EPSILON and prevents trap failures in _plan_aline()
// if (length < 0.00002) { // this value is 2x EPSILON and prevents trap failures in _plan_aline()
if (length < 0.0001) { // this value is 0.1 microns. Prevents planner trap failures
sr_request_status_report(SR_REQUEST_TIMED_FULL); // Was SR_REQUEST_IMMEDIATE_FULL
return (STAT_MINIMUM_LENGTH_MOVE); // STAT_MINIMUM_LENGTH_MOVE needed to end cycle
}
+3 -3
View File
@@ -125,8 +125,8 @@ stat_t mp_calculate_ramps(mpBlockRuntimeBuf_t* block, mpBuf_t* bf, const float e
bf->hint = COMMAND_BLOCK;
return (STAT_NOOP); // NOOP status is informative, not actionable
}
__debug_trap_if_zero(bf->length, "mp_calculate_ramps() - got L=0");
__debug_trap_if_zero(bf->cruise_velocity, "mp_calculate_ramps() - got Vc=0");
debug_trap_if_zero(bf->length, "mp_calculate_ramps() - got L=0");
debug_trap_if_zero(bf->cruise_velocity, "mp_calculate_ramps() - got Vc=0");
// Timings from *here*
@@ -303,7 +303,7 @@ stat_t mp_calculate_ramps(mpBlockRuntimeBuf_t* block, mpBuf_t* bf, const float e
// Rate-limited asymmetric cases (3)
// compute meet velocity to see if the cruise velocity rises above the entry and/or exit velocities
block->cruise_velocity = _get_meet_velocity(entry_velocity, block->exit_velocity, bf->length, bf, block);
__debug_trap_if_zero(block->cruise_velocity, "mp_calculate_ramps() Vc=0 asymmetric HT case");
debug_trap_if_zero(block->cruise_velocity, "mp_calculate_ramps() Vc=0 asymmetric HT case");
// We now store the head/tail lengths we computed in _get_meet_velocity.
// treat as a full up and down (head and tail)
+7 -7
View File
@@ -190,28 +190,28 @@ inline T avg(const T a,const T b) {return (a+b)/2; }
*/
/*
* _debug_trap() - trap unconditionally
* _debug_trap_if_zero() - trap if floating point value is zero
* _debug_trap_if_true() - trap if condition is true
* debug_trap() - trap unconditionally
* debug_trap_if_zero() - trap if floating point value is zero
* debug_trap_if_true() - trap if condition is true
*
* The 'reason' value will display in GDB (but maybe not in AS7), and can also be passed
* to a downstream logger if these are introduced into the function.
*
* Note that it may be possible to print or generate exceptions in _debug_trap(), but
* Note that it may be possible to print or generate exceptions in debug_trap(), but
* it MIGHT interrupt other output, or might have been called deep in an ISR,
* so we had better just _NOP() and hope for the best.
*/
#pragma GCC push_options
#pragma GCC optimize ("O0")
inline void __debug_trap(const char *reason) {
inline void debug_trap(const char *reason) {
__NOP();
#if IN_DEBUGGER == 1
__asm__("BKPT");
#endif
}
inline void __debug_trap_if_zero(float value, const char *reason) {
inline void debug_trap_if_zero(float value, const char *reason) {
if (fp_ZERO(value)) {
__NOP();
#if IN_DEBUGGER == 1
@@ -220,7 +220,7 @@ inline void __debug_trap_if_zero(float value, const char *reason) {
}
}
inline void __debug_trap_if_true(bool condition, const char *reason) {
inline void debug_trap_if_true(bool condition, const char *reason) {
if (condition) {
__NOP();
#if IN_DEBUGGER == 1
+5 -5
View File
@@ -600,7 +600,7 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> {
char c = _data[_scan_offset];
if (c == 0) {
__debug_trap("_scanBuffer() scan ran into NULL");
debug_trap("_scanBuffer() scan ran into NULL");
flush(); // consider the connection and all data trashed
return false;
}
@@ -747,14 +747,14 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> {
// Either way, _scan_offset is one past the end, so we don't care which.
if (_data[_line_start_offset] == 0) {
__debug_trap("readline() read ran into NULL");
debug_trap("readline() read ran into NULL");
}
// scan past any leftover CR or LF from the previous line
while ((_data[_line_start_offset] == '\n') || (_data[_line_start_offset] == '\r')) {
_line_start_offset = (_line_start_offset+1)&(_size-1);
if (_scan_offset == _line_start_offset) {
__debug_trap("readline() read ran into scan (1)");
debug_trap("readline() read ran into scan (1)");
}
}
@@ -802,7 +802,7 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> {
if (_data[_read_offset] == 0) {
__debug_trap("readline() read ran into NULL");
debug_trap("readline() read ran into NULL");
}
// scan past any leftover CR or LF from the previous line
@@ -810,7 +810,7 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> {
while ((c == '\n') || (c == '\r')) {
_read_offset = (_read_offset+1)&(_size-1);
if (_scan_offset == _read_offset) {
__debug_trap("readline() read ran into scan (2)");
debug_trap("readline() read ran into scan (2)");
}
// this also counts as the beginning of a line
_skip_sections.skip(_read_offset);