Skip to content

Conversation

@jwest115
Copy link
Collaborator

@jwest115 jwest115 commented Jun 10, 2025

Related to nasa/fprime#3714, in C++ codegen, cast opcodes, event IDs, channel IDs, etc. to their respective types (ie: FwOpcodeType, FwEventIdType, FwChanIdType, etc.). This helps avoid implicit type conversion warnings that occur when building.

Partially addresses nasa/fprime#3529 (fprime updates are included in nasa/fprime#3714).

@jwest115 jwest115 requested a review from bocchino June 10, 2025 21:26
@jwest115 jwest115 marked this pull request as ready for review June 11, 2025 16:56
Copy link
Collaborator

@bocchino bocchino left a comment

Choose a reason for hiding this comment

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

This PR looks good and correct, but I thought we were moving towards having a single ID type for all these IDs. If we add all these casts, won't we just need to delete them later? Does anything go wrong now if we omit these casts?

@bocchino
Copy link
Collaborator

This helps avoid implicit type conversion warnings that occur when building.

Do these warnings occur when, for example, the channel ID type is smaller than the base ID type? If so, maybe the answer is to unify the types.

@jwest115
Copy link
Collaborator Author

I will double check the case of having the type smaller than the base ID type and get back to you!

@jwest115
Copy link
Collaborator Author

I ran without these changes and tried the case where FwChanIdType is smaller (U16) than the FwIdType (U32) and received the implicit conversion warnings. Currently in fprime, all of the id types are aliases of the FwIdType, maybe that is sufficient? However, if a user configures any of those id types to something different they will hit the warning.

@jwest115
Copy link
Collaborator Author

jwest115 commented Jun 24, 2025

@LeStarch do you think there is a use case for configuring an ID type (like FwEventIdType or FwChanIdType for instance) to something smaller than the base ID type (ie: FwIdType)? Maybe casting the IDs is not a good idea since it would in a way "suppress" the implicit conversion warnings and wouldn't alert users that their IDs are smaller than the base ID?

@LeStarch
Copy link
Collaborator

@jwest115 when would a channel ID or command ID ever not be of exactly base ID type? It seems odd that we'd ever allow users to configure something different, because that could silently break the system.

I can see users wanting to have a smaller ID to save downlink, but I feel the appropriate action would be to shrink the base ID field across the board.

Am I missing something here?

@jwest115
Copy link
Collaborator Author

jwest115 commented Jun 24, 2025

@LeStarch in this PR we introduced a new alias type FwIdType. All of the IDs are aliases of that type, however, a user could configure them to be something different. It almost seems like we shouldn't have types for each of the IDs and rather just a single ID type, since we wouldn't want any of the ID types to stray away from the base ID type.

@LeStarch
Copy link
Collaborator

@jwest115 that is what I was concluding too. I think it would be dangerous to have ID types that are functionally not capable of storing a complete ID. @bocchino, @timcanham thoughts?

@jwest115
Copy link
Collaborator Author

jwest115 commented Jul 7, 2025

Closing since we decided to not add casts at this time.

@jwest115 jwest115 closed this Jul 7, 2025
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