Mark whether a PID is present in response.
[apps/low-level-can-service.git] / README.mkd
index 5e962f0..0c28206 100644 (file)
@@ -9,17 +9,6 @@ This library doesn't assume anything about the source of your diagnostic message
 requests or underlying interface to the CAN bus. It uses dependency injection to
 give you complete control.
 
 requests or underlying interface to the CAN bus. It uses dependency injection to
 give you complete control.
 
-## OBD-II Basics
-
-TODO diagram out a request, response and error response
-
-* store the request arb id, mode, pid, and payload locally
-* send a can message
-* get all new can messages passed to it
-* Check the incoming can message to see if it matches one of the standard ECU
-  response IDs, or our arb ID + 0x8
-* if it matches, parse the diagnostic response and call the callback
-
 ## Usage
 
 First, create some shim functions to let this library use your lower level
 ## Usage
 
 First, create some shim functions to let this library use your lower level
@@ -28,7 +17,7 @@ system:
     // required, this must send a single CAN message with the given arbitration
     // ID (i.e. the CAN message ID) and data. The size will never be more than 8
     // bytes.
     // required, this must send a single CAN message with the given arbitration
     // ID (i.e. the CAN message ID) and data. The size will never be more than 8
     // bytes.
-    void send_can(const uint16_t arbitration_id, const uint8_t* data,
+    bool send_can(const uint16_t arbitration_id, const uint8_t* data,
             const uint8_t size) {
         ...
     }
             const uint8_t size) {
         ...
     }
@@ -48,8 +37,8 @@ With your shims in place, create a `DiagnosticShims` object to pass them around:
 
     DiagnosticShims shims = diagnostic_init_shims(debug, send_can, set_timer);
 
 
     DiagnosticShims shims = diagnostic_init_shims(debug, send_can, set_timer);
 
-With your shims in hand, send a simple PID request to the stadnard broadcast
-address, `0x7df`:
+With your shims in hand, send a simple PID request to the standard broadcast
+address, `0x7df` (we use the constant `OBD2_FUNCTIONAL_BROADCAST_ID` here):
 
     // Optional: This is your callback that will be called the response to your
     // diagnostic request is received.
 
     // Optional: This is your callback that will be called the response to your
     // diagnostic request is received.
@@ -59,7 +48,7 @@ address, `0x7df`:
 
     DiagnosticRequestHandle handle = diagnostic_request_pid(&shims,
             DIAGNOSTIC_STANDARD_PID, // this is a standard PID request, not an extended or enhanced one
 
     DiagnosticRequestHandle handle = diagnostic_request_pid(&shims,
             DIAGNOSTIC_STANDARD_PID, // this is a standard PID request, not an extended or enhanced one
-            0x7df, // the request is going out to the broadcast arbitration ID
+            OBD2_FUNCTIONAL_BROADCAST_ID, // the request is going out to the broadcast arbitration ID
             0x2, // we want PID 0x2
             response_received_handler); // our callback (optional, use NULL if you don't have one)
 
             0x2, // we want PID 0x2
             response_received_handler); // our callback (optional, use NULL if you don't have one)
 
@@ -102,13 +91,13 @@ address, `0x7df`:
         }
     }
 
         }
     }
 
-## Requests for other modes
+### Requests for other modes
 
 If you want to do more besides PID requests on mode 0x1 and 0x22, there's a
 lower level API you can use. Here's how to make a mode 3 request to get DTCs.
 
     DiagnosticRequest request = {
 
 If you want to do more besides PID requests on mode 0x1 and 0x22, there's a
 lower level API you can use. Here's how to make a mode 3 request to get DTCs.
 
     DiagnosticRequest request = {
-        arbitration_id: 0x7df,
+        arbitration_id: OBD2_FUNCTIONAL_BROADCAST_ID,
         mode: OBD2_MODE_EMISSIONS_DTC_REQUEST
     };
     DiagnosticRequestHandle handle = diagnostic_request(&SHIMS, &request, NULL);
         mode: OBD2_MODE_EMISSIONS_DTC_REQUEST
     };
     DiagnosticRequestHandle handle = diagnostic_request(&SHIMS, &request, NULL);
@@ -156,6 +145,13 @@ lower level API you can use. Here's how to make a mode 3 request to get DTCs.
         }
     }
 
         }
     }
 
+## Dependencies
+
+This library requires 2 dependencies:
+
+* [isotp-c](https://github.com/openxc/isotp-c)
+* [bitfield-c](https://github.com/openxc/bitfield-c)
+
 ## Testing
 
 The library includes a test suite that uses the `check` C unit test library.
 ## Testing
 
 The library includes a test suite that uses the `check` C unit test library.
@@ -167,6 +163,18 @@ You can also see the test coverage if you have `lcov` installed and the
 
     $ BROWSER=google-chrome-stable make coverage
 
 
     $ BROWSER=google-chrome-stable make coverage
 
+## OBD-II Basics
+
+TODO diagram out a request, response and error response
+
+* store the request arb id, mode, pid, and payload locally
+* send a can message
+* get all new can messages passed to it
+* Check the incoming can message to see if it matches one of the standard ECU
+  response IDs, or our arb ID + 0x8
+* if it matches, parse the diagnostic response and call the callback
+
+
 ## Future Notes
 
 you're going to request a few PIDs over and over again at some frequency
 ## Future Notes
 
 you're going to request a few PIDs over and over again at some frequency