Make TIMEOUTVALUE macro configurable via compiler flags #35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The TIMEOUTVALUE macro currently has a hardcoded value of 2500 (microseconds), which limits the ability to use the library at lower CAN bus speeds (e.g. 10 kbps). At such speeds, a single CAN frame can take longer than 2.5 ms to transmit, causing
sendMsgBufBlocking()
to timeout even under normal conditions.This commit wraps the TIMEOUTVALUE definition in a conditional
#ifndef
, allowing users to override it via compiler flags (-DTIMEOUTVALUE=20000
) or a preceding#define TIMEOUTVALUE
in their own project code before including<mcp_can.h>
.This change maintains full backward compatibility while enabling more flexible usage across diverse CAN configurations.
Example override in PlatformIO:
Recommended for projects using slow CAN speeds, high bus load, or long arbitration delays.