diff options
author | ManikandanC <Manikandan.Chockalingam@in.bosch.com> | 2017-05-22 10:57:21 +0530 |
---|---|---|
committer | Manikandan C <mchockalingam@de.adit-jv.com> | 2018-12-06 12:28:13 +0100 |
commit | 23652a7cbfb4ea24870f4e2f03cf16b9ece4c1ce (patch) | |
tree | 11716c37bc99a591804c8adad087f2eb0a93641d /src/examples/dlt-example-user.c | |
parent | f50cd0544d70c837d68a28316d2141c5a650db91 (diff) | |
download | DLT-daemon-dynamic_buffer_alloc.tar.gz |
Dynamic allocation of msg bufferdynamic_buffer_alloc
It is possible to change the default buffer size for log message creation via
environment variable:
export DLT_LOG_MSG_BUF_LEN=<value>
Instead of using a static buffer with size of 1390 bytes, the buffer is
allocated dynamically with the specified value.The max size is restricted to approx 65k.
Signed-off-by: Christoph Lipka <clipka@de.adit-jv.com>
Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com>
Diffstat (limited to 'src/examples/dlt-example-user.c')
-rw-r--r-- | src/examples/dlt-example-user.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c index 532402a..12d9c37 100644 --- a/src/examples/dlt-example-user.c +++ b/src/examples/dlt-example-user.c @@ -103,6 +103,7 @@ void usage() printf(" -m mode Set log mode 0=off,1=external,2=internal,3=both\n"); printf(" -l level Set log level to <level>, level=-1..6\n"); printf(" -t timeout Set timeout when sending messages at exit, in ms (Default: 10000 = 10sec)\n"); + printf(" -r size Send raw data with specified size instead of string\n"); #ifdef DLT_TEST_ENABLE printf(" -c Corrupt user header\n"); printf(" -s size Corrupt message size\n"); @@ -130,6 +131,7 @@ int main(int argc, char* argv[]) char *message = 0; int lvalue = DLT_LOG_WARN; char *tvalue = 0; + int rvalue = -1; int index; int c; @@ -142,9 +144,9 @@ int main(int argc, char* argv[]) opterr = 0; #ifdef DLT_TEST_ENABLE - while ((c = getopt (argc, argv, "vgakcd:f:n:m:z:s:l:t:")) != -1) + while ((c = getopt (argc, argv, "vgakcd:f:n:m:z:r:s:l:t:")) != -1) #else - while ((c = getopt (argc, argv, "vgakd:f:n:m:l:t:")) != -1) + while ((c = getopt (argc, argv, "vgakd:f:n:m:l:r:t:")) != -1) #endif /* DLT_TEST_ENABLE */ { switch (c) @@ -211,6 +213,11 @@ int main(int argc, char* argv[]) tvalue = optarg; break; } + case 'r': + { + rvalue = atoi(optarg); + break; + } case '?': { if (optopt == 'd' || optopt == 'f' || optopt == 'n'|| optopt == 'l' || optopt == 't') @@ -238,9 +245,17 @@ int main(int argc, char* argv[]) } } - for (index = optind; index < argc; index++) + if (rvalue == -1) + { + for (index = optind; index < argc; index++) + { + message = argv[index]; + } + } + else /* allocate raw buffer */ { - message = argv[index]; + message = calloc(sizeof(char), rvalue); + memset(message, 'X', rvalue-1); } if (message == 0) @@ -377,8 +392,15 @@ int main(int argc, char* argv[]) } else { - /* Verbose mode */ - DLT_LOG(mycontext,lvalue,DLT_INT(num),DLT_STRING(text)); + if (rvalue == -1) + { + /* Verbose mode */ + DLT_LOG(mycontext,lvalue,DLT_INT(num),DLT_STRING(text)); + } + else + { + DLT_LOG(mycontext,lvalue,DLT_RAW(text, rvalue)); + } } if (delay>0) |