rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
malfunction_central.cpp
Go to the documentation of this file.
1/**
2 * @file malfunction_central.c
3 * @brief This data structure holds current malfunction codes
4 *
5 * todo: make this a class
6 *
7 * @date Dec 20, 2013
8 * @author Andrey Belomutskiy, (c) 2012-2020
9 */
10
11#include "pch.h"
12
13#include "malfunction_central.h"
14
16
17void clearWarnings(void) {
19}
20
21// TODO: wow this is not used by real firmware?!
22#if EFI_UNIT_TEST
23/**
24 * Search if code is present
25 * @return -1 if code not found
26 */
27static int find_position(ObdCode e_code) {
28 // cycle for searching element equal seaching code
29 for (int t = 0; t < error_codes_set.count; t++)
30 if (error_codes_set.error_codes[t] == e_code)
31 return t; // we found position where this code is present
32 return -1; // -1 if code not found
33}
34
35void addError(ObdCode errorCode) {
36 if (error_codes_set.count < MAX_ERROR_CODES_COUNT && find_position(errorCode) == -1) {
39 }
40}
41
42void removeError(ObdCode errorCode) {
43 int pos = find_position(errorCode);
44 if (pos >= 0) {
45 // shift all right elements to one pos left
46 for (int t = pos; t < error_codes_set.count - 1; t++) {
48 }
49
51 }
52}
53#endif // EFI_UNIT_TEST
54
59
60bool hasErrorCodes(void) {
61 return error_codes_set.count > 0;
62}
void removeError(ObdCode errorCode)
Removed the error code from the set of current errors.
void clearWarnings(void)
void getErrorCodes(error_codes_set_s *copy)
Copies the current set of errors into the specified buffer.
static error_codes_set_s error_codes_set
void addError(ObdCode errorCode)
Adds an error code into the set of current errors. The error code is placed into the fixed-size data ...
bool hasErrorCodes(void)
static int find_position(ObdCode e_code)
This data structure holds current malfunction codes.
ObdCode
ObdCode error_codes[MAX_ERROR_CODES_COUNT]