aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.mkd8
-rw-r--r--src/obd2/obd2.h2
-rw-r--r--tests/test_core.c17
3 files changed, 14 insertions, 13 deletions
diff --git a/README.mkd b/README.mkd
index 58cc152d..0c28206a 100644
--- a/README.mkd
+++ b/README.mkd
@@ -37,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);
-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.
@@ -48,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
- 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)
@@ -97,7 +97,7 @@ 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);
diff --git a/src/obd2/obd2.h b/src/obd2/obd2.h
index 7dfdb594..b301138c 100644
--- a/src/obd2/obd2.h
+++ b/src/obd2/obd2.h
@@ -5,6 +5,8 @@
#include <stdint.h>
#include <stdbool.h>
+#define OBD2_FUNCTIONAL_BROADCAST_ID 0x7df
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/tests/test_core.c b/tests/test_core.c
index 51dff33f..b115c1c8 100644
--- a/tests/test_core.c
+++ b/tests/test_core.c
@@ -20,7 +20,7 @@ void response_received_handler(const DiagnosticResponse* response) {
START_TEST (test_receive_wrong_arb_id)
{
DiagnosticRequest request = {
- arbitration_id: 0x7df,
+ arbitration_id: OBD2_FUNCTIONAL_BROADCAST_ID,
mode: OBD2_MODE_POWERTRAIN_DIAGNOSTIC_REQUEST
};
DiagnosticRequestHandle handle = diagnostic_request(&SHIMS, &request,
@@ -37,7 +37,7 @@ END_TEST
START_TEST (test_send_diag_request_with_payload)
{
DiagnosticRequest request = {
- arbitration_id: 0x7df,
+ arbitration_id: OBD2_FUNCTIONAL_BROADCAST_ID,
mode: OBD2_MODE_POWERTRAIN_DIAGNOSTIC_REQUEST,
payload: {0x12, 0x34},
payload_length: 2
@@ -59,7 +59,7 @@ END_TEST
START_TEST (test_send_diag_request)
{
DiagnosticRequest request = {
- arbitration_id: 0x7df,
+ arbitration_id: OBD2_FUNCTIONAL_BROADCAST_ID,
mode: OBD2_MODE_EMISSIONS_DTC_REQUEST
};
DiagnosticRequestHandle handle = diagnostic_request(&SHIMS, &request,
@@ -89,8 +89,7 @@ END_TEST
START_TEST (test_request_pid_standard)
{
- // TODO need a constant for the 7df broadcast functional request
- uint16_t arb_id = 0x7df;
+ uint16_t arb_id = OBD2_MODE_POWERTRAIN_DIAGNOSTIC_REQUEST;
DiagnosticRequestHandle handle = diagnostic_request_pid(&SHIMS,
DIAGNOSTIC_STANDARD_PID, arb_id, 0x2, response_received_handler);
@@ -111,7 +110,7 @@ END_TEST
START_TEST (test_request_pid_enhanced)
{
- uint16_t arb_id = 0x7df;
+ uint16_t arb_id = OBD2_FUNCTIONAL_BROADCAST_ID;
DiagnosticRequestHandle handle = diagnostic_request_pid(&SHIMS,
DIAGNOSTIC_ENHANCED_PID, arb_id, 0x2, response_received_handler);
@@ -132,7 +131,7 @@ END_TEST
START_TEST (test_wrong_mode_response)
{
- uint16_t arb_id = 0x7df;
+ uint16_t arb_id = OBD2_FUNCTIONAL_BROADCAST_ID;
DiagnosticRequestHandle handle = diagnostic_request_pid(&SHIMS,
DIAGNOSTIC_ENHANCED_PID, arb_id, 0x2, response_received_handler);
@@ -151,7 +150,7 @@ END_TEST
START_TEST (test_handle_completed)
{
DiagnosticRequest request = {
- arbitration_id: 0x7df,
+ arbitration_id: OBD2_FUNCTIONAL_BROADCAST_ID,
mode: OBD2_MODE_POWERTRAIN_DIAGNOSTIC_REQUEST
};
DiagnosticRequestHandle handle = diagnostic_request(&SHIMS, &request,
@@ -185,7 +184,7 @@ END_TEST
START_TEST (test_negative_response)
{
DiagnosticRequest request = {
- arbitration_id: 0x7df,
+ arbitration_id: OBD2_FUNCTIONAL_BROADCAST_ID,
mode: OBD2_MODE_POWERTRAIN_DIAGNOSTIC_REQUEST
};
DiagnosticRequestHandle handle = diagnostic_request(&SHIMS, &request,