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

MLC - CAN IO implementation #63

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

jpfbastos
Copy link
Contributor

No description provided.

Copy link

linear bot commented Jan 23, 2025

@jpfbastos jpfbastos marked this pull request as ready for review January 23, 2025 19:30
Copy link
Collaborator

@davidbeechey davidbeechey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, nearly there just a few things here and there to be fixed/added

lib/io/hyped_can/hyped_can_derive/src/lib.rs Outdated Show resolved Hide resolved
lib/io/hyped_can/src/lib.rs Outdated Show resolved Hide resolved
lib/io/hyped_can/src/lib.rs Outdated Show resolved Hide resolved
lib/io/hyped_can/hyped_can_derive/src/lib.rs Show resolved Hide resolved
lib/io/hyped_can/hyped_can_derive/src/lib.rs Outdated Show resolved Hide resolved
lib/io/hyped_can/hyped_can_derive/src/lib.rs Outdated Show resolved Hide resolved
boards/stm32f767zi/Cargo.lock Outdated Show resolved Hide resolved
Comment on lines 39 to 53
Err(embassy_stm32::can::enums::TryReadError::BusError(e)) => Err(match e {
embassy_stm32::can::enums::BusError::Stuff => CanError::Stuff,
embassy_stm32::can::enums::BusError::Form => CanError::Form,
embassy_stm32::can::enums::BusError::Acknowledge => CanError::Acknowledge,
embassy_stm32::can::enums::BusError::BitRecessive => CanError::BitRecessive,
embassy_stm32::can::enums::BusError::BitDominant => CanError::BitDominant,
embassy_stm32::can::enums::BusError::Crc => CanError::Crc,
embassy_stm32::can::enums::BusError::Software => CanError::Software,
embassy_stm32::can::enums::BusError::BusOff => CanError::BusOff,
embassy_stm32::can::enums::BusError::BusPassive => CanError::BusPassive,
embassy_stm32::can::enums::BusError::BusWarning => CanError::BusWarning,
}),
Err(embassy_stm32::can::enums::TryReadError::Empty) => Err(CanError::Empty),
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing you could do here, is impl From<BusError> for CanError where CanError is defined, then you can just return e.into() here. that might be overkill tho

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i tried doing that - however i needed to add embassy-stm32 to the Cargo.toml file, which can't be done as it would make it board specific

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, does that also happen if you don't enable a board in the features?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if i fully understood the question, but basically the moment you write impl From<CanError> for embassy_stm32::can::BusError for example, I get failed to resolve: use of undeclared crate or module embassy_stm32 use of undeclared crate or module embassy_stm32

so i would have to import it in that case, but not sure if that's what you were asking

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can clarify a couple of things here:

  • Reason why we can't use From here is because the embassy type BusError and our type HypedCanError are both defined in other crates and rust doesn't let you do that.
  • The options then become adding the From stuff to the crate where HypedCanError is defined, which would require importing embassy_stm32 (but we can't import embassy_stm32 without enabling exactly one board feature), or moving the HypedCanError enum to the code in hyped_can_derive which I don't think is possible because that would create separate versions for each board's IO where the macro is used

lib/io/hyped_can/hyped_can_derive/src/lib.rs Outdated Show resolved Hide resolved
lib/io/hyped_can/hyped_can_derive/src/lib.rs Outdated Show resolved Hide resolved
lib/io/hyped_can/hyped_can_derive/src/lib.rs Show resolved Hide resolved
lib/io/hyped_can/src/lib.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants