lishen2 / isotp-c

An implementation of the ISO-TP (ISO15765-2) CAN protocol in C
MIT License
212 stars 79 forks source link

Fix issues and add callbacks. #6

Closed zwxdlut closed 5 years ago

zwxdlut commented 5 years ago

1 Add "send_callback_t" function type to IsoTpLink for sending can message. 2 Add "receive_callback_t" to IsoTpLink for receiving flow control message during muti-frame sending. 3 Add "indication_callback" to IsoTpLink for indicating upper layer when ISO-TP layer data ready. 4 Add "sys_time_ms_callback_t" to IsoTpLink for get system time in milliseconds. 5 Add "debug_callback_t" to IsoTpLink for output debug message. 6 Fix endian detection for gcc and armcc. 7 Delete function "isotp_send_with_id" because it just supports for single frame, when sending muti-frame, error will occur. 8 Add function "isotp_send_poll" for sending muti-frame.

lishen2 commented 5 years ago

Thank you for your push, it is a good way to have the user functions stay into the Isotp structure as function pointers, which can avoid confusion when multiple links coexist. I will define system related functions as pointers in the next version. But I will not add the callback like "indication_callback." For embedded systems, callbacks are very likely to increase the depth of the call stack, causing a risk of stack overflow. In addition, the send and receive functions should not be callbacks, but rather user-implemented system-related functions. Thanks again. lishen