diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-02-14 17:58:22 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-02-14 17:58:22 -0500 |
commit | c01a88ba1e56d455c7187a52a5e244500a0d6b0f (patch) | |
tree | 07ac638bdb393c71ba2209b55d18d912f4cb55e7 /src | |
parent | 43fd60983efaaf4a475ee6a0d09395611b4aa6f8 (diff) |
Add an option to control CAN frame padding (on by default).
Fixed #1.
Diffstat (limited to 'src')
-rw-r--r-- | src/isotp/isotp.c | 3 | ||||
-rw-r--r-- | src/isotp/isotp_types.h | 9 | ||||
-rw-r--r-- | src/isotp/receive.h | 2 | ||||
-rw-r--r-- | src/isotp/send.c | 2 |
4 files changed, 12 insertions, 4 deletions
diff --git a/src/isotp/isotp.c b/src/isotp/isotp.c index f115810e..ad693416 100644 --- a/src/isotp/isotp.c +++ b/src/isotp/isotp.c @@ -10,7 +10,8 @@ IsoTpShims isotp_init_shims(LogShim log, SendCanMessageShim send_can_message, IsoTpShims shims = { log: log, send_can_message: send_can_message, - set_timer: set_timer + set_timer: set_timer, + frame_padding: ISO_TP_DEFAULT_FRAME_PADDING_STATUS }; return shims; } diff --git a/src/isotp/isotp_types.h b/src/isotp/isotp_types.h index d9fe4601..5a40733f 100644 --- a/src/isotp/isotp_types.h +++ b/src/isotp/isotp_types.h @@ -96,11 +96,20 @@ typedef void (*IsoTpCanFrameSentHandler)(const IsoTpMessage* message); * with the wider system. * * Use the isotp_init_shims(...) function to create an instance of this struct. + * + * By default, all CAN frames sent from this device in the process of an ISO-TP + * message are padded out to a complete 8 byte frame. This is often required by + * ECUs. To disable this feature, change the 'frame_padding' field to false on + * the IsoTpShims object returned from isotp_init_shims(...). + * + * frame_padding - true if outgoing CAN frames should be padded to a full 8 + * bytes. */ typedef struct { LogShim log; SendCanMessageShim send_can_message; SetTimerShim set_timer; + bool frame_padding; } IsoTpShims; /* Private: PCI types, for identifying each frame of an ISO-TP message. diff --git a/src/isotp/receive.h b/src/isotp/receive.h index e7e56d61..1dfd6f6d 100644 --- a/src/isotp/receive.h +++ b/src/isotp/receive.h @@ -29,8 +29,6 @@ typedef struct { IsoTpMessageReceivedHandler message_received_callback; uint16_t timeout_ms; // timeout_ms: ISO_TP_DEFAULT_RESPONSE_TIMEOUT, - bool frame_padding; - // frame_padding: ISO_TP_DEFAULT_FRAME_PADDING_STATUS, uint8_t* receive_buffer; uint16_t received_buffer_size; uint16_t incoming_message_size; diff --git a/src/isotp/send.c b/src/isotp/send.c index 798fab83..e849bb2c 100644 --- a/src/isotp/send.c +++ b/src/isotp/send.c @@ -37,7 +37,7 @@ IsoTpSendHandle isotp_send_single_frame(IsoTpShims* shims, IsoTpMessage* message } shims->send_can_message(message->arbitration_id, can_data, - 1 + message->size); + shims->frame_padding ? 8 : 1 + message->size); handle.success = true; isotp_complete_send(shims, message, true, callback); return handle; |