Increase arb IDs to uint32_t to fit extended IDs.
authorChristopher Peplin <chris.peplin@rhubarbtech.com>
Thu, 27 Feb 2014 20:53:58 +0000 (15:53 -0500)
committerChristopher Peplin <chris.peplin@rhubarbtech.com>
Thu, 27 Feb 2014 20:53:58 +0000 (15:53 -0500)
deps/isotp-c
src/uds/uds.c
src/uds/uds.h
src/uds/uds_types.h
tests/common.c

index c01a88b..a8f4bf4 160000 (submodule)
@@ -1 +1 @@
-Subproject commit c01a88ba1e56d455c7187a52a5e244500a0d6b0f
+Subproject commit a8f4bf42ee73ede0d2d3ddaf6c312c756c042a6b
index 7303677..510cdd4 100644 (file)
@@ -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) {
 
 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(
         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,
 }
 
 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,
         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,
 }
 
 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 = {
         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;
+}
index 22ff36a..1546320 100644 (file)
@@ -87,7 +87,7 @@ void start_diagnostic_request(DiagnosticShims* shims,
  * sent.
  */
 DiagnosticRequestHandle diagnostic_request_pid(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
         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,
  */
 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.
         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);
 
  */
 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
 #ifdef __cplusplus
 }
 #endif
index a71d53c..89ae18a 100644 (file)
@@ -49,7 +49,7 @@ typedef enum {
  * type - the type of the request (TODO unused)
  */
 typedef struct {
  * 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;
     uint8_t mode;
     bool has_pid;
     uint16_t pid;
@@ -105,7 +105,7 @@ typedef enum {
 typedef struct {
     bool completed;
     bool success;
 typedef struct {
     bool completed;
     bool success;
-    uint16_t arbitration_id;
+    uint32_t arbitration_id;
     uint8_t mode;
     bool has_pid;
     uint16_t pid;
     uint8_t mode;
     bool has_pid;
     uint16_t pid;
index 8d7dd50..fd1e4b2 100644 (file)
@@ -7,7 +7,7 @@
 
 DiagnosticShims SHIMS;
 
 
 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;
 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);
 }
 
     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;
         const uint8_t size) {
     can_frame_was_sent = true;
     last_can_frame_sent_arb_id = arbitration_id;