Skip to content
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

cFE Integration candidate: 2021-01-12 #1088

Merged
merged 11 commits into from
Jan 13, 2021
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ The detailed cFE user's guide can be viewed at <https://github.com/nasa/cFS/blob

## Version History

### Development Build: 6.8.0-rc1+dev248

- Replace `OS_FileSysStatVolume()` with`OS_fsBlocksFree()` which will be deprecated. This call reports the number of total blocks, not just the free blocks, making the check more accurate and removing the need for a workaround for desktop machines.
- Instead of accessing `OS_time_t` values directly, use the OSAL-provided conversion and access methods. This provides independence and abstraction from the specific `OS_time_t` definition and allows OSAL to transition to a 64 bit value.
- Removes the spurious `CFE_SB_TimeOut_t` typedef from `cfe_sb.h`. May affect any apps that inappropriately rely on the private typedef.
- Removes unused `network_includes.h`. Not used by the framework anywhere, apps should use OSAL Socket APIs instead.
- Fixes deprecation directive typos
- See <https://github.com/nasa/cFE/pull/1088>

### Development Build: 6.8.0-rc1+dev236

- Resolved doxygen warnings for osalguide and updated header file references
Expand Down
17 changes: 2 additions & 15 deletions fsw/cfe-core/src/es/cfe_es_backgroundtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,12 @@ void CFE_ES_BackgroundTask(void)
{
/*
* compute the elapsed time (difference) between last
* execution and now, in microseconds.
*
* Note this calculation is done as a uint32 which will overflow
* after about 35 minutes, but the max delays ensure that this
* executes at least every few seconds, so that should never happen.
* execution and now, in milliseconds.
*/
CFE_PSP_GetTime(&CurrTime);
ElapsedTime = 1000000 * (CurrTime.seconds - LastTime.seconds);
ElapsedTime += CurrTime.microsecs;
ElapsedTime -= LastTime.microsecs;
ElapsedTime = OS_TimeGetTotalMilliseconds(OS_TimeSubtract(CurrTime, LastTime));
LastTime = CurrTime;

/*
* convert to milliseconds.
* we do not really need high precision
* for background task timings
*/
ElapsedTime /= 1000;

NextDelay = CFE_ES_BACKGROUND_MAX_IDLE_DELAY; /* default; will be adjusted based on active jobs */
JobPtr = CFE_ES_BACKGROUND_JOB_TABLE;
JobTotal = CFE_ES_BACKGROUND_NUM_JOBS;
Expand Down
31 changes: 9 additions & 22 deletions fsw/cfe-core/src/es/cfe_es_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,11 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo
*/
void CFE_ES_InitializeFileSystems(uint32 StartType)
{
int32 RetStatus;
cpuaddr RamDiskMemoryAddress;
uint32 RamDiskMemorySize;
int32 BlocksFree;
int32 PercentFree;
int32 RetStatus;
cpuaddr RamDiskMemoryAddress;
uint32 RamDiskMemorySize;
int32 PercentFree;
OS_statvfs_t StatBuf;

/*
** Get the memory area for the RAM disk
Expand Down Expand Up @@ -601,25 +601,13 @@ void CFE_ES_InitializeFileSystems(uint32 StartType)
/*
** See how many blocks are free in the RAM disk
*/
BlocksFree = OS_fsBlocksFree(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING);
if ( BlocksFree >= 0 )
RetStatus = OS_FileSysStatVolume(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING, &StatBuf);
if ( RetStatus == OS_SUCCESS && StatBuf.total_blocks > 0 )
{
/*
** Need a sanity check for the desktop systems.
** Because the desktop ports map the volatile disk to the host
** hard disk, it will report more free blocks than the defined number
** of sectors ( blocks ). Therefore it must be truncated.
*/
if ( BlocksFree > CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS )
{
BlocksFree = CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS - 1;
}

/*
** Determine if the disk is too full
*/
BlocksFree = BlocksFree * 100;
PercentFree = BlocksFree / CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS;
PercentFree = (StatBuf.blocks_free * 100) / StatBuf.total_blocks;
CFE_ES_WriteToSysLog("Volatile Disk has %d Percent free space.\n",(int)PercentFree);

if ( PercentFree < CFE_PLATFORM_ES_RAM_DISK_PERCENT_RESERVED )
Expand Down Expand Up @@ -721,7 +709,7 @@ void CFE_ES_InitializeFileSystems(uint32 StartType)
else /* could not determine free blocks */
{
/* Log error message -- note that BlocksFree returns the error code in this case */
CFE_ES_WriteToSysLog("ES Startup: Error Determining Blocks Free on Volume. EC = 0x%08X\n",(unsigned int)BlocksFree);
CFE_ES_WriteToSysLog("ES Startup: Error Determining Blocks Free on Volume. EC = 0x%08X\n",(unsigned int)RetStatus);

/*
** Delay to allow the message to be read
Expand Down Expand Up @@ -983,4 +971,3 @@ int32 CFE_ES_MainTaskSyncDelay(uint32 AppStateId, uint32 TimeOutMilliseconds)

return Status;
}

10 changes: 1 addition & 9 deletions fsw/cfe-core/src/inc/cfe_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,6 @@ typedef CFE_MSG_TelemetryHeader_t CFE_SB_TlmHdr_t;
#define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_MSG_TelemetryHeader_t))/**< \brief Size of telemetry header */
#endif /* CFE_OMIT_DEPRECATED_6_8 */

/** \brief CFE_SB_TimeOut_t to primitive type definition
**
** Internally used by SB in the #CFE_SB_ReceiveBuffer API. Translated from the
** input parmater named TimeOut which specifies the maximum time in
** milliseconds that the caller wants to wait for a message.
*/
typedef uint32 CFE_SB_TimeOut_t;

/** \brief CFE_SB_PipeId_t to primitive type definition
**
** Software Bus pipe identifier used in many SB APIs
Expand Down Expand Up @@ -646,7 +638,7 @@ CFE_Status_t CFE_SB_PassMsg(CFE_MSG_Message_t *MsgPtr);
**/
CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut);

#if CFE_OMIT_DEPRECATED_6_8
#ifndef CFE_OMIT_DEPRECATED_6_8
/**
* \brief DEPRECATED: receive buffer
* \deprecated use CFE_SB_ReceiveBuffer
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/inc/cfe_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


/* Development Build Macro Definitions */
#define CFE_BUILD_NUMBER 236 /*!< Development Build: Number of commits since baseline */
#define CFE_BUILD_NUMBER 248 /*!< Development Build: Number of commits since baseline */
#define CFE_BUILD_BASELINE "v6.8.0-rc1" /*!< Development Build: git tag that is the base for the current development */

/* Version Macro Definitions */
Expand Down
86 changes: 0 additions & 86 deletions fsw/cfe-core/src/inc/network_includes.h

This file was deleted.

4 changes: 2 additions & 2 deletions fsw/cfe-core/src/sb/cfe_sb_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr,

}

#if CFE_OMIT_DEPRECATED_6_8
#ifndef CFE_OMIT_DEPRECATED_6_8
int32 CFE_SB_RcvMsg(CFE_SB_Buffer_t **BufPtr,
CFE_SB_PipeId_t PipeId,
int32 TimeOut)
Expand Down Expand Up @@ -1891,7 +1891,7 @@ int32 CFE_SB_ZeroCopyPass(CFE_SB_Buffer_t *BufPtr,

int32 CFE_SB_ReadQueue (CFE_SB_PipeD_t *PipeDscPtr,
CFE_ES_ResourceID_t TskId,
CFE_SB_TimeOut_t Time_Out,
uint32 Time_Out,
CFE_SB_BufferD_t **Message)
{
int32 Status,TimeOut;
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/sb/cfe_sb_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber);
void CFE_SB_UnlockSharedData(const char *FuncName, int32 LineNumber);
void CFE_SB_ReleaseBuffer (CFE_SB_BufferD_t *bd, CFE_SB_DestinationD_t *dest);
int32 CFE_SB_ReadQueue(CFE_SB_PipeD_t *PipeDscPtr,CFE_ES_ResourceID_t TskId,
CFE_SB_TimeOut_t Time_Out,CFE_SB_BufferD_t **Message );
uint32 Time_Out,CFE_SB_BufferD_t **Message );
int32 CFE_SB_WriteQueue(CFE_SB_PipeD_t *pd,uint32 TskId,
const CFE_SB_BufferD_t *bd,CFE_SB_MsgId_t MsgId );
uint8 CFE_SB_GetPipeIdx(CFE_SB_PipeId_t PipeId);
Expand Down
100 changes: 16 additions & 84 deletions fsw/cfe-core/src/time/cfe_time_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,57 +489,16 @@ CFE_TIME_Compare_t CFE_TIME_Compare(CFE_TIME_SysTime_t TimeA, CFE_TIME_SysTime_
*/
uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds)
{
uint32 MicroSeconds;

/* 0xffffdf00 subseconds = 999999 microseconds, so anything greater
* than that we set to 999999 microseconds, so it doesn't get to
* a million microseconds */

if (SubSeconds > 0xffffdf00)
{
MicroSeconds = 999999;
}
else
{
/*
** Convert a 1/2^32 clock tick count to a microseconds count
**
** Conversion factor is ( ( 2 ** -32 ) / ( 10 ** -6 ) ).
**
** Logic is as follows:
** x * ( ( 2 ** -32 ) / ( 10 ** -6 ) )
** = x * ( ( 10 ** 6 ) / ( 2 ** 32 ) )
** = x * ( ( 5 ** 6 ) ( 2 ** 6 ) / ( 2 ** 26 ) ( 2 ** 6) )
** = x * ( ( 5 ** 6 ) / ( 2 ** 26 ) )
** = x * ( ( 5 ** 3 ) ( 5 ** 3 ) / ( 2 ** 7 ) ( 2 ** 7 ) (2 ** 12) )
**
** C code equivalent:
** = ( ( ( ( ( x >> 7) * 125) >> 7) * 125) >> 12 )
*/

MicroSeconds = (((((SubSeconds >> 7) * 125) >> 7) * 125) >> 12);

OS_time_t tm;

/* if the Subseconds % 0x4000000 != 0 then we will need to
* add 1 to the result. the & is a faster way of doing the % */
if ((SubSeconds & 0x3ffffff) != 0)
{
MicroSeconds++;
}

/* In the Micro2SubSecs conversion, we added an extra anomaly
* to get the subseconds to bump up against the end point,
* 0xFFFFF000. This must be accounted for here. Since we bumped
* at the half way mark, we must "unbump" at the same mark
*/
if (MicroSeconds > 500000)
{
MicroSeconds --;
}

} /* end else */

return(MicroSeconds);
/*
** Convert using the OSAL method. Note that there
** is no range check here because any uint32 value is valid,
** and OSAL will handle and properly convert any input.
*/
tm = OS_TimeAssembleFromSubseconds(0, SubSeconds);

return OS_TimeGetMicrosecondsPart(tm);

} /* End of CFE_TIME_Sub2MicroSecs() */

Expand All @@ -549,51 +508,24 @@ uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds)
*/
uint32 CFE_TIME_Micro2SubSecs(uint32 MicroSeconds)
{
OS_time_t tm;
uint32 SubSeconds;

/*
** Conversion amount must be less than one second
** (preserves existing behavior where output saturates at max value)
*/
if (MicroSeconds > 999999)
{
SubSeconds = 0xFFFFFFFF;
}
else
{
/*
** Convert micro-seconds count to sub-seconds (1/2^32) count
**
** Conversion factor is ( ( 10 ** -6 ) / ( 2 ** -20 ).
**
** Logic is as follows:
** x * ( ( 10 ** -6 ) / ( 2 ** -32 ) )
** = x * ( ( 2 ** 32 ) / ( 10 ** 6 ) )
** = x * ( ( ( 2 ** 26 ) ( 2 ** 6) ) / ( ( 5 ** 6 ) ( 2 ** 6 ) ) )
** = x * ( ( 2 ** 26 ) / ( 5 ** 6 ) )
** = x * ( ( ( 2 ** 11) ( 2 ** 3) (2 ** 12) ) / ( 5( 5 ** 5 ) ) )
** = x * ( ( ( ( ( 2 ** 11 ) / 5 ) * ( 2 ** 3 ) ) / ( 5 ** 5 ) ) * (2 ** 12) )
**
** C code equivalent:
** = ( ( ( ( ( x << 11 ) / 5 ) << 3 ) / 3125 ) << 12 )
**
** Conversion factor was reduced and factored accordingly
** to minimize precision loss and register overflow.
*/
SubSeconds = ( ( ( ( MicroSeconds << 11 ) / 5 ) << 3 ) / 3125 ) << 12;

/* To get the SubSeconds to "bump up" against 0xFFFFF000 when
* MicroSeconds = 9999999, we add in another anomaly to the
* conversion at the half-way point (500000 us). This will bump
* all of the subseconds up by 0x1000, so 999999 us == 0xFFFFF00,
* 999998 == 0xFFFFE000, etc. This extra anomaly is accounted for
* in the Sub2MicroSecs conversion as well.
*/

if (SubSeconds > 0x80001000)
{
SubSeconds += 0x1000;
}

/*
** Convert micro-seconds count to sub-seconds (1/2^32) count using OSAL
*/
tm = OS_TimeAssembleFromNanoseconds(0, MicroSeconds * 1000);
SubSeconds = OS_TimeGetSubsecondsPart(tm);
}

return(SubSeconds);
Expand Down
4 changes: 2 additions & 2 deletions fsw/cfe-core/src/time/cfe_time_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ CFE_TIME_SysTime_t CFE_TIME_LatchClock(void)
/*
** Convert time to cFE format (seconds : 1/2^32 subseconds)...
*/
LatchTime.Seconds = LocalTime.seconds;
LatchTime.Subseconds = CFE_TIME_Micro2SubSecs(LocalTime.microsecs);
LatchTime.Seconds = OS_TimeGetTotalSeconds(LocalTime);
LatchTime.Subseconds = OS_TimeGetSubsecondsPart(LocalTime);

return(LatchTime);

Expand Down
Loading