Skip to content

Commit

Permalink
fix apparent CopyPaste error assigning OBD fault (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-hol authored Jul 17, 2023
1 parent a8cbf0e commit 0975c78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions firmware/controllers/algo/obd_error_codes.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file obd_error_codes.h
* @brief Standart and custom OBD-II error codes
* @brief Standard and custom OBD-II error codes
*
* More info at http://www.obd-codes.com/faq/obd2-codes-explained.php
*
Expand Down Expand Up @@ -1714,10 +1714,10 @@ enum class ObdCode : uint16_t {

CUSTOM_6010 = 6010,
CUSTOM_6011 = 6011,
CUSTOM_INTEPOLATE_ERROR = 6012,
CUSTOM_INTEPOLATE_ERROR_2 = 6013,
CUSTOM_INTEPOLATE_ERROR_3 = 6014,
CUSTOM_INTEPOLATE_ERROR_4 = 6015,
CUSTOM_ERR_INTERPOLATE_1 = 6012,
CUSTOM_ERR_INTERPOLATE_2 = 6013,
CUSTOM_ERR_INTERPOLATE_3 = 6014,
CUSTOM_ERR_INTERPOLATE_4 = 6015,
CUSTOM_PARAM_RANGE = 6016,
CUSTOM_MAF_NEEDED = 6017,
CUSTOM_UNKNOWN_ALGORITHM = 6018,
Expand Down
8 changes: 4 additions & 4 deletions firmware/util/math/interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ static void testBinary() {
*/
float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, float x) {
if (cisnan(x1) || cisnan(x2) || cisnan(y1) || cisnan(y2)) {
warning(ObdCode::CUSTOM_INTEPOLATE_ERROR, "interpolate%s: why param", msg);
warning(ObdCode::CUSTOM_ERR_INTERPOLATE_1, "interpolate%s: why param", msg);
return NAN;
}
if (cisnan(x)) {
warning(ObdCode::CUSTOM_INTEPOLATE_ERROR, "interpolate%s: why X", msg);
warning(ObdCode::CUSTOM_ERR_INTERPOLATE_2, "interpolate%s: why X", msg);
return NAN;
}
// todo: double comparison using EPS
if (x1 == x2) {
/**
* we could end up here for example while resetting bins while changing engine type
*/
warning(ObdCode::CUSTOM_INTEPOLATE_ERROR, "interpolate%s: Same x1 and x2 in interpolate: %.2f/%.2f", msg, x1, x2);
warning(ObdCode::CUSTOM_ERR_INTERPOLATE_3, "interpolate%s: Same x1 and x2 in interpolate: %.2f/%.2f", msg, x1, x2);
return NAN;
}

Expand All @@ -94,7 +94,7 @@ float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, fl
// efiAssertVoid(ObdCode::CUSTOM_ERR_ASSERT_VOID, x1 != x2, "no way we can interpolate");
float a = INTERPOLATION_A(x1, y1, x2, y2);
if (cisnan(a)) {
warning(ObdCode::CUSTOM_INTEPOLATE_ERROR, "interpolate%s: why a", msg);
warning(ObdCode::CUSTOM_ERR_INTERPOLATE_4, "interpolate%s: why a", msg);
return NAN;
}
float b = y1 - a * x1;
Expand Down

0 comments on commit 0975c78

Please sign in to comment.