Document all functions in header files.
[apps/agl-service-can-low-level.git] / src / isotp / isotp_types.h
index 6449745..aabca74 100644 (file)
 extern "C" {
 #endif
 
+/* Private: The default timeout to use when waiting for a response during a
+ * multi-frame send or receive.
+ */
 const uint8_t ISO_TP_DEFAULT_RESPONSE_TIMEOUT;
-const bool ISO_TP_DEFAULT_FRAME_PADDING_STATUS;
 
-typedef struct {
-    const uint16_t arbitration_id;
-    uint8_t payload[OUR_MAX_ISO_TP_MESSAGE_SIZE];
-    uint16_t size;
-    bool completed;
-} IsoTpMessage;
+/* Private: Determines if by default, padding is added to ISO-TP message frames.
+ */
+const bool ISO_TP_DEFAULT_FRAME_PADDING_STATUS;
 
+/* Public: The type signature for an optional logging function, if the user
+ * wishes to provide one. It should print, store or otherwise display the
+ * message.
+ *
+ * message - A format string to log using the given parameters.
+ * ... (vargs) - the parameters for the format string.
+ */
 typedef void (*LogShim)(const char* message, ...);
+/* Public: The type signature for a function to send a single CAN message.
+ *
+ * arbitration_id - The arbitration ID of the message.
+ * data - The data payload for the message. NULL is valid if size is also 0.
+ * size - The size of the data payload, in bytes.
+ *
+ * Returns true if the CAN message was sent successfully.
+ */
 typedef bool (*SendCanMessageShim)(const uint16_t arbitration_id,
         const uint8_t* data, const uint8_t size);
+
+/* Public: The type signature for a... TODO, not used yet.
+ */
 typedef bool (*SetTimerShim)(uint16_t time_ms, void (*callback));
 
-typedef void (*IsoTpMessageReceivedHandler)(const IsoTpMessage* message);
-typedef void (*IsoTpMessageSentHandler)(const IsoTpMessage* message,
+/* Public: The signature for a function to be called when an ISO-TP message has
+ * been completely received.
+ *
+ * message - The received message.
+ */
+typedef void (*IsoTpMessageReceivedHandler)(const struct IsoTpMessage* message);
+
+/* Public: the signature for a function to be called when an ISO-TP message has
+ * been completely sent, or had a fatal error during sending.
+ *
+ * message - The sent message.
+ * success - True if the message was sent successfully.
+ */
+typedef void (*IsoTpMessageSentHandler)(const struct IsoTpMessage* message,
         const bool success);
-typedef void (*IsoTpCanFrameSentHandler)(const IsoTpMessage* message);
 
+/* Public: The signature for a function to be called when a CAN frame has been
+ * sent as as part of sending or receive an ISO-TP message.
+ *
+ * This is really only useful for debugging the library itself.
+ *
+ * message - The ISO-TP message that generated this CAN frame.
+ */
+typedef void (*IsoTpCanFrameSentHandler)(const struct IsoTpMessage* message);
+
+/* Public: A container for a sent or received ISO-TP message.
+ *
+ * completed - An IsoTpMessage is the return value from a few functions - this
+ *      attribute will be true if the message is actually completely received.
+ *      If the function returns but is only partially through receiving the
+ *      message, this will be false and you should not consider the other data
+ *      to be valid.
+ * arbitration_id - The arbitration ID of the message.
+ * payload - The optional payload of the message - don't forget to check the
+ *      size!
+ * size -  The size of the payload. The size will be 0 if there is no payload.
+ */
+typedef struct {
+    const uint16_t arbitration_id;
+    uint8_t payload[OUR_MAX_ISO_TP_MESSAGE_SIZE];
+    uint16_t size;
+    bool completed;
+} IsoTpMessage;
+
+/* Public: A container for the 3 shim functions used by the library to interact
+ * with the wider system.
+ *
+ * Use the isotp_init_shims(...) function to create an instance of this struct.
+ */
 typedef struct {
     LogShim log;
     SendCanMessageShim send_can_message;
     SetTimerShim set_timer;
 } IsoTpShims;
 
-typedef struct {
-    bool success;
-    bool completed;
-    uint16_t arbitration_id;
-    IsoTpMessageReceivedHandler message_received_callback;
-
-    // Private
-    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;
-
+/* Private: PCI types, for identifying each frame of an ISO-TP message.
+ */
 typedef enum {
     PCI_SINGLE = 0x0,
     PCI_FIRST_FRAME = 0x1,
@@ -66,6 +112,8 @@ typedef enum {
     PCI_FLOW_CONTROL_FRAME = 0x3
 } IsoTpProtocolControlInformation;
 
+/* Private: PCI flow control identifiers.
+ */
 typedef enum {
     PCI_FLOW_STATUS_CONTINUE = 0x0,
     PCI_FLOW_STATUS_WAIT = 0x1,