diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-17 15:56:34 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-17 15:56:34 -0500 |
commit | 6ebad2aac3ba2f0d7ff5e37c5db4e5b9549247e2 (patch) | |
tree | fcec8eae39587e50054fb627eee3662acb7809b3 /src | |
parent | 648c2f77afd1dadce1c01de3f1dc42b54da656d0 (diff) |
Mark whether a PID is present in response.
Diffstat (limited to 'src')
-rw-r--r-- | src/obd2/obd2.c | 6 | ||||
-rw-r--r-- | src/obd2/obd2_types.h | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/obd2/obd2.c b/src/obd2/obd2.c index 5b282f16..5061dd6b 100644 --- a/src/obd2/obd2.c +++ b/src/obd2/obd2.c @@ -154,9 +154,9 @@ static bool handle_positive_response(DiagnosticRequestHandle* handle, // hide the "response" version of the mode from the user // if it matched response->mode = handle->request.mode; - bool has_pid = false; + response->has_pid = false; if(handle->request.pid_length > 0 && message->size > 1) { - has_pid = true; + response->has_pid = true; if(handle->request.pid_length == 2) { response->pid = get_bitfield(message->payload, message->size, PID_BYTE_INDEX * CHAR_BIT, sizeof(uint16_t) * CHAR_BIT); @@ -173,7 +173,7 @@ static bool handle_positive_response(DiagnosticRequestHandle* handle, response->payload_length); } - if((handle->request.pid_length == 0 && !has_pid) + if((handle->request.pid_length == 0 && !response->has_pid) || response->pid == handle->request.pid) { response->success = true; response->completed = true; diff --git a/src/obd2/obd2_types.h b/src/obd2/obd2_types.h index 0699fc4b..15552e88 100644 --- a/src/obd2/obd2_types.h +++ b/src/obd2/obd2_types.h @@ -83,7 +83,10 @@ typedef enum { * the negative_response_code field for the reason. * arbitration_id - The arbitration ID the response was received on. * mode - The OBD-II mode for the original request. - * pid - If the request was for a PID, this is the PID echo. + * has_pid - If this is a response to a PID request, this will be true and the + * 'pid' field will be valid. + * pid - If the request was for a PID, this is the PID echo. Only valid if + * 'has_pid' is true. * negative_response_code - If the request was not successful, 'success' will be * false and this will be set to a DiagnosticNegativeResponseCode returned * by the other node. @@ -95,6 +98,7 @@ typedef struct { bool success; uint16_t arbitration_id; uint8_t mode; + bool has_pid; uint16_t pid; DiagnosticNegativeResponseCode negative_response_code; uint8_t payload[MAX_OBD2_PAYLOAD_LENGTH]; |