aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------deps/isotp-c12
-rw-r--r--src/uds/uds.c14
-rw-r--r--src/uds/uds.h10
-rw-r--r--src/uds/uds_types.h4
-rw-r--r--tests/common.c4
5 files changed, 28 insertions, 16 deletions
diff --git a/deps/isotp-c b/deps/isotp-c
-Subproject c01a88ba1e56d455c7187a52a5e244500a0d6b0
+Subproject a8f4bf42ee73ede0d2d3ddaf6c312c756c042a6
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;
diff --git a/tests/common.c b/tests/common.c
index 8d7dd50d..fd1e4b2c 100644
--- a/tests/common.c
+++ b/tests/common.c
@@ -7,7 +7,7 @@
DiagnosticShims SHIMS;
-uint16_t last_can_frame_sent_arb_id;
+uint32_t last_can_frame_sent_arb_id;
uint8_t last_can_payload_sent[8];
uint8_t last_can_payload_size;
bool can_frame_was_sent;
@@ -23,7 +23,7 @@ void debug(const char* format, ...) {
va_end(args);
}
-bool mock_send_can(const uint16_t arbitration_id, const uint8_t* data,
+bool mock_send_can(const uint32_t arbitration_id, const uint8_t* data,
const uint8_t size) {
can_frame_was_sent = true;
last_can_frame_sent_arb_id = arbitration_id;