Motion: Panic if queue is full
If the queue is full and a new move is queued, panic! Introduce a new error code QUEUE_FULL to help diagnose situations where the queue is handled improperly: likely one of the state machines not waiting for the previous actions to finish. PulseGen::PlanMove returns a boolean if the queue cannot be moved. We could extend this to Motion::PlanMove, however all moves would then have to check for this. Having a global check such as this ensures we never ignore such situation.pull/110/head
parent
ac78619b5b
commit
ee8c80e5c4
|
|
@ -28,8 +28,8 @@ enum class ErrorCode : uint_fast16_t {
|
|||
|
||||
INVALID_TOOL = 0x8006, ///< tool/slot index out of range (typically issuing T5 into an MMU with just 5 slots - valid range 0-4)
|
||||
|
||||
QUEUE_FULL = 0x802d, ///< internal logic error - attempt to move with a full queue
|
||||
MMU_NOT_RESPONDING = 0x802e, ///< internal error of the printer - communication with the MMU is not working
|
||||
|
||||
INTERNAL = 0x802f, ///< internal runtime error (software)
|
||||
|
||||
// TMC bit masks
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "motion.h"
|
||||
#include "panic.h"
|
||||
|
||||
// TODO: use proper timer abstraction
|
||||
#ifdef __AVR__
|
||||
|
|
@ -48,6 +49,9 @@ void Motion::PlanMoveTo(Axis axis, pos_t pos, steps_t feed_rate, steps_t end_rat
|
|||
// move was queued, prepare the axis
|
||||
if (!axisData[axis].enabled)
|
||||
SetEnabled(axis, true);
|
||||
} else {
|
||||
// queue is full: queue mishandling! trigger a panic
|
||||
Panic(ErrorCode::QUEUE_FULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
# common include and source directories
|
||||
set(include_common ${CMAKE_SOURCE_DIR}/src/modules ${CMAKE_SOURCE_DIR}/src/hal)
|
||||
set(include_common ${CMAKE_SOURCE_DIR}/src/modules ${CMAKE_SOURCE_DIR}/src/hal
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
)
|
||||
set(source_common
|
||||
${CMAKE_SOURCE_DIR}/src/modules/motion.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/modules/speed_table.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/modules/pulse_gen.cpp
|
||||
${MODULES_STUBS_DIR}/stub_gpio.cpp
|
||||
${MODULES_STUBS_DIR}/stub_panic.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/hal/tmc2130.cpp
|
||||
${MODULES_STUBS_DIR}/stub_shr16.cpp
|
||||
${MODULES_STUBS_DIR}/stub_spi.cpp
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
#include "panic.h"
|
||||
|
||||
// For retrival during tests
|
||||
ErrorCode panic_code = ErrorCode::RUNNING;
|
||||
|
||||
void Panic(ErrorCode ec) {
|
||||
panic_code = ec;
|
||||
}
|
||||
Loading…
Reference in New Issue