@@ -31,29 +31,23 @@ SOFTWARE.
3131
3232#if configUSE_TRACE_FACILITY != 1
3333void freertos_ps () {
34- Serial .println (" FreeRTOS_ps() needs configUSE_TRACE_FACILITY = 1 for uxTaskGetSystemState()" );
34+ p .println (" FreeRTOS_ps() needs configUSE_TRACE_FACILITY = 1 for uxTaskGetSystemState()" );
3535}
3636#else
3737
3838static char freertos_taskStatusChar (eTaskState eCurrentState) {
3939 switch (eCurrentState)
4040 {
41- case eRunning:
42- return ' X' ;
43- case eReady:
44- return ' R' ;
45- case eBlocked:
46- return ' B' ;
47- case eSuspended:
48- return ' S' ;
49- case eDeleted:
50- return ' D' ;
51- default : // Should not get here, but it is included to prevent static checking errors.
52- return ' -' ;
41+ case eRunning: return ' X' ;
42+ case eReady: return ' R' ;
43+ case eBlocked: return ' B' ;
44+ case eSuspended: return ' S' ;
45+ case eDeleted: return ' D' ;
46+ default : return ' -' ; // Should not get here, but it is included to prevent static checking errors.
5347 }
5448}
5549
56- void freertos_ps ()
50+ void freertos_ps (Print &p )
5751{
5852 static struct taskarr_s {
5953 TaskStatus_t pxTaskStatusArray[FREERTOS_PS_MAX_TASKS];
@@ -75,12 +69,12 @@ void freertos_ps()
7569 uint32_t totalRunTime = tanew.ulTotalRunTime - taold.ulTotalRunTime ;
7670 uint64_t tot = 0 ;
7771
78- Serial .printf (" \n === FreeRTOS Tasks - Measurement Period: %.2f seconds ===\n\n " , dt);
79- Serial .print (" TID Name CPU% Free St Pr Ni" );
72+ p .printf (" \n === FreeRTOS Tasks - Measurement Period: %.2f seconds ===\n\n " , dt);
73+ p .print (" TID Name CPU% Free St Pr Ni" );
8074 #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
81- Serial .print (" Core" );
75+ p .print (" Core" );
8276 #endif
83- Serial .println ();
77+ p .println ();
8478
8579 float perc_sum = 0 ;
8680 for ( uint32_t i = 0 ; i < tanew.uxArraySize ; i++ )
@@ -96,7 +90,7 @@ void freertos_ps()
9690 }
9791 float perc = (float )runtime / totalRunTime * 100 ;
9892 perc_sum += perc;
99- Serial .printf (" %3d %-12s%7.2f%% %5d %c %2d %2d" ,
93+ p .printf (" %3d %-12s%7.2f%% %5d %c %2d %2d" ,
10094 (int )t.xTaskNumber ,
10195 t.pcTaskName ,
10296 (float )perc,
@@ -106,13 +100,13 @@ void freertos_ps()
106100 (int )t.uxCurrentPriority
107101 );
108102 #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
109- Serial .printf (" %2lX" ,
103+ p .printf (" %2lX" ,
110104 t.uxCoreAffinityMask & ((1 <<configNUMBER_OF_CORES)-1 )
111105 );
112106 #endif
113- Serial .printf (" \n " );
107+ p .printf (" \n " );
114108 tot += runtime;
115109 }
116- Serial .printf (" Total %7.2f%%\n " , perc_sum);
110+ p .printf (" Total %7.2f%%\n " , perc_sum);
117111}
118112#endif // configUSE_TRACE_FACILITY != 1
0 commit comments