Skip to content

Commit c8abccd

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 c8abccd

File tree

4 files changed

+229
-1
lines changed

4 files changed

+229
-1
lines changed

fsw/inc/cfe_psp.h

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

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

fsw/inc/cfe_psp_configdata.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ typedef const struct
4343
uint8 MinorVersion;
4444
uint8 Revision;
4545
uint8 MissionRev;
46-
char VersionString[32];
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: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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+
*
33+
* Function: CFE_PSP_GetVersionString
34+
*
35+
* Purpose: Implemented per public OSAL API
36+
* See description in API and header file for detail
37+
*
38+
*-----------------------------------------------------------------*/
39+
const char *CFE_PSP_GetVersionString(void)
40+
{
41+
return GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.VersionString;
42+
}
43+
44+
/*----------------------------------------------------------------
45+
*
46+
* Function: CFE_PSP_GetVersionCodeName
47+
*
48+
* Purpose: Implemented per public OSAL API
49+
* See description in API and header file for detail
50+
*
51+
*-----------------------------------------------------------------*/
52+
const char *CFE_PSP_GetVersionCodeName(void)
53+
{
54+
return GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.VersionCodeName;
55+
}
56+
57+
/*----------------------------------------------------------------
58+
*
59+
* Function: CFE_PSP_GetVersionNumber
60+
*
61+
* Purpose: Implemented per public OSAL API
62+
* See description in API and header file for detail
63+
*
64+
*-----------------------------------------------------------------*/
65+
void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4])
66+
{
67+
VersionNumbers[0] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MajorVersion;
68+
VersionNumbers[1] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MinorVersion;
69+
VersionNumbers[2] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.Revision;
70+
VersionNumbers[3] = GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.MissionRev;
71+
}
72+
73+
/*----------------------------------------------------------------
74+
*
75+
* Function: CFE_PSP_GetBuildNumber
76+
*
77+
* Purpose: Implemented per public OSAL API
78+
* See description in API and header file for detail
79+
*
80+
*-----------------------------------------------------------------*/
81+
uint32 CFE_PSP_GetBuildNumber(void)
82+
{
83+
return GLOBAL_PSP_CONFIGDATA.PSP_VersionInfo.BuildNumber;
84+
}

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)