Skip to content

Web: Fix CAN options visibility for non-CAN boards#227

Open
garvit000 wants to merge 3 commits intoArduPilot:mainfrom
garvit000:clean-can-fix
Open

Web: Fix CAN options visibility for non-CAN boards#227
garvit000 wants to merge 3 commits intoArduPilot:mainfrom
garvit000:clean-can-fix

Conversation

@garvit000
Copy link

This PR fixes #151 where the "CAN" feature category remained visible even when selecting a board that does not support CAN.
Changes:

Test Plan:

  • Select "CubeOrange" → Verify "CAN" category is visible
  • Select "KakuteF4-Mini" → Verify "CAN" category is hidden

Supersedes #209 with a cleaner implementation addressing all review feedback.

Closes #151

@shiv-tyagi
Copy link
Member

Before I do a review, can you please tell did you test it? And what cases did you cover?

Also, it is generally not recommended to close existing PRs without a good reason. We lose review history that way.

@garvit000
Copy link
Author

@shiv-tyagi Yes I tested it with cubeorange and mupilot where CAN was visible and kakutef4mini where CAN was hidden.
The categories are refreshing when switching boards, also I have just pushed an extra commit to follow all hwdef include directives fixing detection for mupilot.
Regarding the PR I apologize for closing it without discussion, should i reopen it?

@garvit000
Copy link
Author

Waiting for reply @shiv-tyagi

Copy link
Member

@shiv-tyagi shiv-tyagi left a comment

Choose a reason for hiding this comment

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

Hi @garvit000. Sorry for replying late. I am busy with some other stuff.

Thanks for all your efforts.

I still need to take out some time to test this. Also, the structuring of this code is problematic. We need organise it better. I have posted some comments. I might post comments again once you fix there till we reach a good shape. But I cannot promise if I would be able to reply fast.

Comment on lines +207 to +210
- A list contains boards for NON-'ap_periph' targets.
- A list contains boards for the 'ap_periph' target.
- A list of Boards for NON-'ap_periph' targets.
- A list of Boards for the 'ap_periph' target.
Copy link
Member

Choose a reason for hiding this comment

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

Return statement shows two element tuple but comment says four why?

Copy link
Author

Choose a reason for hiding this comment

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

I think while rebasing i accepted both changes, have fixed that now

Comment on lines +239 to +243
# Invalidate stale cache entries that contain dicts instead of Board objects
if non_periph_boards and isinstance(non_periph_boards[0], dict):
self.logger.debug("Stale cache entry found, treating as cache miss")
return None

Copy link
Member

Choose a reason for hiding this comment

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

We can remove this. I mentioned this in one of my previous reviews as well that we can handle this cleanup manually.

vehicle_id=vehicle_id,
)

board_dicts = [board.to_dict() for board in boards]
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to convert board to dict?

Comment on lines +184 to +188
for board in boards:
if board.id == board_id or board.name == board_id:
board_has_can = bool(board.attributes.get("has_can"))
break

Copy link
Member

Choose a reason for hiding this comment

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

I think this is still not the right way to do it. We need to have methods in ap src metadata fetcher to return features for boards. We should not pollute the code here.

Comment on lines +387 to +404
non_periph_boards = self.__exclude_boards_matching_patterns(
boards=non_periph_boards,
patterns=['fmuv*', 'SITL*'],
)
self.logger.debug(f"non_periph_boards filtered: {non_periph_boards}")

non_periph_boards_sorted = sorted(non_periph_boards)
periph_boards_sorted = sorted(periph_boards)
non_periph_boards_sorted = sorted(non_periph_boards)
periph_boards_sorted = sorted(periph_boards)

self.logger.debug(
f"non_periph_boards sorted: {non_periph_boards_sorted}"
)
self.logger.debug(f"periph_boards sorted: {periph_boards_sorted}")
self.logger.debug(
f"non_periph_boards sorted: {non_periph_boards_sorted}"
)
self.logger.debug(f"periph_boards sorted: {periph_boards_sorted}")

return (
non_periph_boards_sorted,
periph_boards_sorted,
)
return (
self.__build_board_metadata(non_periph_boards_sorted, hwdef_dir),
self.__build_board_metadata(periph_boards_sorted, hwdef_dir),
)
Copy link
Member

Choose a reason for hiding this comment

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

Can we keep the sorting piece of code out of checkout locking and build board metadata early?

@garvit000
Copy link
Author

I have moved the logic from vehicles to meta data fetcher and addressed other comments, have a look at them when you are not busy.

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.

Dont present CAN items if CAN is not present in hwdef

2 participants