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

Fixed FOME CAN data bus selection #275

Merged
merged 2 commits into from
Oct 31, 2023
Merged

Fixed FOME CAN data bus selection #275

merged 2 commits into from
Oct 31, 2023

Conversation

Krakert
Copy link
Contributor

@Krakert Krakert commented Oct 28, 2023

pass the CAN bus via the transmitStruct to CanTxMessage::CanTxMessage, bus is by default 0, now looks at the setting from TS, bool canBroadcastUseChannelTwo.

@@ -216,17 +216,18 @@ static void populateFrame(Odometry& msg) {
void sendCanVerbose() {
auto base = engineConfiguration->verboseCanBaseAddress;
auto isExt = engineConfiguration->rusefiVerbose29b;

Copy link
Contributor

Choose a reason for hiding this comment

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

omg the tabs! 😆

@@ -112,9 +112,9 @@ class CanTxTyped final : public CanTxMessage
};

template <typename TData>
void transmitStruct(uint32_t id, bool isExtended)
void transmitStruct(uint32_t id, bool isExtended, bool canChannel = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be a size_t ("bus")?

line 31:

explicit CanTxMessage(uint32_t eid, uint8_t dlc = 8, size_t bus = 0, bool isExtended = false);

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's make this parameter canChannel non-optional - that's sort of what got us in this mess in the first place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we update CanTxMessage::CanTxMessage so that inside the function we look at which bus to use?

CanTxMessage::CanTxMessage(uint32_t eid, uint8_t dlc, bool isExtended)

Or do we want to changed transmitStruct so that we need to pass the bus to the function?

void transmitStruct(uint32_t id, bool isExtended, bool canChannel)

Copy link
Collaborator

Choose a reason for hiding this comment

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

so that inside the function we look at which bus to use?

eh? All I mean by my comment was to remove = false on line 115 here.

Copy link
Contributor Author

@Krakert Krakert Oct 30, 2023

Choose a reason for hiding this comment

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

When I change that, I need to update all uses for transmitStruct

transmitStruct<Aim5f5>(0x5f5, false);
transmitStruct<Aim5f6>(0x5f6, false);
transmitStruct<Aim5f7>(0x5f7, false);
auto canChannel = engineConfiguration->canBroadcastUseChannelTwo;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is not "canChannel" a less than ideal name for "use second channel"? also what if soon more than two buses would be supported? A few of stm32f7 have three CAN buses.

Copy link
Contributor Author

@Krakert Krakert Oct 30, 2023

Choose a reason for hiding this comment

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

Now canBroadcastUseChannelTwo is a Bool, CAN 2 is a true / 1 so when more CAN buses are added we can switch to a int which keeps the logic the same.
0 -> CAN1
1 -> CAN2
2 -> CAN3

Copy link
Contributor

@rusefillc rusefillc Oct 30, 2023

Choose a reason for hiding this comment

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

So why not "size_t busIndex = engineConfiguration->canBroadcastUseChannelTwo;" to keep the... technical debt most localized?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yea, that was going to be my next comment, we should really be doing size_t busIndex = engineConfiguration->canBroadcastUseChannelTwo ? 1 : 0

@@ -91,7 +91,7 @@ class CanTxTyped final : public CanTxMessage
#endif // EFI_CAN_SUPPORT

public:
explicit CanTxTyped(uint32_t id, bool isExtended) : CanTxMessage(id, sizeof(TData), isExtended) { }
explicit CanTxTyped(uint32_t id, bool isExtended, bool canChannel) : CanTxMessage(id, sizeof(TData), canChannel, isExtended) { }
Copy link
Contributor

Choose a reason for hiding this comment

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

bool to size_t conversion heh?

@mck1117 mck1117 merged commit 4e44e41 into FOME-Tech:master Oct 31, 2023
21 checks passed
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.

4 participants