diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-02 17:14:56 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-02 17:14:56 -0500 |
commit | 3b25a0491ce9ef9b55c903c6c7f0929bc2910d1a (patch) | |
tree | 95b61b97468093c079a19a9ad8b8f2100cf6e983 /src/isotp/isotp.h | |
parent | e3637d97ecaef1768d3f9ef40cb0204a0e668ff2 (diff) |
Allocate ISO-TP message buffer on the stack.
Diffstat (limited to 'src/isotp/isotp.h')
-rw-r--r-- | src/isotp/isotp.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/isotp/isotp.h b/src/isotp/isotp.h index c0db0178..adf0f247 100644 --- a/src/isotp/isotp.h +++ b/src/isotp/isotp.h @@ -6,19 +6,22 @@ #include <stdio.h> #define CAN_MESSAGE_BYTE_SIZE 8 +#define MAX_ISO_TP_MESSAGE_SIZE 4096 +// TODO we want to avoid malloc, and we can't be allocated 4K on the stack for +// each IsoTpMessage, so for now we're setting an artificial max message size +// 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 -const uint16_t MAX_ISO_TP_MESSAGE_SIZE; -const uint16_t MAX_CAN_FRAME_SIZE; 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; + uint8_t payload[OUR_MAX_ISO_TP_MESSAGE_SIZE]; uint16_t size; bool completed; } IsoTpMessage; @@ -121,7 +124,7 @@ void isotp_message_to_string(const IsoTpMessage* message, char* destination, size_t destination_length); IsoTpHandle isotp_send(IsoTpShims* shims, const uint16_t arbitration_id, - const uint8_t* payload, uint16_t size, + const uint8_t payload[], uint16_t size, IsoTpMessageSentHandler callback); IsoTpHandle isotp_receive(IsoTpShims* shims, |