Move a few things about to make compiling with other projects possible.
authorChristopher Peplin <chris.peplin@rhubarbtech.com>
Sun, 5 Jan 2014 20:43:26 +0000 (15:43 -0500)
committerChristopher Peplin <chris.peplin@rhubarbtech.com>
Sun, 5 Jan 2014 20:43:43 +0000 (15:43 -0500)
src/isotp/isotp.c
src/isotp/isotp_types.h
src/isotp/receive.c
src/isotp/send.c

index c8b0a56..f115810 100644 (file)
@@ -1,9 +1,6 @@
 #include <isotp/isotp.h>
 #include <bitfield/bitfield.h>
 
-const uint8_t ISO_TP_DEFAULT_RESPONSE_TIMEOUT = 100;
-const bool ISO_TP_DEFAULT_FRAME_PADDING_STATUS = true;
-
 /* void isotp_set_timeout(IsoTpHandler* handler, uint16_t timeout_ms) { */
     /* handler->timeout_ms = timeout_ms; */
 /* } */
index aabca74..d9fe460 100644 (file)
 // here - since we only handle single frame messages, 8 bytes is plenty.
 #define OUR_MAX_ISO_TP_MESSAGE_SIZE 8
 
-#ifdef __cplusplus
-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;
+#define ISO_TP_DEFAULT_RESPONSE_TIMEOUT 100
 
 /* Private: Determines if by default, padding is added to ISO-TP message frames.
  */
-const bool ISO_TP_DEFAULT_FRAME_PADDING_STATUS;
+#define ISO_TP_DEFAULT_FRAME_PADDING_STATUS true
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* 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: The type signature for an optional logging function, if the user
  * wishes to provide one. It should print, store or otherwise display the
@@ -53,7 +72,7 @@ typedef bool (*SetTimerShim)(uint16_t time_ms, void (*callback));
  *
  * message - The received message.
  */
-typedef void (*IsoTpMessageReceivedHandler)(const struct IsoTpMessage* message);
+typedef void (*IsoTpMessageReceivedHandler)(const 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.
@@ -61,7 +80,7 @@ typedef void (*IsoTpMessageReceivedHandler)(const struct IsoTpMessage* message);
  * message - The sent message.
  * success - True if the message was sent successfully.
  */
-typedef void (*IsoTpMessageSentHandler)(const struct IsoTpMessage* message,
+typedef void (*IsoTpMessageSentHandler)(const IsoTpMessage* message,
         const bool success);
 
 /* Public: The signature for a function to be called when a CAN frame has been
@@ -71,26 +90,7 @@ typedef void (*IsoTpMessageSentHandler)(const struct IsoTpMessage* message,
  *
  * 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;
+typedef void (*IsoTpCanFrameSentHandler)(const IsoTpMessage* message);
 
 /* Public: A container for the 3 shim functions used by the library to interact
  * with the wider system.
index bfbf16f..6539064 100644 (file)
@@ -1,16 +1,18 @@
 #include <isotp/receive.h>
+#include <bitfield/bitfield.h>
+#include <string.h>
 
-bool isotp_handle_single_frame(IsoTpReceiveHandle* handle, IsoTpMessage* message) {
-    isotp_complete_receive(handle, message);
-    return true;
-}
-
-void isotp_complete_receive(IsoTpReceiveHandle* handle, IsoTpMessage* message) {
+static void isotp_complete_receive(IsoTpReceiveHandle* handle, IsoTpMessage* message) {
     if(handle->message_received_callback != NULL) {
         handle->message_received_callback(message);
     }
 }
 
+bool isotp_handle_single_frame(IsoTpReceiveHandle* handle, IsoTpMessage* message) {
+    isotp_complete_receive(handle, message);
+    return true;
+}
+
 IsoTpReceiveHandle isotp_receive(IsoTpShims* shims,
         const uint16_t arbitration_id, IsoTpMessageReceivedHandler callback) {
     IsoTpReceiveHandle handle = {
index 13db064..798fab8 100644 (file)
@@ -1,4 +1,6 @@
 #include <isotp/send.h>
+#include <bitfield/bitfield.h>
+#include <string.h>
 
 #define PCI_NIBBLE_INDEX 0
 #define PAYLOAD_LENGTH_NIBBLE_INDEX 1