Skip to content

Commit 2670eef

Browse files
committed
Fix #256, add PSP version API
Add a PSP implementation of the version API discussed in nasa/cFS#200
1 parent a1a7e7a commit 2670eef

File tree

4 files changed

+230
-5
lines changed

4 files changed

+230
-5
lines changed

fsw/inc/cfe_psp.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,59 @@ int32 CFE_PSP_EepromWriteDisable(uint32 Bank);
410410
int32 CFE_PSP_EepromPowerUp(uint32 Bank);
411411
int32 CFE_PSP_EepromPowerDown(uint32 Bank);
412412

413+
/**
414+
* \brief Obtain the PSP version/baseline identifier string
415+
*
416+
* This retrieves the PSP version identifier string without extra info
417+
*
418+
* \returns Version string. This is a fixed string and cannot be NULL.
419+
*/
420+
const char *CFE_PSP_GetVersionString(void);
421+
422+
/**
423+
* \brief Obtain the version code name
424+
*
425+
* This retrieves the PSP code name. This is a compatibility indicator for the
426+
* overall NASA CFS ecosystem. All modular components which are intended to
427+
* interoperate should report the same code name.
428+
*
429+
* \returns Code name. This is a fixed string and cannot be NULL.
430+
*/
431+
const char *CFE_PSP_GetVersionCodeName(void);
432+
433+
/**
434+
* \brief Obtain the PSP numeric version numbers as uint8 values
435+
*
436+
* This retrieves the numeric PSP version identifier as an array of 4 uint8 values.
437+
*
438+
* The array of numeric values is in order of precedence:
439+
* [0] = Major Number
440+
* [1] = Minor Number
441+
* [2] = Revision Number
442+
* [3] = Mission Revision
443+
*
444+
* The "Mission Revision" (last output) also indicates whether this is an
445+
* official release, a patched release, or a development version.
446+
* 0 indicates an official release
447+
* 1-254 local patch level (reserved for mission use)
448+
* 255 indicates a development build
449+
*
450+
* \param[out] VersionNumbers A fixed-size array to be filled with the version numbers
451+
*/
452+
void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4]);
453+
454+
/**
455+
* \brief Obtain the PSP library numeric build number
456+
*
457+
* The build number is a monotonically increasing number that (coarsely)
458+
* reflects the number of commits/changes that have been merged since the
459+
* epoch release. During development cycles this number should increase
460+
* after each subsequent merge/modification.
461+
*
462+
* Like other version information, this is a fixed number assigned at compile time.
463+
*
464+
* \returns The OSAL library build number
465+
*/
466+
uint32 CFE_PSP_GetBuildNumber(void);
467+
413468
#endif /* _cfe_psp_ */

fsw/inc/cfe_psp_configdata.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@
3939
*/
4040
typedef const struct
4141
{
42-
uint8 MajorVersion;
43-
uint8 MinorVersion;
44-
uint8 Revision;
45-
uint8 MissionRev;
46-
char VersionString[32];
42+
uint8 MajorVersion;
43+
uint8 MinorVersion;
44+
uint8 Revision;
45+
uint8 MissionRev;
46+
const char *VersionString; /**< The simple semantic version identifier */
47+
const char *VersionCodeName; /**< Cross-module compatiblity indicator */
48+
uint32 BuildNumber;
4749
} CFE_PSP_VersionInfo_t;
4850

