diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-03 14:29:55 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-03 14:29:55 -0500 |
commit | 980d26f9dfc4eb5b8da0dc786f733110be265aea (patch) | |
tree | 333355e7c84f1642addac359e41987e927be7fa0 /src/isotp/receive.h | |
parent | a5e910714733f309b6db18f6017c6f0864e20d38 (diff) |
Document all functions in header files.
Diffstat (limited to 'src/isotp/receive.h')
-rw-r--r-- | src/isotp/receive.h | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/src/isotp/receive.h b/src/isotp/receive.h index 438d0824..e7e56d61 100644 --- a/src/isotp/receive.h +++ b/src/isotp/receive.h @@ -9,13 +9,74 @@ extern "C" { #endif -void isotp_complete_receive(IsoTpReceiveHandle* handle, IsoTpMessage* message); +/* Public: A handle for beginning and continuing receiving a single ISO-TP + * message - both single and multi-frame. + * + * Since an ISO-TP message may contain multiple frames, we need to keep a handle + * around while waiting for subsequent CAN messages to complete the message. + * This struct encapsulates the local state required. + * + * completed - True if the received message request is completely finished. + * success - True if the message request was successful. The value if this field + * isn't valid if 'completed' isn't true. + */ +typedef struct { + bool completed; + bool success; -bool isotp_handle_single_frame(IsoTpReceiveHandle* handle, IsoTpMessage* message); + // Private + uint16_t arbitration_id; + 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; + // TODO timer callback for multi frame +} IsoTpReceiveHandle; +/* Public: Initiate receiving a single ISO-TP message on a particular + * arbitration ID. + * + * Note that no actual CAN data has been received at this point - this just sets + * up a handle to be used when new CAN messages to arrive, so they can be parsed + * as potential single or multi-frame ISO-TP messages. + * + * shims - Low-level shims required to send and receive CAN messages, etc. + * arbitration_id - The arbitration ID to receive the message on. + * callback - an optional function to be called when the message is completely + * received (use NULL if no callback required). + * + * Returns a handle to be used with isotp_continue_receive when a new CAN frame + * arrives. The 'completed' field in the returned IsoTpReceiveHandle will be true + * when the message is completely sent. + */ IsoTpReceiveHandle isotp_receive(IsoTpShims* shims, const uint16_t arbitration_id, IsoTpMessageReceivedHandler callback); +/* Public: Continue to receive a an ISO-TP message, based on a freshly + * received CAN message. + * + * For a multi-frame ISO-TP message, this function must be called + * repeatedly whenever a new CAN message is received in order to complete + * receipt. + * + * TODO does this API work for if we wanted to receive an ISO-TP message and + * send our own flow control messages back? + * + * shims - Low-level shims required to send and receive CAN messages, etc. + * handle - An IsoTpReceiveHandle previously returned by isotp_receive(...). + * arbitration_id - The arbitration_id of the received CAN message. + * data - The data of the received CAN message. + * size - The size of the data in the received CAN message. + * + * Returns an IsoTpMessage with the 'completed' field set to true if a message + * was completely received. If 'completed' is false, more CAN frames are + * required to complete the messages, or the arbitration ID didn't match this + * 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, const uint8_t data[], const uint8_t size); |