summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2013-12-30 18:30:13 -0500
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2013-12-30 18:30:13 -0500
commitbc7c0205d8dd7550060f6f0bbe8e2064d28ace8c (patch)
treebd68ac749b67fe0c5f592196e562600954417d51 /src
parent368d36cc15b69882e9d21803f3b8aa7a1c97736e (diff)
Don't use debug function directly in library.
Diffstat (limited to 'src')
-rw-r--r--src/isotp/isotp.c16
-rw-r--r--src/isotp/isotp.h7
2 files changed, 9 insertions, 14 deletions
diff --git a/src/isotp/isotp.c b/src/isotp/isotp.c
index 7c12d430..f303e214 100644
--- a/src/isotp/isotp.c
+++ b/src/isotp/isotp.c
@@ -39,15 +39,9 @@ IsoTpHandler isotp_init(IsoTpShims* shims, uint16_t arbitration_id,
return handler;
}
-// TODO this would be better as a "isotp_message_to_string"
-void log_isotp_message(const IsoTpMessage* message) {
- debug("ID: 0x%02x", message->arbitration_id);
- if(message->size > 0) {
- debug("Payload:");
- for(int i = 0; i < message->size; i++) {
- debug("0x%x", message->payload[i]);
- }
- } else {
- debug("(no payload)");
- }
+void isotp_message_to_string(const IsoTpMessage* message, char* destination,
+ size_t destination_length) {
+ snprintf(destination, destination_length,"ID: 0x%02x, Payload: 0x%llx",
+ // TODO the payload may be backwards here
+ message->arbitration_id, message->payload);
}
diff --git a/src/isotp/isotp.h b/src/isotp/isotp.h
index 619dcc69..74a4897a 100644
--- a/src/isotp/isotp.h
+++ b/src/isotp/isotp.h
@@ -3,6 +3,7 @@
#include <stdint.h>
#include <stdbool.h>
+#include <stdio.h>
#define CAN_MESSAGE_BYTE_SIZE 8
@@ -21,7 +22,7 @@ typedef struct {
const uint16_t size;
} IsoTpMessage;
-typedef void (*LogShim)(const char* message);
+typedef void (*LogShim)(const char* message, ...);
typedef bool (*SendCanMessageShim)(const uint16_t arbitration_id,
const uint8_t* data, const uint8_t size);
typedef bool (*SetTimerShim)(uint16_t time_ms, void (*callback));
@@ -88,8 +89,8 @@ void isotp_set_timeout(IsoTpHandler* handler, uint16_t timeout_ms);
void isotp_destroy(IsoTpHandler* handler);
-void log_isotp_message(const IsoTpMessage* message);
-
+void isotp_message_to_string(const IsoTpMessage* message, char* destination,
+ size_t destination_length);
#ifdef __cplusplus
}