From a8f4bf42ee73ede0d2d3ddaf6c312c756c042a6b Mon Sep 17 00:00:00 2001 From: Christopher Peplin Date: Thu, 27 Feb 2014 15:53:19 -0500 Subject: [PATCH] Increase size of arb ID to uint32_t to fit extended IDs. --- src/isotp/isotp_types.h | 4 ++-- src/isotp/receive.c | 4 ++-- src/isotp/receive.h | 6 +++--- tests/common.c | 10 +++++----- tests/test_core.c | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/isotp/isotp_types.h b/src/isotp/isotp_types.h index 5a40733f..9d05980a 100644 --- a/src/isotp/isotp_types.h +++ b/src/isotp/isotp_types.h @@ -38,7 +38,7 @@ extern "C" { * size - The size of the payload. The size will be 0 if there is no payload. */ typedef struct { - const uint16_t arbitration_id; + const uint32_t arbitration_id; uint8_t payload[OUR_MAX_ISO_TP_MESSAGE_SIZE]; uint16_t size; bool completed; @@ -60,7 +60,7 @@ typedef void (*LogShim)(const char* message, ...); * * Returns true if the CAN message was sent successfully. */ -typedef bool (*SendCanMessageShim)(const uint16_t arbitration_id, +typedef bool (*SendCanMessageShim)(const uint32_t arbitration_id, const uint8_t* data, const uint8_t size); /* Public: The type signature for a... TODO, not used yet. diff --git a/src/isotp/receive.c b/src/isotp/receive.c index 792afda9..2dc380bc 100644 --- a/src/isotp/receive.c +++ b/src/isotp/receive.c @@ -14,7 +14,7 @@ bool isotp_handle_single_frame(IsoTpReceiveHandle* handle, IsoTpMessage* message } IsoTpReceiveHandle isotp_receive(IsoTpShims* shims, - const uint16_t arbitration_id, IsoTpMessageReceivedHandler callback) { + const uint32_t arbitration_id, IsoTpMessageReceivedHandler callback) { IsoTpReceiveHandle handle = { success: false, completed: false, @@ -26,7 +26,7 @@ IsoTpReceiveHandle isotp_receive(IsoTpShims* shims, } IsoTpMessage isotp_continue_receive(IsoTpShims* shims, - IsoTpReceiveHandle* handle, const uint16_t arbitration_id, + IsoTpReceiveHandle* handle, const uint32_t arbitration_id, const uint8_t data[], const uint8_t size) { IsoTpMessage message = { arbitration_id: arbitration_id, diff --git a/src/isotp/receive.h b/src/isotp/receive.h index 1dfd6f6d..6788914a 100644 --- a/src/isotp/receive.h +++ b/src/isotp/receive.h @@ -25,7 +25,7 @@ typedef struct { bool success; // Private - uint16_t arbitration_id; + uint32_t arbitration_id; IsoTpMessageReceivedHandler message_received_callback; uint16_t timeout_ms; // timeout_ms: ISO_TP_DEFAULT_RESPONSE_TIMEOUT, @@ -52,7 +52,7 @@ typedef struct { * when the message is completely sent. */ IsoTpReceiveHandle isotp_receive(IsoTpShims* shims, - const uint16_t arbitration_id, IsoTpMessageReceivedHandler callback); + const uint32_t arbitration_id, IsoTpMessageReceivedHandler callback); /* Public: Continue to receive a an ISO-TP message, based on a freshly * received CAN message. @@ -76,7 +76,7 @@ IsoTpReceiveHandle isotp_receive(IsoTpShims* shims, * handle. Keep passing the same handle to this function when CAN frames arrive. */ IsoTpMessage isotp_continue_receive(IsoTpShims* shims, - IsoTpReceiveHandle* handle, const uint16_t arbitration_id, + IsoTpReceiveHandle* handle, const uint32_t arbitration_id, const uint8_t data[], const uint8_t size); #ifdef __cplusplus diff --git a/tests/common.c b/tests/common.c index d062db5d..a9eed39e 100644 --- a/tests/common.c +++ b/tests/common.c @@ -8,17 +8,17 @@ IsoTpShims SHIMS; IsoTpReceiveHandle RECEIVE_HANDLE; -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; bool message_was_received; -uint16_t last_message_received_arb_id; +uint32_t last_message_received_arb_id; uint8_t last_message_received_payload[OUR_MAX_ISO_TP_MESSAGE_SIZE]; uint8_t last_message_received_payload_size; -uint16_t last_message_sent_arb_id; +uint32_t last_message_sent_arb_id; bool last_message_sent_status; uint8_t last_message_sent_payload[OUR_MAX_ISO_TP_MESSAGE_SIZE]; uint8_t last_message_sent_payload_size; @@ -31,7 +31,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; @@ -73,7 +73,7 @@ void message_sent(const IsoTpMessage* message, const bool success) { } } -void can_frame_sent(const uint16_t arbitration_id, const uint8_t* payload, +void can_frame_sent(const uint32_t arbitration_id, const uint8_t* payload, const uint8_t size) { debug("Sent CAN Frame with arb ID 0x%x and %d bytes", arbitration_id, size); } diff --git a/tests/test_core.c b/tests/test_core.c index 78e13e8d..73b47af0 100644 --- a/tests/test_core.c +++ b/tests/test_core.c @@ -30,7 +30,7 @@ START_TEST (test_default_frame_padding_on) { ck_assert(SHIMS.frame_padding); const uint8_t payload[] = {0x12, 0x34}; - uint16_t arbitration_id = 0x2a; + uint32_t arbitration_id = 0x2a; isotp_send(&SHIMS, arbitration_id, payload, sizeof(payload), message_sent); ck_assert_int_eq(last_message_sent_arb_id, arbitration_id); fail_unless(last_message_sent_status); @@ -44,7 +44,7 @@ START_TEST (test_disabled_frame_padding) { SHIMS.frame_padding = false; const uint8_t payload[] = {0x12, 0x34}; - uint16_t arbitration_id = 0x2a; + uint32_t arbitration_id = 0x2a; isotp_send(&SHIMS, arbitration_id, payload, sizeof(payload), message_sent); ck_assert_int_eq(last_message_sent_arb_id, arbitration_id); fail_unless(last_message_sent_status); -- 2.16.6