Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAN messages set to extended by default in only one constructor #1178

Open
calebchalmers opened this issue Jul 6, 2024 · 1 comment
Open

Comments

@calebchalmers
Copy link
Contributor

Inside can_message.hpp, there are three constructors for modm::can::Message: The first one leaves the message data initialized with all zeros and keep the default flags; this results in extended being true by default. The remaining two constructors allow for initializing with data and have an extended parameter which is false by default.

I realize this is a relatively small and breaking change, but I think it would be ideal if extended was always false by default, and if the first constructor had an extended parameter, to avoid having to declare an extra array like this:

uint8_t inData[8]{};  // all zeros array
modm::can::Message message(MESSAGE_IDENTIFIER, MESSAGE_LENGTH, inData, false);
@salkinium
Copy link
Member

I'm also tending more towards having all bits zero initialized (thus extended=0) in the default constructor. However, if we're going to break the behavior (silent failure), then we should also break the interface entirely (compilation failure). I personally don't like the CAN Message class very much, perhaps there is a better way to model this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants