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

fix(sensors): Share sync line control bitmasks #799

Merged
merged 6 commits into from
Aug 6, 2024

Conversation

ryanthecoder
Copy link
Contributor

I had been mistaken about the sensor hardware being shared instances but I see now that they were not, so I broke out the bitmask communication between sensor tasks into another singleton that the sensor hardware tasks can share.
I also updated the tests so that when we test with multiple sensors they actually use two different hardware instances.

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Definitely want to get these prints out. Also wait why &= 0xff ^ thing rather than &= ~thing?

[[nodiscard]] auto mask_satisfied() const -> bool {
if (set_sync_required_mask !=
static_cast<uint8_t>(SensorIdBitMask::UNUSED)) {
printf("%x is required\n", set_sync_required_mask);
Copy link
Member

Choose a reason for hiding this comment

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

mmm don't like these even they compile out


auto reset_sync(can::ids::SensorId sensor) -> void {
// force the bit for this sensor to 0
sync_state_mask &= 0xFF ^ get_mask_from_id(sensor);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sync_state_mask &= 0xFF ^ get_mask_from_id(sensor);
sync_state_mask &= ~get_mask_from_id(sensor);

?

Copy link
Member

Choose a reason for hiding this comment

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

it's the more common way I've seen, anyway

@ryanthecoder ryanthecoder force-pushed the share-sync-line-control-bitmasks branch from 69683e8 to 5d1fa27 Compare August 6, 2024 17:53
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@ryanthecoder ryanthecoder merged commit 241fb03 into main Aug 6, 2024
30 of 31 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.

2 participants