summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2014-01-05 15:43:26 -0500
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2014-01-05 15:43:43 -0500
commitef06cb3a05d45df7a04cf91ab5c0b233fdf2bd48 (patch)
tree795869c8418953b7ef522cf13a53277032c683cb /src
parent8922abb7ff8c30e1fa5af078284eb6aebf0052e5 (diff)
Move a few things about to make compiling with other projects possible.
Diffstat (limited to 'src')
-rw-r--r--src/isotp/isotp.c3
-rw-r--r--src/isotp/isotp_types.h56
-rw-r--r--src/isotp/receive.c14
-rw-r--r--src/isotp/send.c2
4 files changed, 38 insertions, 37 deletions
diff --git a/src/isotp/isotp.c b/src/isotp/isotp.c
index c8b0a561..f115810e 100644
--- a/src/isotp/isotp.c
+++ b/src/isotp/isotp.c
@@ -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; */
/* } */
diff --git a/src/isotp/isotp_types.h b/src/isotp/isotp_types.h
index aabca740..d9fe4601 100644
--- a/src/isotp/isotp_types.h
+++ b/src/isotp/isotp_types.h
@@ -12,18 +12,37 @@
// 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.
diff --git a/src/isotp/receive.c b/src/isotp/receive.c
index bfbf16fd..65390648 100644
--- a/src/isotp/receive.c
+++ b/src/isotp/receive.c
@@ -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 = {
diff --git a/src/isotp/send.c b/src/isotp/send.c
index 13db064c..798fab83 100644
--- a/src/isotp/send.c
+++ b/src/isotp/send.c
@@ -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