Merge pull request #8 from claneys/master
[apps/agl-service-can-low-level.git] / src / uds / extras.h
1 #ifndef __EXTRAS_H__
2 #define __EXTRAS_H__
3
4 #include <uds/uds_types.h>
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 // TODO everything in here is unused for the moment!
11
12 typedef enum {
13     POWERTRAIN = 0x0,
14     CHASSIS = 0x1,
15     BODY = 0x2,
16     NETWORK = 0x3
17 } DiagnosticTroubleCodeGroup;
18
19 typedef struct {
20     DiagnosticTroubleCodeGroup group;
21     uint8_t group_num;
22     uint8_t code;
23 } DiagnosticTroubleCode;
24
25
26 /* Private: TODO unused for now
27  */
28 typedef enum {
29     DTC_EMISSIONS,
30     DTC_DRIVE_CYCLE,
31     DTC_PERMANENT
32 } DiagnosticTroubleCodeType;
33
34
35 // TODO should we enumerate every OBD-II PID? need conversion formulas, too
36 typedef struct {
37     uint16_t pid;
38     uint8_t bytes_returned;
39     float min_value;
40     float max_value;
41 } DiagnosticParameter;
42
43 typedef void (*DiagnosticMilStatusReceived)(bool malfunction_indicator_status);
44 typedef void (*DiagnosticVinReceived)(uint8_t vin[]);
45 typedef void (*DiagnosticTroubleCodesReceived)(
46         DiagnosticMode mode, DiagnosticTroubleCode* codes);
47 typedef void (*DiagnosticPidEnumerationReceived)(
48         const DiagnosticResponse* response, uint16_t* pids);
49
50 DiagnosticRequestHandle diagnostic_request_malfunction_indicator_status(
51         DiagnosticShims* shims,
52         DiagnosticMilStatusReceived callback);
53
54 DiagnosticRequestHandle diagnostic_request_vin(DiagnosticShims* shims,
55         DiagnosticVinReceived callback);
56
57 DiagnosticRequestHandle diagnostic_request_dtc(DiagnosticShims* shims,
58         DiagnosticTroubleCodeType dtc_type,
59         DiagnosticTroubleCodesReceived callback);
60
61 bool diagnostic_clear_dtc(DiagnosticShims* shims);
62
63 DiagnosticRequestHandle diagnostic_enumerate_pids(DiagnosticShims* shims,
64         DiagnosticRequest* request, DiagnosticPidEnumerationReceived callback);
65
66
67 #ifdef __cplusplus
68 }
69 #endif
70
71 #endif // __EXTRAS_H__