Compile with test coverage calculation.
[apps/agl-service-can-low-level.git] / README.mkd
1 OBD-II Support Library in C
2 =============================
3
4 TODO diagram out a request, response and error response
5
6 TODO isotp needs to accept responses on an ID other that the request's arb id -
7 or maybe we have 2 isotp instances, for rx and tx.
8
9 * Response's arb id is assigned ID plus 0x8
10 * Functional daignostic request (Broadcast), 0x7df arb id
11 * Standard ECU requests to 0x7e0 - 0x7e7
12
13 * Some requests don't need PIDs - e.g. mode 3
14     * some responses don't have PIDs, just payload - e.g. mode 3
15
16 * Service ID + 0x40 == positive response
17 * Response includes PID echo - use this to match up request/response
18 * Response ID, ISO-TP PCI, ISO-TP length, service response ID, PID echo, data
19
20 I send the request and give a callback
21 when the response arrives for the matchin service and PID - on any arb id, since
22 this may be a broadcast - call my callback.
23
24
25 TODO do you want to provide the callback to the Handler, or to each
26 individual send?o
27 ok, what are the use cases here.
28
29 you're going to request a few PIDs over and over again at some frequency
30 you're going to request DTCs once and read the response
31 you're going to clear DTCs once
32
33 i'd rather use the same diagnostic handler to send all of the differet messages
34 rather than create one for each use. that way ai can
35
36 but that does complicate the memory management because it'll need to create
37 some internal data structures.
38
39 at the simplest, what does this handler have to do?
40
41 * store the request arb id, mode, pid, and payload locally
42 * send a can message
43 * get all new can messages passed to it
44 * Check the incoming can message to see if it matches one of the standard ECU
45   response IDs, or our arb ID + 0x8
46 * if it matches, parse the diagnostic response and call the callback
47
48 that seems pretty simple and not worth greatly increasing the internal state to
49 handle multiple requests
50
51 what we need is another layer on top of that to handle the repeated requests.
52
53 ## API
54
55     void my_callback(const DiagnosticResponse* response) {
56     }
57
58     DiagnosticRequestHandle handle = diagnostic_init(my_callback);
59     DiagnosticRequest request = {
60         arbitratin_id: 0x7df,
61         mode: OBD2_MODE_POWERTRAIN_DIAGNOSTIC_REQUEST,
62         pid: 3
63     };
64
65     diagnostic_send(&handle, &request);
66     while(true) {
67         diagnostic_handle_can_frame(&handle, 42, data, 8);
68     }
69
70     diagnostic_request_pid(&handle, DIAGNOSTIC_STANDARD_PID, 42
71
72     diagnostic_destroy(&handle);
73
74 ## Testing
75
76 The library includes a test suite that uses the `check` C unit test library.
77
78     $ make test
79
80 ## Authors
81
82 Chris Peplin cpeplin@ford.com
83
84 ## License
85
86 Copyright (c) 2013 Ford Motor Company
87
88 Licensed under the BSD license.