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

Rewrite CAN APIs #7798

Open
wants to merge 7 commits into
base: 2027
Choose a base branch
from
Open

Rewrite CAN APIs #7798

wants to merge 7 commits into from

Conversation

ThadHouse
Copy link
Member

With the requirement to support multiple CAN buses, the CAN API's need to massively change. We'll start this from the high level and go lower.

PCM, PH and PowerDistribution classes now take an explicit busId parameter, for which bus they are attached to. There is no default busId, this is always a required parameter.

The constructor for the CAN API takes a bus id now. For the sending APIs, there is now a flags parameter. This flag is for specifying FD data length and FD bitrate switching. In Java, these are separate parameters, whereas in C++ there is a single struct for these 3. For receiving APIs, theres a required output parameter passed into the APIs where all the info will be stored. This will contain the flags.

For the Low level CAN direct access API, there is no longer a way to read messages by mask and filter. This functionality was problematic on the old roborio anyway, as there was no specification for messages would be selected for the mask if multiple messages matched. Instead, you can read or write explicit CAN IDs. If you need to read a mask and filter of message IDs, either use socketcan directly, or use the stream APIs.

@ThadHouse ThadHouse requested review from a team as code owners February 18, 2025 00:31
@github-actions github-actions bot added component: wpilibj WPILib Java component: wpilibc WPILib C++ component: hal Hardware Abstraction Layer component: examples 2027 2027 target labels Feb 18, 2025
@auscompgeek
Copy link
Member

In Java, these are separate parameters, whereas in C++ there is a single struct for these 3.

Curious what the reason is here. Is it because the separate parameters are simpler to pass over JNI?

@ThadHouse
Copy link
Member Author

In Java, these are separate parameters, whereas in C++ there is a single struct for these 3.

Curious what the reason is here. Is it because the separate parameters are simpler to pass over JNI?

Yeah. To avoid the overhead of an extra object that isn't really needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2027 2027 target component: examples component: hal Hardware Abstraction Layer component: wpilibc WPILib C++ component: wpilibj WPILib Java
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants