From cbc23de7b7f456778fd0909d27b5776dc8abbbab Mon Sep 17 00:00:00 2001 From: Paul Guenette Date: Mon, 8 Jul 2019 23:07:47 +0200 Subject: [PATCH] Add axis.clear_errors() function --- Firmware/MotorControl/axis.hpp | 11 ++++++++++- Firmware/communication/can_simple.cpp | 7 +------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Firmware/MotorControl/axis.hpp b/Firmware/MotorControl/axis.hpp index 2f100d83..776e4e02 100644 --- a/Firmware/MotorControl/axis.hpp +++ b/Firmware/MotorControl/axis.hpp @@ -134,6 +134,14 @@ public: void watchdog_feed(); bool watchdog_check(); + void clear_errors() { + motor_.error_ = Motor::ERROR_NONE; + controller_.error_ = Controller::ERROR_NONE; + sensorless_estimator_.error_ = SensorlessEstimator::ERROR_NONE; + encoder_.error_ = Encoder::ERROR_NONE; + + error_ = Axis::ERROR_NONE; + } // True if there are no errors bool inline check_for_errors() { @@ -311,7 +319,8 @@ public: make_protocol_object("trap_traj", trap_.make_protocol_definitions()), make_protocol_object("min_endstop", min_endstop_.make_protocol_definitions()), make_protocol_object("max_endstop", max_endstop_.make_protocol_definitions()), - make_protocol_function("watchdog_feed", *this, &Axis::watchdog_feed) + make_protocol_function("watchdog_feed", *this, &Axis::watchdog_feed), + make_protocol_function("clear_errors", *this, &Axis::clear_errors) ); } }; diff --git a/Firmware/communication/can_simple.cpp b/Firmware/communication/can_simple.cpp index e043920e..62d9306f 100644 --- a/Firmware/communication/can_simple.cpp +++ b/Firmware/communication/can_simple.cpp @@ -379,12 +379,7 @@ void CANSimple::get_vbus_voltage_callback(Axis* axis, can_Message_t& msg) { } void CANSimple::clear_errors_callback(Axis* axis, can_Message_t& msg) { - axis->motor_.error_ = Motor::ERROR_NONE; - axis->controller_.error_ = Controller::ERROR_NONE; - axis->sensorless_estimator_.error_ = SensorlessEstimator::ERROR_NONE; - axis->encoder_.error_ = Encoder::ERROR_NONE; - - axis->error_ = Axis::ERROR_NONE; + axis->clear_errors(); } void CANSimple::send_heartbeat(Axis* axis) {