-
Notifications
You must be signed in to change notification settings - Fork 217
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 #821, add accessor functions for version strings #824
Fix #821, add accessor functions for version strings #824
Conversation
620d004
to
7576fed
Compare
Corrected some whitespace style diffs, passed through clang-format-10 again. |
If folks like this general approach (and I do think its much better than using a macro) then two more suggestions/questions:
|
Seems like a better approach than OSAL_API_VERSION (runtime vs compile time)
I can't think of any reason why not... |
I vote for keeping it a string and letting people create their own parsers for SemVer if they care. When I was looking into this a while ago, it seems like the standard practice is to have a plain-text VERSION file with a string and the code then grabs this info from the file when reporting. Granted, I didn't do an exhaustive search or literature review: |
@CDKnightNASA I don't think we are proposing removing the string version, just adding the API to get numbers. |
I was referring to Joe's question (1) about getting each element as a number in adition to a string. What would be the impact of removing the MAJOR, MINOR, etc. macros altogether? |
Well, it would simplify things, for sure :-) I guess the advantage of reporting version as a set of 4 integers is that it limits the version to four integers. If its a free form string, then (by definition) formatting isn't strictly enforced, it is only a matter of time until someone releases an OSAL version tagged as But the only actual use of numeric version that I can think of is to determine API compatibility at application compile-time (e.g. to check of compiling with a version of OSAL that has a certain function implemented). There are other ways to address that problem though - Checking a 4-part version number is rather complex to do correctly and not an ideal indicator of API level. |
Checking the code again - we do have a With that - as far as I can tell I don't see any real value for keeping the individual integers - EXCEPT for the comment earlier about the fact that it implicitly enforces that version is always expressible as four simple integers. If we don't need to restrict this, then numbers should probably go away. |
OK - I did think of another possible use case for the numeric version number - it currently refers to the last "official" release, and is actually the only way to get that info.
The problem is that the latter is not really parseable - it is a human-friendly string, not a code-friendly string. So if code needs to report the official release, the only way to do so is to print the entire description string, which has a lot of other stuff in it. There is no way to get the official release version in isolation from the rest of the info. Not meaning to add another option to the mix - but if we DO keep the numeric version and define it as the "official release" - this means that the long description string becomes redundant. All of the real info in that string would become obtainable separately, so CFE could simply pretty-print the info on its own. So the set API-accessible version items becomes:
When CFE pretty-prints in its reporting event, it can just assemble all of these elements together (easy enough). While not a huge simplification, it does mean that CFE-generated events would be consistently formatted. Right now these long strings are somewhat arbitrary and not necessarily identical between components. (note that today some have newlines, some do not, capitalization and punctuation varies) |
Final thought on that - as long as we don't care about restricting to numbers, we could also make (3) above as a string, too. In that case "baseline" (1) and "last official release" (3) would report identical strings on official releases, but different strings on development versions. This makes it easy to tell the different when reporting. I'll put this aside and wait for consensus before updating this PR. In the meantime in nasa/cFE#1170 (which was the impetus of all this) I've worked around this in a temporary/interim method which is probably good enough for now - but I would definitely like to get something more coherent for the 6.0 release - right now our version reporting is still a mis-mosh of different ideas and patterns and really hard to understand. |
The numbers are used in telemetry though, really cFE should report not only cFE and OSAL as it does now, but PSP also. Maybe these all could be switched to strings? I don't have a problem with that, but a tlm change is more impact. Although with modules the single cFE version also poses a challenge... |
I vote for changing the telemetry to output a string as opposed to individual numbers. Agree that cFE telemetry should report on PSP as well |
Good point, I forgot about the ES housekeeping telemetry packet - this has version numbers as integers. I have no complaints if this were changed to strings but ground system people might have an opinion. |
Random question, do we have other osal or psp info in telemetry? |
The only downside that I can see to reporting as strings is that what is now 4 bytes in telemetry (x2 = 8 bytes total) will need at least 32 bytes as a string, and we are proposing 3 of them to include PSP, so it needs 96 bytes - a pretty big increase in size of the TLM packet. |
Regarding the CCB conversation, I am fine with integers in telemetry packets, 99 for a development version, and strings in EVS messages. The development version for RTEMS 4.11 is 4.11.99 for example. (RTEMS 5 is taking a different approach, which can be seen here: https://devel.rtems.org/wiki/Developer/Release under "RTEMS Release 5 Series And Higher Numbering" |
Hi everyone, I created an issue at the bundle level to keep the discussion going on this without completely derailing the api solution from this PR. See nasa/cFS#200 |
@jphickey what do you think about replacing |
I really prefer to just return the "raw material" of the version info without the extra wordiness/punctuation/etc. Then ES (or whatever sends the full/descriptive info) can assemble into a complete, user friendly string. This way it will be more consistent. |
I was thinking something like a varargs where |
This just seems overly complex, for something that should be really simple... I concur with the comments in nasa/cFS#200 (comment) that we should first identify specifically what the intent/use-case of this info is, then report the items that satisfy that use-case, and don't make it too complicated. |
Adds 4 version API calls: const char *OS_GetVersionString(void); const char *OS_GetVersionCodeName(void); void OS_GetVersionNumber(uint8[4]); uint32 OS_GetBuildNumber(void); These return the values of current macros in osapi-version.h. The accessor function should be the preferred way to get the OSAL version info (vs. using macro directly) as it is evaluated at OSAL library compile time, rather than application compile time, and thus will remain correct in the event that OSAL is relinked without recompiling the application.
7576fed
to
6197a52
Compare
Updated per discussion/consensus in nasa/cFS#200. The runtime API now has 4 calls:
Note this change does not affect the existing macros, it just adds the APIs to get the same values. The intent is to not break any code currently depending on the macros, but just to add the API as the preferred way of getting the info at runtime. |
Combines: - nasa/cFE#1196 - nasa/osal#835 - nasa/elf2cfetbl#72 Includes: - nasa/cFE#1154 - nasa/cFE#935 - nasa/cFE#1179 - nasa/cFE#1140 - nasa/cFE#1178 - nasa/cFE#1197 - nasa/osal#834 - nasa/osal#826 - nasa/osal#827 - nasa/osal#829 - nasa/osal#824 - nasa/elf2cfetbl#71
IC: Caelum-rc4+dev6, nasa/cFS#443 - Reverts development version identifier to 99 for revision number
* The "Mission Revision" (last output) also indicates whether this is an | ||
* official release, a patched release, or a development version. | ||
* 0 indicates an official release | ||
* 1-254 local patch level (reserved for mission use) | ||
* 255 indicates a development build |
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.
This won't match, but in a quick scan I don't see code dependent on 0xFF.
Describe the contribution
Adds 3 simple API calls:
These directly return the values of string macros defined in
osapi-version.h
.The accessor function should be the preferred way to get the OSAL version string (vs. using macro directly) as it is evaluated at OSAL library compile time, rather than application compile time, and thus will remain correct in the event that OSAL is relinked without recompiling the application.
Fixes #821
Testing performed
Build and run all unit tests, sanity check CFE.
Expected behavior changes
This adds new APIs to get version strings - does not change anything existing within OSAL.
System(s) tested on
Ubuntu 20.04
Additional context
Looking at the existing macros I determined we really needed 3 functions for version info:
OS_VERSION
macro - this is the semantic version without any extra detail. This is returned byOS_GetVersion()
.OS_VERSION_STRING
macro - this has extra detail like the most recent official release. This is returned byOS_GetVersionDescription()
.OS_VERSION_STRING
macro and this is returned byOS_GetVersionDescription()
.I resisted the temptation to simply toss these into
osapi-common.c
and instead added a new/separate source file calledosapi-version.c
to implement these 3 calls. In turn this meant a new coverage test needed to be added too (since the pattern in OSAL is one coverage test per file unit).Putting this in a separate source file is better as it maintains the pattern/relationship between .c and .h files, and it also allows the version.c file to be auto-generated at some point if we decide to go that route in the future.
Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.