diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-12-31 16:29:07 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-12-31 16:29:07 -0500 |
commit | 03c3696d34a064e40c98bb5d53c9b68967353cea (patch) | |
tree | f546d19b16f0594d48a9a3c534794dc1d409a7e2 /src | |
parent | 6bbc83bd1daac73f9e0dcccb848154a3c3b972fa (diff) |
Return completion status when receiving CAN frames.
Diffstat (limited to 'src')
-rw-r--r-- | src/isotp/isotp.c | 14 | ||||
-rw-r--r-- | src/isotp/isotp.h | 8 | ||||
-rw-r--r-- | src/isotp/receive.c | 4 | ||||
-rw-r--r-- | src/isotp/receive.h | 3 |
4 files changed, 19 insertions, 10 deletions
diff --git a/src/isotp/isotp.c b/src/isotp/isotp.c index f5b20795..58243123 100644 --- a/src/isotp/isotp.c +++ b/src/isotp/isotp.c @@ -33,23 +33,26 @@ void isotp_message_to_string(const IsoTpMessage* message, char* destination, message->arbitration_id, message->payload); } -void isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle, +bool isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle, const uint16_t arbitration_id, const uint8_t data[], const uint8_t data_length) { + bool message_completed = false; + if(data_length < 1) { - return; + return message_completed; } if(handle->type == ISOTP_HANDLE_RECEIVING) { if(handle->receive_handle.arbitration_id != arbitration_id) { - return; + return message_completed; } } else if(handle->type == ISOTP_HANDLE_SENDING) { if(handle->send_handle.receiving_arbitration_id != arbitration_id) { - return; + return message_completed; } } else { shims->log("The ISO-TP handle is corrupt"); + return message_completed; } IsoTpProtocolControlInformation pci = (IsoTpProtocolControlInformation) @@ -73,11 +76,12 @@ void isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle, size: payload_length }; - isotp_handle_single_frame(handle, &message); + message_completed = isotp_handle_single_frame(handle, &message); break; } default: shims->log("Only single frame messages are supported"); break; } + return message_completed; } diff --git a/src/isotp/isotp.h b/src/isotp/isotp.h index e3ec588a..4f58dac4 100644 --- a/src/isotp/isotp.h +++ b/src/isotp/isotp.h @@ -93,7 +93,13 @@ IsoTpShims isotp_init_shims(LogShim log, SendCanMessageShim send_can_message, SetTimerShim set_timer); -void isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle, +/* Public: + * + * Returns true if a complete ISO-TP message was sent or received as of + * processing this CAN frame. Check the 'success' and 'completed' flag on the + * handle to make sure. + */ +bool isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle, const uint16_t arbitration_id, const uint8_t data[], const uint8_t size); diff --git a/src/isotp/receive.c b/src/isotp/receive.c index 1d623384..e69c59b7 100644 --- a/src/isotp/receive.c +++ b/src/isotp/receive.c @@ -1,8 +1,8 @@ #include <isotp/receive.h> -void isotp_handle_single_frame(IsoTpHandle* handle, - IsoTpMessage* message) { +bool isotp_handle_single_frame(IsoTpHandle* handle, IsoTpMessage* message) { isotp_complete_receive(handle, message); + return true; } void isotp_complete_receive(IsoTpHandle* handle, IsoTpMessage* message) { diff --git a/src/isotp/receive.h b/src/isotp/receive.h index b7c17963..b01e12de 100644 --- a/src/isotp/receive.h +++ b/src/isotp/receive.h @@ -11,8 +11,7 @@ extern "C" { void isotp_complete_receive(IsoTpHandle* handle, IsoTpMessage* message); -void isotp_handle_single_frame(IsoTpHandle* handle, - IsoTpMessage* message); +bool isotp_handle_single_frame(IsoTpHandle* handle, IsoTpMessage* message); #ifdef __cplusplus } |