Skip to content

Commit

Permalink
Implement dumping the Tracelyzer trace when pressing enter (#252)
Browse files Browse the repository at this point in the history
* Test: Press Enter to Trace dump on posix demo
* Test: allow tracedump multiple times
* Fix: main full demo
  • Loading branch information
cobusve committed Sep 9, 2020
1 parent 9b82585 commit 0d571fb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
39 changes: 31 additions & 8 deletions FreeRTOS/Demo/Posix_GCC/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://www.FreeRTOS.org
* http://aws.amazon.com/freertos
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
* 1 tab == 4 spaces!
*/
Expand Down Expand Up @@ -79,7 +79,7 @@
extern void main_blinky( void );
extern void main_full( void );
extern void main_tcp_echo_client_tasks( void );

static void traceOnEnter( void );
/*
* Only the comprehensive demo uses application hook (callback) functions. See
* http://www.freertos.org/a00016.html for more information.
Expand Down Expand Up @@ -135,31 +135,31 @@ int main( void )
/* Start the trace recording - the recording is written to a file if
configASSERT() is called. */
printf( "\r\nTrace started.\r\nThe trace will be dumped to disk if a call to configASSERT() fails.\r\n" );
printf( "\r\nThe trace will be dumped to disk if Enter is hit.\r\n" );
uiTraceStart();
}
#endif

console_init();
#if ( mainSELECTED_APPLICATION == ECHO_CLIENT_DEMO )
{
console_print("Starting echo client demo\n");
console_print("Starting echo client demo\n");
main_tcp_echo_client_tasks();
}
#elif ( mainSELECTED_APPLICATION == BLINKY_DEMO )
{
console_print("Starting echo blinky demo\n");
console_print("Starting echo blinky demo\n");
main_blinky();
}
#elif ( mainSELECTED_APPLICATION == FULL_DEMO)
{
console_print("Starting full demo\n");
console_print("Starting full demo\n");
main_full();
}
#else
{
#error "The selected demo is not valid"
}

#endif /* if ( mainSELECTED_APPLICATION ) */

return 0;
Expand Down Expand Up @@ -197,11 +197,14 @@ void vApplicationIdleHook( void )
allocated by the kernel to any task that has since deleted itself. */


usleep(15000);
traceOnEnter();

#if ( mainSELECTED_APPLICATION == FULL_DEMO )
{
/* Call the idle task processing used by the full demo. The simple
blinky demo does not use the idle task hook. */
vFullDemoIdleFunction();
vFullDemoIdleFunction();
}
#endif
}
Expand Down Expand Up @@ -237,6 +240,26 @@ void vApplicationTickHook( void )
#endif /* mainSELECTED_APPLICATION */
}

void traceOnEnter()
{
int ret;
struct timeval tv = { 0L, 0L };
fd_set fds;
FD_ZERO(&fds);
FD_SET(0, &fds);
ret = select(1, &fds, NULL, NULL, &tv);
if ( ret > 0 )
{
if( xTraceRunning == pdTRUE )
{
prvSaveTraceFile();
}
/* clear the buffer */
char buffer[200];
read(1, &buffer, 200);
}
}

void vLoggingPrintf( const char *pcFormat,
... )
{
Expand Down
11 changes: 2 additions & 9 deletions FreeRTOS/Demo/Posix_GCC/main_full.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

/*
*******************************************************************************
* NOTE 1: The Linux port is a simulation (or is that emulation?) only! Do not
* expect to get real time behaviour from the Linux port or this demo
* NOTE 1: The POSIX port is a simulation (or is that emulation?) only! Do not
* expect to get real time behaviour from the POSIX port or this demo
* application. It is provided as a convenient development and demonstration
* test bed only.
*
Expand Down Expand Up @@ -719,13 +719,6 @@ uint32_t ulIdleExecutionTime;
}
}
}

ulIdleExecutionTime = ulTaskGetIdleRunTimeCounter();
if( ulIdleExecutionTime == ulLastIdleExecutionTime )
{
pcStatusMessage = "Error: Total amount of Idle task execution time did not change";
}
ulLastIdleExecutionTime = ulIdleExecutionTime;
}
/*-----------------------------------------------------------*/

Expand Down

0 comments on commit 0d571fb

Please sign in to comment.