From 414f45ede2d999d93082a5aca9888581cb71d391 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 3 Dec 2017 18:17:59 -0500 Subject: [PATCH] softer error handling --- firmware/controllers/algo/obd_error_codes.h | 10 +++++----- firmware/controllers/core/fsio_core.cpp | 2 +- firmware/controllers/core/interpolation.cpp | 2 +- firmware/controllers/math/engine_math.h | 2 +- firmware/hw_layer/adc_inputs.cpp | 4 ++-- firmware/util/datalogging.cpp | 5 ++++- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/firmware/controllers/algo/obd_error_codes.h b/firmware/controllers/algo/obd_error_codes.h index 15d68aa03f..55c1de2d56 100644 --- a/firmware/controllers/algo/obd_error_codes.h +++ b/firmware/controllers/algo/obd_error_codes.h @@ -1872,7 +1872,7 @@ typedef enum { ERROR_TRIGGER_DRAMA = 6513, CUSTOM_MAP_ANGLE_PARAM = 6514, CUSTOM_ERR_DISPLAY_MODE = 6515, - CUSTOM_ERR_6516 = 6516, + CUSTOM_ERR_ADC_UNKNOWN_CHANNEL = 6516, CUSTOM_ERR_ADC_USED = 6517, CUSTOM_ERR_ADC_DEPTH_SLOW = 6518, CUSTOM_ERR_ADC_DEPTH_FAST = 6519, @@ -1892,12 +1892,12 @@ typedef enum { CUSTOM_ERR_INTERPOLATE_PARAM = 6533, ERROR_LOGGING_SIZE_CALC = 6534, CUSTOM_ERR_ADC_CHANNEL = 6535, - CUSTOM_ERR_6536 = 6536, - CUSTOM_ERR_6537 = 6537, - CUSTOM_ERR_6538 = 6538, + CUSTOM_ERR_ANGLE = 6536, + CUSTOM_ERR_LOGGING_NULL = 6537, + CUSTOM_ERR_PARSING_ERROR = 6538, CUSTOM_ERR_INJECTOR_LAG = 6539, - CUSTOM_ERR_6540 = 6540, + CUSTOM_ERR_AXIS_ORDER = 6540, CUSTOM_ERR_6541 = 6541, CUSTOM_ERR_6542 = 6542, CUSTOM_ERR_6543 = 6543, diff --git a/firmware/controllers/core/fsio_core.cpp b/firmware/controllers/core/fsio_core.cpp index c2eebcb29f..a4bddc1317 100644 --- a/firmware/controllers/core/fsio_core.cpp +++ b/firmware/controllers/core/fsio_core.cpp @@ -427,7 +427,7 @@ LEElement *LEElementPool::parseExpression(const char * line) { /** * Cannot recognize token */ - warning(CUSTOM_ERR_6536, "unrecognized [%s]", parsingBuffer); + warning(CUSTOM_ERR_PARSING_ERROR, "unrecognized [%s]", parsingBuffer); return NULL; } n->init(action); diff --git a/firmware/controllers/core/interpolation.cpp b/firmware/controllers/core/interpolation.cpp index 90223b0ec7..04a2a021fd 100644 --- a/firmware/controllers/core/interpolation.cpp +++ b/firmware/controllers/core/interpolation.cpp @@ -173,7 +173,7 @@ int findIndex2(const float array[], unsigned size, float value) { void ensureArrayIsAscending(const char *msg, const float array[], int size) { for (int i = 0; i < size - 1; i ++) { if (array[i] >= array[i+ 1]) { - firmwareError(CUSTOM_ERR_6538, "invalid axis %s at %f", msg, array[i]); + firmwareError(CUSTOM_ERR_AXIS_ORDER, "invalid axis %s at %f", msg, array[i]); } } } diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index 09823cdab8..8ccb1554cc 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -33,7 +33,7 @@ void setFlatInjectorLag(float value DECLARE_ENGINE_PARAMETER_SUFFIX); #define fixAngle(angle, msg) \ { \ if (cisnan(angle)) { \ - firmwareError(CUSTOM_ERR_6516, "angle NaN %s", msg); \ + firmwareError(CUSTOM_ERR_ANGLE, "angle NaN %s", msg); \ angle = 0; \ } \ assertAngleRange(angle, msg); \ diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index cdd352cbfd..c7f96435ba 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -317,7 +317,7 @@ brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel) { case ADC_CHANNEL_IN15: return GPIOC_5; default: - firmwareError(CUSTOM_ERR_6516, "Unknown hw channel %d [%s]", hwChannel, msg); + firmwareError(CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg); return GPIO_INVALID; } } @@ -398,7 +398,7 @@ ioportid_t getAdcChannelPort(const char *msg, adc_channel_e hwChannel) { case ADC_CHANNEL_IN15: return GPIOC; default: - firmwareError(CUSTOM_ERR_6516, "Unknown hw channel %d [%s]", hwChannel, msg); + firmwareError(CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg); return NULL; } } diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index 3155f0b0d7..140a2d5012 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -255,7 +255,10 @@ void printMsg(Logging *logger, const char *fmt, ...) { * in order to reduce memory usage */ void scheduleMsg(Logging *logging, const char *fmt, ...) { - efiAssertVoid(logging != NULL, "logging NULL"); + if (logging == NULL) { + warning(CUSTOM_ERR_LOGGING_NULL, "logging NULL"); + return; + } int wasLocked = lockAnyContext(); resetLogging(logging); // todo: is 'reset' really needed here? appendMsgPrefix(logging);