Skip to content

Commit c7363c8

Browse files
authored
Merge pull request #1088 from nasa/integration-candidate
cFE Integration candidate: 2021-01-12
2 parents 1ede295 + 2d1493e commit c7363c8

File tree

13 files changed

+66
-282
lines changed

13 files changed

+66
-282
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ The detailed cFE user's guide can be viewed at <https://github.com/nasa/cFS/blob
1010

1111
## Version History
1212

13+
### Development Build: 6.8.0-rc1+dev248
14+
15+
- 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.
16+
- 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.
17+
- Removes the spurious `CFE_SB_TimeOut_t` typedef from `cfe_sb.h`. May affect any apps that inappropriately rely on the private typedef.
18+
- Removes unused `network_includes.h`. Not used by the framework anywhere, apps should use OSAL Socket APIs instead.
19+
- Fixes deprecation directive typos
20+
- See <https://github.com/nasa/cFE/pull/1088>
21+
1322
### Development Build: 6.8.0-rc1+dev236
1423

1524
- Resolved doxygen warnings for osalguide and updated header file references

fsw/cfe-core/src/es/cfe_es_backgroundtask.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,12 @@ void CFE_ES_BackgroundTask(void)
136136
{
137137
/*
138138
* compute the elapsed time (difference) between last
139-
* execution and now, in microseconds.
140-
*
141-
* Note this calculation is done as a uint32 which will overflow
142-
* after about 35 minutes, but the max delays ensure that this
143-
* executes at least every few seconds, so that should never happen.
139+
* execution and now, in milliseconds.
144140
*/
145141
CFE_PSP_GetTime(&CurrTime);
146-
ElapsedTime = 1000000 * (CurrTime.seconds - LastTime.seconds);
147-
ElapsedTime += CurrTime.microsecs;
148-
ElapsedTime -= LastTime.microsecs;
142+
ElapsedTime = OS_TimeGetTotalMilliseconds(OS_TimeSubtract(CurrTime, LastTime));
149143
LastTime = CurrTime;
150144

151-
/*
152-
* convert to milliseconds.
153-
* we do not really need high precision
154-
* for background task timings
155-
*/
156-
ElapsedTime /= 1000;
157-
158145
NextDelay = CFE_ES_BACKGROUND_MAX_IDLE_DELAY; /* default; will be adjusted based on active jobs */
159146
JobPtr = CFE_ES_BACKGROUND_JOB_TABLE;
160147
JobTotal = CFE_ES_BACKGROUND_NUM_JOBS;

fsw/cfe-core/src/es/cfe_es_start.c

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,11 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo
494494
*/
495495
void CFE_ES_InitializeFileSystems(uint32 StartType)
496496
{
497-
int32 RetStatus;
498-
cpuaddr RamDiskMemoryAddress;
499-
uint32 RamDiskMemorySize;
500-
int32 BlocksFree;
501-
int32 PercentFree;
497+
int32 RetStatus;
498+
cpuaddr RamDiskMemoryAddress;
499+
uint32 RamDiskMemorySize;
500+
int32 PercentFree;
501+
OS_statvfs_t StatBuf;
502502

503503
/*
504504
** Get the memory area for the RAM disk
@@ -601,25 +601,13 @@ void CFE_ES_InitializeFileSystems(uint32 StartType)
601601
/*
602602
** See how many blocks are free in the RAM disk
603603
*/
604-
BlocksFree = OS_fsBlocksFree(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING);
605-
if ( BlocksFree >= 0 )
604+
RetStatus = OS_FileSysStatVolume(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING, &StatBuf);
605+
if ( RetStatus == OS_SUCCESS && StatBuf.total_blocks > 0 )
606606
{
607-
/*
608-
** Need a sanity check for the desktop systems.
609-
** Because the desktop ports map the volatile disk to the host
610-
** hard disk, it will report more free blocks than the defined number
611-
** of sectors ( blocks ). Therefore it must be truncated.
612-
*/
613-
if ( BlocksFree > CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS )
614-
{
615-
BlocksFree = CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS - 1;
616-
}
617-
618607
/*
619608
** Determine if the disk is too full
620609
*/
621-
BlocksFree = BlocksFree * 100;
622-
PercentFree = BlocksFree / CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS;
610+
PercentFree = (StatBuf.blocks_free * 100) / StatBuf.total_blocks;
623611
CFE_ES_WriteToSysLog("Volatile Disk has %d Percent free space.\n",(int)PercentFree);
624612

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

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

984972
return Status;
985973
}
986-

fsw/cfe-core/src/inc/cfe_sb.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,6 @@ typedef CFE_MSG_TelemetryHeader_t CFE_SB_TlmHdr_t;
152152
#define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_MSG_TelemetryHeader_t))/**< \brief Size of telemetry header */
153153
#endif /* CFE_OMIT_DEPRECATED_6_8 */
154154

155-
/** \brief CFE_SB_TimeOut_t to primitive type definition
156-
**
157-
** Internally used by SB in the #CFE_SB_ReceiveBuffer API. Translated from the
158-
** input parmater named TimeOut which specifies the maximum time in
159-
** milliseconds that the caller wants to wait for a message.
160-
*/
161-
typedef uint32 CFE_SB_TimeOut_t;
162-
163155
/** \brief CFE_SB_PipeId_t to primitive type definition
164156
**
165157
** Software Bus pipe identifier used in many SB APIs
@@ -646,7 +638,7 @@ CFE_Status_t CFE_SB_PassMsg(CFE_MSG_Message_t *MsgPtr);
646638
**/
647639
CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut);
648640

649-
#if CFE_OMIT_DEPRECATED_6_8
641+
#ifndef CFE_OMIT_DEPRECATED_6_8
650642
/**
651643
* \brief DEPRECATED: receive buffer
652644
* \deprecated use CFE_SB_ReceiveBuffer

fsw/cfe-core/src/inc/cfe_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

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

4141
/* Version Macro Definitions */

fsw/cfe-core/src/inc/network_includes.h

Lines changed: 0 additions & 86 deletions
This file was deleted.

fsw/cfe-core/src/sb/cfe_sb_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ int32 CFE_SB_TransmitBufferFull(CFE_SB_BufferD_t *BufDscPtr,
14551455

14561456
}
14571457

1458-
#if CFE_OMIT_DEPRECATED_6_8
1458+
#ifndef CFE_OMIT_DEPRECATED_6_8
14591459
int32 CFE_SB_RcvMsg(CFE_SB_Buffer_t **BufPtr,
14601460
CFE_SB_PipeId_t PipeId,
14611461
int32 TimeOut)
@@ -1891,7 +1891,7 @@ int32 CFE_SB_ZeroCopyPass(CFE_SB_Buffer_t *BufPtr,
18911891

18921892
int32 CFE_SB_ReadQueue (CFE_SB_PipeD_t *PipeDscPtr,
18931893
CFE_ES_ResourceID_t TskId,
1894-
CFE_SB_TimeOut_t Time_Out,
1894+
uint32 Time_Out,
18951895
CFE_SB_BufferD_t **Message)
18961896
{
18971897
int32 Status,TimeOut;

fsw/cfe-core/src/sb/cfe_sb_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber);
239239
void CFE_SB_UnlockSharedData(const char *FuncName, int32 LineNumber);
240240
void CFE_SB_ReleaseBuffer (CFE_SB_BufferD_t *bd, CFE_SB_DestinationD_t *dest);
241241
int32 CFE_SB_ReadQueue(CFE_SB_PipeD_t *PipeDscPtr,CFE_ES_ResourceID_t TskId,
242-
CFE_SB_TimeOut_t Time_Out,CFE_SB_BufferD_t **Message );
242+
uint32 Time_Out,CFE_SB_BufferD_t **Message );
243243
int32 CFE_SB_WriteQueue(CFE_SB_PipeD_t *pd,uint32 TskId,
244244
const CFE_SB_BufferD_t *bd,CFE_SB_MsgId_t MsgId );
245245
uint8 CFE_SB_GetPipeIdx(CFE_SB_PipeId_t PipeId);

fsw/cfe-core/src/time/cfe_time_api.c

Lines changed: 16 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -489,57 +489,16 @@ CFE_TIME_Compare_t CFE_TIME_Compare(CFE_TIME_SysTime_t TimeA, CFE_TIME_SysTime_
489489
*/
490490
uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds)
491491
{
492-
uint32 MicroSeconds;
493-
494-
/* 0xffffdf00 subseconds = 999999 microseconds, so anything greater
495-
* than that we set to 999999 microseconds, so it doesn't get to
496-
* a million microseconds */
497-
498-
if (SubSeconds > 0xffffdf00)
499-
{
500-
MicroSeconds = 999999;
501-
}
502-
else
503-
{
504-
/*
505-
** Convert a 1/2^32 clock tick count to a microseconds count
506-
**
507-
** Conversion factor is ( ( 2 ** -32 ) / ( 10 ** -6 ) ).
508-
**
509-
** Logic is as follows:
510-
** x * ( ( 2 ** -32 ) / ( 10 ** -6 ) )
511-
** = x * ( ( 10 ** 6 ) / ( 2 ** 32 ) )
512-
** = x * ( ( 5 ** 6 ) ( 2 ** 6 ) / ( 2 ** 26 ) ( 2 ** 6) )
513-
** = x * ( ( 5 ** 6 ) / ( 2 ** 26 ) )
514-
** = x * ( ( 5 ** 3 ) ( 5 ** 3 ) / ( 2 ** 7 ) ( 2 ** 7 ) (2 ** 12) )
515-
**
516-
** C code equivalent:
517-
** = ( ( ( ( ( x >> 7) * 125) >> 7) * 125) >> 12 )
518-
*/
519-
520-
MicroSeconds = (((((SubSeconds >> 7) * 125) >> 7) * 125) >> 12);
521-
492+
OS_time_t tm;
522493

523-
/* if the Subseconds % 0x4000000 != 0 then we will need to
524-
* add 1 to the result. the & is a faster way of doing the % */
525-
if ((SubSeconds & 0x3ffffff) != 0)
526-
{
527-
MicroSeconds++;
528-
}
529-
530-
/* In the Micro2SubSecs conversion, we added an extra anomaly
531-
* to get the subseconds to bump up against the end point,
532-
* 0xFFFFF000. This must be accounted for here. Since we bumped
533-
* at the half way mark, we must "unbump" at the same mark
534-
*/
535-
if (MicroSeconds > 500000)
536-
{
537-
MicroSeconds --;
538-
}
539-
540-
} /* end else */
541-
542-
return(MicroSeconds);
494+
/*
495+
** Convert using the OSAL method. Note that there
496+
** is no range check here because any uint32 value is valid,
497+
** and OSAL will handle and properly convert any input.
498+
*/
499+
tm = OS_TimeAssembleFromSubseconds(0, SubSeconds);
500+
501+
return OS_TimeGetMicrosecondsPart(tm);
543502

544503
} /* End of CFE_TIME_Sub2MicroSecs() */
545504

@@ -549,51 +508,24 @@ uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds)
549508
*/
550509
uint32 CFE_TIME_Micro2SubSecs(uint32 MicroSeconds)
551510
{
511+
OS_time_t tm;
552512
uint32 SubSeconds;
553513

554514
/*
555515
** Conversion amount must be less than one second
516+
** (preserves existing behavior where output saturates at max value)
556517
*/
557518
if (MicroSeconds > 999999)
558519
{
559520
SubSeconds = 0xFFFFFFFF;
560521
}
561522
else
562523
{
563-
/*
564-
** Convert micro-seconds count to sub-seconds (1/2^32) count
565-
**
566-
** Conversion factor is ( ( 10 ** -6 ) / ( 2 ** -20 ).
567-
**
568-
** Logic is as follows:
569-
** x * ( ( 10 ** -6 ) / ( 2 ** -32 ) )
570-
** = x * ( ( 2 ** 32 ) / ( 10 ** 6 ) )
571-
** = x * ( ( ( 2 ** 26 ) ( 2 ** 6) ) / ( ( 5 ** 6 ) ( 2 ** 6 ) ) )
572-
** = x * ( ( 2 ** 26 ) / ( 5 ** 6 ) )
573-
** = x * ( ( ( 2 ** 11) ( 2 ** 3) (2 ** 12) ) / ( 5( 5 ** 5 ) ) )
574-
** = x * ( ( ( ( ( 2 ** 11 ) / 5 ) * ( 2 ** 3 ) ) / ( 5 ** 5 ) ) * (2 ** 12) )
575-
**
576-
** C code equivalent:
577-
** = ( ( ( ( ( x << 11 ) / 5 ) << 3 ) / 3125 ) << 12 )
578-
**
579-
** Conversion factor was reduced and factored accordingly
580-
** to minimize precision loss and register overflow.
581-
*/
582-
SubSeconds = ( ( ( ( MicroSeconds << 11 ) / 5 ) << 3 ) / 3125 ) << 12;
583-
584-
/* To get the SubSeconds to "bump up" against 0xFFFFF000 when
585-
* MicroSeconds = 9999999, we add in another anomaly to the
586-
* conversion at the half-way point (500000 us). This will bump
587-
* all of the subseconds up by 0x1000, so 999999 us == 0xFFFFF00,
588-
* 999998 == 0xFFFFE000, etc. This extra anomaly is accounted for
589-
* in the Sub2MicroSecs conversion as well.
590-
*/
591-
592-
if (SubSeconds > 0x80001000)
593-
{
594-
SubSeconds += 0x1000;
595-
}
596-
524+
/*
525+
** Convert micro-seconds count to sub-seconds (1/2^32) count using OSAL
526+
*/
527+
tm = OS_TimeAssembleFromNanoseconds(0, MicroSeconds * 1000);
528+
SubSeconds = OS_TimeGetSubsecondsPart(tm);
597529
}
598530

599531
return(SubSeconds);

fsw/cfe-core/src/time/cfe_time_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ CFE_TIME_SysTime_t CFE_TIME_LatchClock(void)
9191
/*
9292
** Convert time to cFE format (seconds : 1/2^32 subseconds)...
9393
*/
94-
LatchTime.Seconds = LocalTime.seconds;
95-
LatchTime.Subseconds = CFE_TIME_Micro2SubSecs(LocalTime.microsecs);
94+
LatchTime.Seconds = OS_TimeGetTotalSeconds(LocalTime);
95+
LatchTime.Subseconds = OS_TimeGetSubsecondsPart(LocalTime);
9696

9797
return(LatchTime);
9898

0 commit comments

Comments
 (0)