32 static void string_stream(
const char* s,
void *arg) {
33 strcat((
char*)arg, s);
36 static bool test_tlm(
void)
38 long long int a = 0xAA00DEADBEEF0055;
44 puts(
"Test: Add 1 component");
48 char str_stream[128] = { 0 };
50 assert(0 == strcmp(str_stream,
"START:first:0\nEND:first\n"));
52 puts(
"Test: Add 2 components");
54 assert(0 != second_comp);
61 puts(
"Test: Add 3rd component with large data");
63 assert(0 != third_comp);
65 char large_array1[512] = { 0 };
66 char large_array2[512] = { 0 };
67 char large_array_org[512] = { 0 };
68 for (
int i = 0; i <
sizeof(large_array1); i++) {
71 large_array_org[i] = i;
77 puts(
"Test: Add variable to component");
83 puts(
"Test: Register variables to component");
89 puts(
"Test: Get pointer by name");
93 puts(
"Test: TLM Stream decode");
96 char stream_start[100] =
"START:second:2\n";
97 char stream_var_a[100] =
"b:4:1:0:01,01,00,00";
98 char stream_var_d[100] =
"d:1:1:0:11";
99 assert(tlm_stream_decode(stream_start));
100 assert(!tlm_stream_decode(stream_var_a));
101 assert(!tlm_stream_decode(stream_var_d));
105 puts(
"Test: TLM Stream to stdio");
113 puts(
"Test: TLM Stream to file");
114 FILE *file = fopen(
"test.txt",
"w");
121 memset(large_array1, 0,
sizeof(large_array1));
122 memset(large_array2, 0,
sizeof(large_array2));
123 file = fopen(
"test.txt",
"r");
126 assert(0x12345 == b);
128 assert(0 == memcmp(large_array_org, large_array1,
sizeof(large_array_org)));
129 assert(0 == memcmp(large_array_org, large_array2,
sizeof(large_array_org)));
133 char s1[42] =
"0123456789012345678901234567890123456789";
134 char s2[42] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN";
139 file = fopen(
"test.txt",
"w");
144 memset(s1, 0,
sizeof(s1));
145 memset(s2, 0,
sizeof(s2));
147 file = fopen(
"test.txt",
"r");
152 printf(
"s1 = |%s|\n", s1);
153 printf(
"s2 = |%s|\n", s2);
155 assert(0 == strcmp(s1,
"0123456789012345678901234567890123456789"));
156 assert(0 == strcmp(s2,
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN"));
printf("Recorder started: %s\n", uiTraceStart()?"OK":"ERROR")
tlm_component * tlm_component_get_by_name(const char *name)
Definition: c_tlm_comp.c:84
Each real time kernel port consists of three files that contain the core kernel components and are common to every and one or more files that are specific to a particular microcontroller and or compiler The FreeRTOS Source directory contains the three files that are common to every port list c
Definition: readme.txt:2
tlm_component * tlm_component_add(const char *name)
Definition: c_tlm_comp.c:43
void tlm_stream_one(tlm_component *comp, stream_callback_type stream, void *print_ascii, void *arg)
Definition: c_tlm_stream.c:175
void tlm_stream_one_file(tlm_component *comp_ptr, FILE *file)
Definition: c_tlm_stream.c:235
Telemetry stream and decode.
bool tlm_stream_decode_file(FILE *file)
Definition: c_tlm_stream.c:266
bool tlm_variable_register(tlm_component *comp_ptr, const char *name, const void *data_ptr, const uint16_t data_size, const uint16_t arr_size, tlm_type type)
Definition: c_tlm_var.c:55
Definition: c_tlm_var.h:40
#define TLM_REG_VAR(comp, var, type)
Definition: c_tlm_var.h:88
Definition: c_tlm_var.h:45
void tlm_stream_all_file(FILE *file)
Definition: c_tlm_stream.c:256
Definition: c_tlm_var.h:42
const tlm_reg_var_type * tlm_variable_get_by_name(tlm_component *comp_ptr, const char *name)
Definition: c_tlm_var.c:94
Definition: c_tlm_comp.h:51
Definition: c_tlm_var.h:43