aboutsummaryrefslogtreecommitdiffstats
path: root/libs/uds-c/src/uds/extras.h
blob: 126e5d4224712b2be63d497ca96825afd8fc4e09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef __EXTRAS_H__
#define __EXTRAS_H__

#include <uds/uds_types.h>

#ifdef __cplusplus
extern "C" {
#endif

// TODO everything in here is unused for the moment!

typedef enum {
    POWERTRAIN = 0x0,
    CHASSIS = 0x1,
    BODY = 0x2,
    NETWORK = 0x3
} DiagnosticTroubleCodeGroup;

typedef struct {
    DiagnosticTroubleCodeGroup group;
    uint8_t group_num;
    uint8_t code;
} DiagnosticTroubleCode;


/* Private: TODO unused for now
 */
typedef enum {
    DTC_EMISSIONS,
    DTC_DRIVE_CYCLE,
    DTC_PERMANENT
} DiagnosticTroubleCodeType;


// TODO should we enumerate every OBD-II PID? need conversion formulas, too
typedef struct {
    uint16_t pid;
    uint8_t bytes_returned;
    float min_value;
    float max_value;
} DiagnosticParameter;

typedef void (*DiagnosticMilStatusReceived)(bool malfunction_indicator_status);
typedef void (*DiagnosticVinReceived)(uint8_t vin[]);
typedef void (*DiagnosticTroubleCodesReceived)(
        DiagnosticMode mode, DiagnosticTroubleCode* codes);
typedef void (*DiagnosticPidEnumerationReceived)(
        const DiagnosticResponse* response, uint16_t* pids);

DiagnosticRequestHandle diagnostic_request_malfunction_indicator_status(
        DiagnosticShims* shims,
        DiagnosticMilStatusReceived callback);

DiagnosticRequestHandle diagnostic_request_vin(DiagnosticShims* shims,
        DiagnosticVinReceived callback);

DiagnosticRequestHandle diagnostic_request_dtc(DiagnosticShims* shims,
        DiagnosticTroubleCodeType dtc_type,
        DiagnosticTroubleCodesReceived callback);

bool diagnostic_clear_dtc(DiagnosticShims* shims);

DiagnosticRequestHandle diagnostic_enumerate_pids(DiagnosticShims* shims,
        DiagnosticRequest* request, DiagnosticPidEnumerationReceived callback);


#ifdef __cplusplus
}
#endif

#endif // __EXTRAS_H__