From 414f84a2ce16b2616141809368ef778329586551 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Thu, 6 Dec 2018 20:21:00 -0800 Subject: [PATCH] add dump errors util function --- CHANGELOG.md | 3 +++ docs/troubleshooting.md | 16 ++----------- tools/odrive/enums.py | 52 ++++++++++++++++++++++++++++++++--------- tools/odrive/shell.py | 5 ++-- tools/odrive/utils.py | 42 ++++++++++++++++++++++++++++++--- 5 files changed, 88 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d77a003e..6b001221 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Unreleased Features Please add a note of your changes below this heading if you make a Pull Request. +### Added +* `dump_errors()` utility function in odrivetool to dump, decode and optionally clear errors. + # Releases ## [0.4.7] - 2018-11-28 ### Added diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index c05c7f92..c5556d02 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -14,21 +14,9 @@ Table of Contents: ## Error codes -If your ODrive is not working as expected, run `odrivetool` and type `hex(.error)` Enter where `` is the axis that isn't working. This will display a [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) representation of the error code. Each bit represents one error flag. - -
Example
-Say you got this error output: -```python -In [1]: hex(odrv0.axis0.error) -Out[1]: '0x6' -``` - -Written in binary, the number `0x6` corresponds to `110`, that means bits 1 and 2 are set (counting starts at 0). -Looking at the reference below, this means that both `ERROR_DC_BUS_UNDER_VOLTAGE` and `ERROR_DC_BUS_OVER_VOLTAGE` occurred. -
- -The axis error may say that some other component has failed. Say it reports `ERROR_ENCODER_FAILED`, then you need to go check the encoder error: `hex(.encoder.error)`. +If your ODrive is not working as expected, run `odrivetool` and type `dump_errors(odrv0)` Enter. This will dump a list of all the errors that are present. To also clear all the errors, you can run `dump_errors(odrv0, True)`. +The following sections will give some guidance on the most common errors. You may also check the code for the full list of errors: * Axis error flags defined [here](../Firmware/MotorControl/axis.hpp). * Motor error flags defined [here](../Firmware/MotorControl/motor.hpp). * Encoder error flags defined [here](../Firmware/MotorControl/encoder.hpp). diff --git a/tools/odrive/enums.py b/tools/odrive/enums.py index 19572c90..26e0f816 100644 --- a/tools/odrive/enums.py +++ b/tools/odrive/enums.py @@ -11,17 +11,47 @@ AXIS_STATE_ENCODER_INDEX_SEARCH = 6 AXIS_STATE_ENCODER_OFFSET_CALIBRATION = 7 AXIS_STATE_CLOSED_LOOP_CONTROL = 8 -AXIS_ERROR_NONE = 0 -AXIS_ERROR_INVALID_STATE = 1 -#AXIS_ERROR_DC_BUS_UNDER_VOLTAGE = 2 -#AXIS_ERROR_DC_BUS_OVER_VOLTAGE = 3 -#AXIS_ERROR_CURRENT_MEASUREMENT_TIMEOUT = 4 -#AXIS_ERROR_CONTROL_LOOP_TIMEOUT = 5 -#AXIS_ERROR_MOTOR_FAILED = 6 -#AXIS_ERROR_SENSORLESS_ESTIMATOR_FAILED = 7 -#AXIS_ERROR_ENCODER_FAILED = 8 -#AXIS_ERROR_CONTROLLER_FAILED = 9 -#AXIS_ERROR_POS_CTRL_DURING_SENSORLESS = 10 +class errors: + class axis: + ERROR_NONE = 0x00 + ERROR_INVALID_STATE = 0x01 #