]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c
Update trace recorder code to the latest.
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-Trace / trcStreamingRecorder.c
index c86d688e6baffbe1d712bf802e36a05e330008f8..dc1b87865cda49e2da307a3d51c2c9523a061f56 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Trace Recorder Library for Tracealyzer v4.1.1\r
+ * Trace Recorder Library for Tracealyzer v4.1.5\r
  * Percepio AB, www.percepio.com\r
  *\r
  * trcStreamingRecorder.c\r
@@ -48,6 +48,9 @@
 \r
 #if (TRC_USE_TRACEALYZER_RECORDER == 1)\r
 \r
+#include <stdio.h>\r
+#include <stdarg.h>\r
+\r
 typedef struct{\r
        uint16_t EventID;\r
        uint16_t EventCount;\r
@@ -174,9 +177,6 @@ static uint16_t FormatVersion = 0x0004;
 /* The number of events stored. Used as event sequence number. */\r
 static uint32_t eventCounter = 0;\r
 \r
-/* The user event channel for recorder warnings, defined in trcKernelPort.c */\r
-extern char* trcWarningChannel;\r
-\r
 /* Remembers if an earlier ISR in a sequence of adjacent ISRs has triggered a task switch.\r
 In that case, vTraceStoreISREnd does not store a return to the previously executing task. */\r
 int32_t isPendingContextSwitch = 0;\r
@@ -399,6 +399,37 @@ void vTracePrint(traceString chn, const char* str)
        prvTraceStoreSimpleStringEventHelper(chn, str);\r
 }\r
 \r
+\r
+/*******************************************************************************\r
+* vTraceConsoleChannelPrintF\r
+*\r
+* Wrapper for vTracePrint, using the default channel. Can be used as a drop-in\r
+* replacement for printf and similar functions, e.g. in a debug logging macro.\r
+*\r
+* Example:\r
+*\r
+*       // Old: #define LogString debug_console_printf\r
+*\r
+*    // New, log to Tracealyzer instead:\r
+*       #define LogString vTraceConsoleChannelPrintF\r
+*       ...\r
+*       LogString("My value is: %d", myValue);\r
+******************************************************************************/\r
+void vTraceConsoleChannelPrintF(const char* fmt, ...)\r
+{\r
+               va_list vl;\r
+               char tempBuf[60];\r
+               static traceString consoleChannel = NULL;\r
+\r
+               if (consoleChannel == NULL)\r
+                       consoleChannel = xTraceRegisterString("Debug Console");\r
+\r
+               va_start(vl, fmt);\r
+               vsnprintf(tempBuf, 60, fmt, vl);\r
+               vTracePrint(consoleChannel, tempBuf);\r
+               va_end(vl);\r
+}\r
+\r
 /******************************************************************************\r
  * vTracePrintF\r
  *\r