1 /*
2 Copyright (c) 2018, MIPI Alliance, Inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 * Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
15 distribution.
16
17 * Neither the name of the copyright holder nor the names of its
18 contributors may be used to endorse or promote products derived
19 from this software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include "mipi_syst.h"
35
36 /* Example SyS-T client code using various instrumentation call types */
37
38 const struct mipi_syst_origin origin =
39 MIPI_SYST_GEN_ORIGIN_GUID(0x494E5443, 0x8A9C, 0x4014, 0xA65A, 0x2F36A36D96E4, 1);
40 struct mipi_syst_handle * systh;
41
42 void banner();
43 void sinewave();
44 void raw();
45 void printf_format_test();
46 void catalog_format_test();
47 void short_messages();
48
main(int argc,char * argv[])49 int main(int argc, char* argv[])
50 {
51 #if defined(MIPI_SYST_STATIC)
52 MIPI_SYST_INIT(mipi_syst_platform_init, 0);
53 #endif
54
55 systh = MIPI_SYST_ALLOC_HANDLE(&origin);
56
57 /* add optional fields */
58 MIPI_SYST_ENABLE_HANDLE_CHECKSUM(systh, 1);
59 MIPI_SYST_ENABLE_HANDLE_TIMESTAMP(systh, 1);
60
61 MIPI_SYST_BUILD(systh, MIPI_SYST_SEVERITY_MAX, 0x00010000, "version banner string", sizeof("version banner string"));
62
63 MIPI_SYST_CATALOG32_3(systh, MIPI_SYST_SEVERITY_INFO,
64 MIPI_SYST_HASH("SyS-T Library version %d.%d.%d",0),
65 MIPI_SYST_VERSION_MAJOR,
66 MIPI_SYST_VERSION_MINOR,
67 MIPI_SYST_VERSION_PATCH);
68
69 banner();
70 catalog_format_test();
71 printf_format_test();
72 sinewave();
73 raw();
74 short_messages();
75
76 /* Different catalog calls */
77 MIPI_SYST_CATPRINTF64_0(systh, MIPI_SYST_SEVERITY_INFO, 0x1122334455667788, "Hello world\n");
78 MIPI_SYST_CATPRINTF32(systh, MIPI_SYST_SEVERITY_INFO, 2, "%s=%d\n",
79 MIPI_SYST_PARAM_CSTR("state"),
80 MIPI_SYST_PARAM_INT(10)
81 );
82 MIPI_SYST_CATALOG32(systh, MIPI_SYST_SEVERITY_INFO, MIPI_SYST_HASH("%s=%d\n", 0),
83 MIPI_SYST_PARAM_CSTR("state"),
84 MIPI_SYST_PARAM_INT(10)
85 );
86
87 /* Release any resources associated with this SyS-T handle.
88 */
89 MIPI_SYST_DELETE_HANDLE(systh);
90
91 #if defined(MIPI_SYST_STATIC)
92 MIPI_SYST_SHUTDOWN(mipi_syst_platform_destroy);
93 #endif
94
95 return 0;
96 }