diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/uds/uds.c | 14 | ||||
-rw-r--r-- | src/uds/uds.h | 10 | ||||
-rw-r--r-- | src/uds/uds_types.h | 4 |
3 files changed, 21 insertions, 7 deletions
diff --git a/src/uds/uds.c b/src/uds/uds.c index 7303677a..510cdd43 100644 --- a/src/uds/uds.c +++ b/src/uds/uds.c @@ -32,7 +32,7 @@ DiagnosticShims diagnostic_init_shims(LogShim log, static void setup_receive_handle(DiagnosticRequestHandle* handle) { if(handle->request.arbitration_id == OBD2_FUNCTIONAL_BROADCAST_ID) { - uint16_t response_id; + uint32_t response_id; for(response_id = 0; response_id < OBD2_FUNCTIONAL_RESPONSE_COUNT; ++response_id) { handle->isotp_receive_handles[response_id] = isotp_receive( @@ -142,7 +142,7 @@ DiagnosticRequestHandle diagnostic_request(DiagnosticShims* shims, } DiagnosticRequestHandle diagnostic_request_pid(DiagnosticShims* shims, - DiagnosticPidRequestType pid_request_type, uint16_t arbitration_id, + DiagnosticPidRequestType pid_request_type, uint32_t arbitration_id, uint16_t pid, DiagnosticResponseReceived callback) { DiagnosticRequest request = { arbitration_id: arbitration_id, @@ -214,7 +214,7 @@ static bool handle_positive_response(DiagnosticRequestHandle* handle, } DiagnosticResponse diagnostic_receive_can_frame(DiagnosticShims* shims, - DiagnosticRequestHandle* handle, const uint16_t arbitration_id, + DiagnosticRequestHandle* handle, const uint32_t arbitration_id, const uint8_t data[], const uint8_t size) { DiagnosticResponse response = { @@ -373,3 +373,11 @@ void diagnostic_request_to_string(const DiagnosticRequest* request, } } +bool diagnostic_request_equals(const DiagnosticRequest* ours, + const DiagnosticRequest* theirs) { + bool equals = ours->arbitration_id == theirs->arbitration_id && + ours->mode == theirs->mode; + equals &= ours->has_pid == theirs->has_pid; + equals &= ours->pid == theirs->pid; + return equals; +} diff --git a/src/uds/uds.h b/src/uds/uds.h index 22ff36af..1546320e 100644 --- a/src/uds/uds.h +++ b/src/uds/uds.h @@ -87,7 +87,7 @@ void start_diagnostic_request(DiagnosticShims* shims, * sent. */ DiagnosticRequestHandle diagnostic_request_pid(DiagnosticShims* shims, - DiagnosticPidRequestType pid_request_type, uint16_t arbitration_id, + DiagnosticPidRequestType pid_request_type, uint32_t arbitration_id, uint16_t pid, DiagnosticResponseReceived callback); /* Public: Continue to send and receive a single diagnostic request, based on a @@ -106,7 +106,7 @@ DiagnosticRequestHandle diagnostic_request_pid(DiagnosticShims* shims, */ DiagnosticResponse diagnostic_receive_can_frame(DiagnosticShims* shims, DiagnosticRequestHandle* handle, - const uint16_t arbitration_id, const uint8_t data[], + const uint32_t arbitration_id, const uint8_t data[], const uint8_t size); /* Public: Parse the entier payload of the reponse as a single integer. @@ -145,6 +145,12 @@ void diagnostic_request_to_string(const DiagnosticRequest* request, */ float diagnostic_decode_obd2_pid(const DiagnosticResponse* response); +/* Public: Returns true if the "fingerprint" of the two diagnostic messages + * matches - the arbitration_id, mode and pid (or lack of pid). + */ +bool diagnostic_request_equals(const DiagnosticRequest* ours, + const DiagnosticRequest* theirs); + #ifdef __cplusplus } #endif diff --git a/src/uds/uds_types.h b/src/uds/uds_types.h index a71d53c6..89ae18a7 100644 --- a/src/uds/uds_types.h +++ b/src/uds/uds_types.h @@ -49,7 +49,7 @@ typedef enum { * type - the type of the request (TODO unused) */ typedef struct { - uint16_t arbitration_id; + uint32_t arbitration_id; uint8_t mode; bool has_pid; uint16_t pid; @@ -105,7 +105,7 @@ typedef enum { typedef struct { bool completed; bool success; - uint16_t arbitration_id; + uint32_t arbitration_id; uint8_t mode; bool has_pid; uint16_t pid; |