-
Notifications
You must be signed in to change notification settings - Fork 202
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 #263, expose IsValidMsgID and partially address #245 Consistent use of MsgId types #602
Fix #263, expose IsValidMsgID and partially address #245 Consistent use of MsgId types #602
Conversation
* \brief Translation macro to convert from MsgId integer values to opaque/abstract API values | ||
* | ||
* This conversion exists in macro form to allow compile-time evaluation for constants, and | ||
* should not be used directly in application code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather thse be in a separate file if it's not intended for application use, since this file is pulled into the API by doxygen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the problem is the same logic is needed by CFE_SB_MsgIdToValue/ValueToMsgId and these are inline functions within the same file, so the macro needs to be available.
By "application code' really I mean runtime -- the reason these need to exist in macro form is because one cannot use the inline function when initializing data at compile-time. I want to encourage use of the inline functions whenever possible because its more type safe, but occasionally one does need an expression that evaluates at compile-time, and its those times that the macro needs to be used instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still could be in different file and just include, which provides a clear separation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But there is a possible valid case for using it externally, where one actually needs a value that evaluates at compile time.
The preference should always be to use the inline function, but there are some places (e.g. global variable init) where they don't work.
As there are no applications using this and the decision isn't made yet as to how MsgIds will be defined in the future, I suppose I could put this into a new file in the private/
subdir if that helps, but that seems like overkill to make a new file for just this.
But No matter how we define MID's in the future, I would think we'd need something that can be evaluated at compile time....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the documentation was clarified to indicate "application runtime code" rather than just "application code"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, from a naive user point of view I wouldn't know the difference. No biggie, I just don't like huge header files to begin with, especially containing things that have different uses. Wouldn't have to be in private, just prefer separation.
d0c0b6b
to
f0b101f
Compare
f0b101f
to
67eaf73
Compare
NOTE: commit 67eaf73 is only for a minor cleanup in unit test file sb_UT.c. Didn't realize this was re-reviewed since my last push, but it is largely the same thing. I had just mistakenly pushed to my fork a little earlier than I should have. At any rate, this version basically assumes that the Nonetheless, this should be (hopefully) good to go now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split out exposing CFE_SB_IsValidMsgId.
This also more properly defines the the CFE_SB_INVALID_MSG_ID macro for external use going forward.
Make CFE core apps consistent in their use of the CFE_SB_MsgId type and with the CFE SB API. This employs the CFE SB API whenever any of the following needs to happen: - Use of a CFE_SB_MsgId_t value within a printf (event, syslog, etc). - Initialization of a CFE_SB_MsgId_t from an integer value - Comparison of two CFE_SB_MsgId_t values - Checking if a CFE_SB_MsgId_t value is within the valid set A few new macros are introduced, mainly because the inline functions that already existed for this purpose cannot be used where evaluation must be done at compile time (e.g. constants, struct initialization). These are initially just typecasts, but could become more interesting in future revisions.
67eaf73
to
51c599c
Compare
Same basic changeset, in two commits now. |
CCB 20200415 - APPROVED |
@jphickey can you work with @dmknutsen and resolve the conflicts between this #578 and #635 ? |
Describe the contribution
Fixes #263
This exposes the
CFE_SB_IsValidMsgId()
in the CFE SB public API, rather than confining it to the private/internal API.Partially addresses #245
This also includes a number of internal changes to make CFE core apps consistent in their use of the CFE_SB_MsgId type and with the CFE SB API. This employs the appropriate CFE SB abstraction API whenever any of the following needs to happen:
Notable exception to integer conversion rules is for the MID
#define
values, which are not changed for backward compatibility reasons. These are still defined as integers, and used directly in the code.Also worth noting - this replaces the switch/case constructs used in message dispatch with a nested if/else based on CFE_SB_MsgId_Equal(), as the switch statement can only be used with an integer.
A few new macros are introduced, mainly because the inline functions that already existed for this purpose cannot be used where evaluation must be done at compile time (e.g. constants, struct initialization). These are initially just typecasts, but could become more interesting
in future revisions.
Testing performed
Build with SIMULATION=native ENABLE_UNIT_TESTS=TRUE
cmdUtil
. Ensure no changes to message routing/processing for every core app.Expected behavior changes
This exposes the
CFE_SB_IsValidMsgId()
for application usage.No other API or behavior changes. All other changes are transparent.
System(s) tested on
Ubuntu 18.04 LTS 64 bit
Additional context
This is a step in the direction of related issue #245 but does not do anything that would affect backward compatibility with the way the MID integers are currently defined and used. It does introduce a few of the macros that will become more relevant/necessary (i.e. so they can evolve beyond a simple typecast/passthrough).
Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.
EDIT added reference for MsgId handling