4951
/**

fsw/shared/src/cfe_psp_version.c

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
** GSC-18128-1, "Core Flight Executive Version 6.7"
3+
**
4+
** Copyright (c) 2006-2019 United States Government as represented by
5+
** the Administrator of the National Aeronautics and Space Administration.
6+
** All Rights Reserved.
7+
**
8+
** Licensed under the Apache License, Version 2.0 (the "License");
9+
** you may not use this file except in compliance with the License.
10+
** You may obtain a copy of the License at
11+
**
12+
** http://www.apache.org/licenses/LICENSE-2.0
13+
**
14+
** Unless required by applicable law or agreed to in writing, software
15+
** distributed under the License is distributed on an "AS IS" BASIS,
16+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
** See the License for the specific language governing permissions and
18+
** limitations under the License.
19+
*/
20+
21+
/**
22+
* \file cfe_psp_version.c
23+
*
24+
* Defines API that obtains the values of the various version identifiers
25+
*/
26+
27+
#include <cfe_psp.h>
28+
#include <cfe_psp_configdata.h>
29+
30+
/*----------------------------------------------------------------
31+
*
32+
* Function: CFE_PSP_GetVersionString
33+
*
34+
* Purpose: Implemented per public OSAL API
35+
* See description in API and header file for detail
36+
*
37+
*-----------------------------------------------------------------*/
38+
const char *CFE_PSP_GetVersionString(void)
39+
{
40+
return GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.VersionString;
41+
}
42+
43+
/*----------------------------------------------------------------
44+
*
45+
* Function: CFE_PSP_GetVersionCodeName
46+
*
47+
* Purpose: Implemented per public OSAL API
48+
* See description in API and header file for detail
49+
*
50+
*-----------------------------------------------------------------*/
51+
const char *CFE_PSP_GetVersionCodeName(void)
52+
{
53+
return GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.VersionCodeName;
54+
}
55+
56+
/*----------------------------------------------------------------
57+
*
58+
* Function: CFE_PSP_GetVersionNumber
59+
*
60+
* Purpose: Implemented per public OSAL API
61+
* See description in API and header file for detail
62+
*
63+
*-----------------------------------------------------------------*/
64+
void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4])
65+
{
66+
VersionNumbers[0] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MajorVersion;
67+
VersionNumbers[1] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MinorVersion;
68+
VersionNumbers[2] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.Revision;
69+
VersionNumbers[3] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MissionRev;
70+
}
71+
72+
/*----------------------------------------------------------------
73+
*
74+
* Function: CFE_PSP_GetBuildNumber
75+
*
76+
* Purpose: Implemented per public OSAL API
77+
* See description in API and header file for detail
78+
*
79+
*-----------------------------------------------------------------*/
80+
uint32 CFE_PSP_GetBuildNumber(void)
81+
{
82+
return GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.BuildNumber;
83+
}

ut-stubs/ut_psp_stubs.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,3 +733,88 @@ int32 CFE_PSP_Exception_CopyContext(uint32 ContextLogId, void *ContextBuf, uint3
733733

734734
return status;
735735
}
736+
737+
/*----------------------------------------------------------------
738+
*
739+
* Function: CFE_PSP_GetVersionString
740+
*
741+
* Purpose: Implemented per public OSAL API
742+
* See description in API and header file for detail
743+
*
744+
*-----------------------------------------------------------------*/
745+
const char *CFE_PSP_GetVersionString(void)
746+
{
747+
static const char DEFAULT[] = "UT";
748+
void * Buffer;
749+
const char * RetVal;
750+
751+
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVersionString), &Buffer, NULL, NULL);
752+
if (Buffer == NULL)
753+
{
754+
RetVal = DEFAULT;
755+
}
756+
else
757+
{
758+
RetVal = Buffer;
759+
}
760+
761+
return RetVal;
762+
}
763+
764+
/*----------------------------------------------------------------
765+
*
766+
* Function: CFE_PSP_GetVersionCodeName
767+
*
768+
* Purpose: Implemented per public OSAL API
769+
* See description in API and header file for detail
770+
*
771+
*-----------------------------------------------------------------*/
772+
const char *CFE_PSP_GetVersionCodeName(void)
773+
{
774+
static const char DEFAULT[] = "UT";
775+
void * Buffer;
776+
const char * RetVal;
777+
778+
UT_GetDataBuffer(UT_KEY(CFE_PSP_GetVersionCodeName), &Buffer, NULL, NULL);
779+
if (Buffer == NULL)
780+
{
781+
RetVal = DEFAULT;
782+
}
783+
else
784+
{
785+
RetVal = Buffer;
786+
}
787+
788+
return RetVal;
789+
}
790+
791+
/*----------------------------------------------------------------
792+
*
793+
* Function: CFE_PSP_GetVersionNumber
794+
*
795+
* Purpose: Implemented per public OSAL API
796+
* See description in API and header file for detail
797+
*
798+
*-----------------------------------------------------------------*/
799+
void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4])
800+
{
801+
UT_Stub_RegisterContext(UT_KEY(CFE_PSP_GetVersionNumber), VersionNumbers);
802+
UT_DEFAULT_IMPL(VersionNumbers);
803+
}
804+
805+
/*----------------------------------------------------------------
806+
*
807+
* Function: CFE_PSP_GetBuildNumber
808+
*
809+
* Purpose: Implemented per public OSAL API
810+
* See description in API and header file for detail
811+
*
812+
*-----------------------------------------------------------------*/
813+
uint32 CFE_PSP_GetBuildNumber(void)
814+
{
815+
int32 status;
816+
817+
status = UT_DEFAULT_IMPL(CFE_PSP_GetBuildNumber);
818+
819+
return status;
820+
}

0 commit comments

Comments
 (0)