1\page mipi_syst_example_page Instrumentation API Examples 2 3[TOC] 4 5SyS-T ships with various example applications that show how to use 6instrumentation calls. The examples are stored inside the examples 7directory of the distribution file set. A CMake script is provided for 8building the examples on CMake supported platforms. To build the 9examples without CMake, add the SyS-T include directory to the list of 10include directories for the compiler being used and tell the linker 11to link against the SyS-T library. 12 13Example for building a SyS-T example on Linux: 14 15 $ export MIPI_SYST_SDK=<enter path to SyS-T-SDK here> 16 $ gcc -o hello hello.c -I$MIPI_SYST_SDK/include -L$MIPI_SYST_SDK/lib -lmipi_syst 17 18 19SyS-T "hello world" Style Application 20=========================================================================== 21This example is stored in the examples/hello directory of the SyS-T 22distribution. 23 24Example source code: 25 26\code{.c} 27#include "mipi_syst.h" /* SyS-T definitions */ 28 29 30/* Define origin used by this example as the message client ID 31 */ 32static const struct mipi_syst_origin origin = 33MIPI_SYST_GEN_ORIGIN_GUID(0x494E5443, 0xA2AE, 0x4C70, 0xABB5, 0xD1A79E9CEA35, 1); 34 35int main(int argc, char* argv[]) 36{ 37 struct mipi_syst_handle* systh; 38 39 /* Initialize a SyS-T output handle structure 40 */ 41 systh = MIPI_SYST_ALLOC_HANDLE( &origin ); 42 43 /* Send a string message with payload "Hello World!" 44 */ 45 MIPI_SYST_DEBUG(systh, MIPI_SYST_SEVERITY_INFO, "Hello world!" , /*length*/ 12); 46 47 /* Release any resources associated with this SyS-T handle. 48 */ 49 MIPI_SYST_DELETE_HANDLE(systh); 50 51 return 0; 52} 53\endcode 54 55The example will produce output like that below if the ``example`` platform is used. 56It shows which MIPI STP protocol packets are created to transport the 57SYS-T message data. 58 59``` 60STP Protocol Output: 61 0 <D32TS> 01800242 // SyS-T header 62 1 <D64> 704caea243544e49 // GUID part #1 63 2 <D64> 35ea9c9ea7d1b5ab // GUID part #2 64 3 <D64> 6f77206f6c6c6548 // Payload part #1 65 4 <D32> 21646c72 // Payload part #2 66 5 <FLAG> // end of record 67SYS-T RAW DATA: 42108001494E5443A2AE4C70ABB5D1A79E9CEA3548656C6C6F20776F726C6421 68``` 69