diff options
Diffstat (limited to 'src/examples')
-rw-r--r-- | src/examples/dlt-example-filetransfer.c | 82 | ||||
-rw-r--r-- | src/examples/dlt-example-user-common-api.c | 68 | ||||
-rw-r--r-- | src/examples/dlt-example-user-func.c | 60 | ||||
-rw-r--r-- | src/examples/dlt-example-user.c | 84 |
4 files changed, 147 insertions, 147 deletions
diff --git a/src/examples/dlt-example-filetransfer.c b/src/examples/dlt-example-filetransfer.c index a56e09d..4fc10e2 100644 --- a/src/examples/dlt-example-filetransfer.c +++ b/src/examples/dlt-example-filetransfer.c @@ -58,8 +58,8 @@ #include <stdio.h> #include <ctype.h> -#include <dlt_filetransfer.h> /*Needed for transferring files with the dlt protocol*/ -#include <dlt.h> /*Needed for dlt logging*/ +#include <dlt_filetransfer.h> /*Needed for transferring files with the dlt protocol*/ +#include <dlt.h> /*Needed for dlt logging*/ #define MAXSTRLEN 1024 @@ -81,9 +81,9 @@ DLT_DECLARE_CONTEXT(fileContext); */ void usage() { - char version[255]; + char version[255]; - dlt_get_version(version,255); + dlt_get_version(version,255); printf("Usage: dlt-example-filetransfer [options] absolute-path-to-file\n"); printf("Simple filetransfer example"); @@ -102,7 +102,7 @@ void usage() //!Main program dlt-test-filestransfer starts here int main(int argc, char* argv[]) { - //char str[MAXSTRLEN]; + //char str[MAXSTRLEN]; int opt, timeout; char apid[DLT_ID_SIZE]; @@ -110,19 +110,19 @@ int main(int argc, char* argv[]) //char version[255]; int index; - int dflag = 0; - int iflag = 0; - char *file = 0; - char *tvalue = 0; + int dflag = 0; + int iflag = 0; + char *file = 0; + char *tvalue = 0; dlt_set_id(apid, FLTR_APP); dlt_set_id(ctid, FLTR_CONTEXT); - while ((opt = getopt(argc, argv, "idf:t:a:c:h")) != -1) + while ((opt = getopt(argc, argv, "idf:t:a:c:h")) != -1) { switch (opt) { - case 'd': + case 'd': { dflag = 1; break; @@ -173,21 +173,21 @@ int main(int argc, char* argv[]) } } - for (index = optind; index < argc; index++) - { - file = argv[index]; - } + for (index = optind; index < argc; index++) + { + file = argv[index]; + } - if (file == 0) - { - /* no message, show usage and terminate */ - fprintf(stderr,"ERROR: No absolute path to file specified\n"); - usage(); - return -1; - } + if (file == 0) + { + /* no message, show usage and terminate */ + fprintf(stderr,"ERROR: No absolute path to file specified\n"); + usage(); + return -1; + } - if (tvalue) + if (tvalue) { timeout = atoi(tvalue); } @@ -196,27 +196,27 @@ int main(int argc, char* argv[]) timeout = TIMEOUT; } - //Register the application at the dlt-daemon - DLT_REGISTER_APP(apid,FLTR_APP_DESC); + //Register the application at the dlt-daemon + DLT_REGISTER_APP(apid,FLTR_APP_DESC); - //Register the context of the main program at the dlt-daemon - DLT_REGISTER_CONTEXT(fileContext,ctid,FLTR_CONTEXT_DESC); + //Register the context of the main program at the dlt-daemon + DLT_REGISTER_CONTEXT(fileContext,ctid,FLTR_CONTEXT_DESC); - //More details in corresponding methods - if( iflag ) - { - dlt_user_log_file_infoAbout(&fileContext,file); - } + //More details in corresponding methods + if( iflag ) + { + dlt_user_log_file_infoAbout(&fileContext,file); + } - if( dlt_user_log_file_complete(&fileContext,file,dflag,timeout) < 0 ) - { - printf("File couldn't be transferred. Please check the dlt log messages.\n"); - } + if( dlt_user_log_file_complete(&fileContext,file,dflag,timeout) < 0 ) + { + printf("File couldn't be transferred. Please check the dlt log messages.\n"); + } - //Unregister the context in which the file transfer happened from the dlt-daemon - DLT_UNREGISTER_CONTEXT(fileContext); - //Unregister the context of the main program from the dlt-daemon - DLT_UNREGISTER_APP(); + //Unregister the context in which the file transfer happened from the dlt-daemon + DLT_UNREGISTER_CONTEXT(fileContext); + //Unregister the context of the main program from the dlt-daemon + DLT_UNREGISTER_APP(); - return 0; + return 0; } diff --git a/src/examples/dlt-example-user-common-api.c b/src/examples/dlt-example-user-common-api.c index dba4897..ee6370c 100644 --- a/src/examples/dlt-example-user-common-api.c +++ b/src/examples/dlt-example-user-common-api.c @@ -85,9 +85,9 @@ void usage() printf(" -a Enable local printing of DLT messages (Default: disabled)\n"); printf(" -m mode Set log mode 0=off,1=external,2=internal,3=both\n"); #ifdef DLT_TEST_ENABLE - printf(" -c Corrupt user header\n"); + printf(" -c Corrupt user header\n"); printf(" -s size Corrupt message size\n"); - printf(" -z size Size of message\n"); + printf(" -z size Size of message\n"); #endif /* DLT_TEST_ENABLE */ } @@ -109,11 +109,11 @@ int main(int argc, char* argv[]) int index; int c; - char *text; - int num,maxnum; - int delay; + char *text; + int num,maxnum; + int delay; - int state=-1,newstate; + int state=-1,newstate; opterr = 0; #ifdef DLT_TEST_ENABLE @@ -207,7 +207,7 @@ int main(int argc, char* argv[]) } else { - maxnum = 10; + maxnum = 10; } if (dvalue) @@ -232,44 +232,44 @@ int main(int argc, char* argv[]) #ifdef DLT_TEST_ENABLE if (cflag) { - dlt_user_test_corrupt_user_header(1); + dlt_user_test_corrupt_user_header(1); } if (svalue) { - dlt_user_test_corrupt_message_size(1,atoi(svalue)); + dlt_user_test_corrupt_message_size(1,atoi(svalue)); } - if (zvalue) - { - char* buffer = malloc(atoi(zvalue)); - if(buffer==0) - { - /* no message, show usage and terminate */ - fprintf(stderr,"Cannot allocate buffer memory!\n"); - return -1; - } + if (zvalue) + { + char* buffer = malloc(atoi(zvalue)); + if(buffer==0) + { + /* no message, show usage and terminate */ + fprintf(stderr,"Cannot allocate buffer memory!\n"); + return -1; + } DLT_LOG2(mycontext,DLT_LOG_WARN,DLT_STRING(text),DLT_RAW(buffer,atoi(zvalue))); - free(buffer); - } + free(buffer); + } #endif /* DLT_TEST_ENABLE */ for (num=0;num<maxnum;num++) { printf("Send %d %s\n",num,text); - newstate = dlt_get_log_state(); - if(state!=newstate) - { - state = newstate; - if(state == -1) { - printf("Client unknown state!\n"); - } - else if(state == 0) { - printf("Client disconnected!\n"); - } - else if(state == 1) { - printf("Client connected!\n"); - } - } + newstate = dlt_get_log_state(); + if(state!=newstate) + { + state = newstate; + if(state == -1) { + printf("Client unknown state!\n"); + } + else if(state == 0) { + printf("Client disconnected!\n"); + } + else if(state == 1) { + printf("Client connected!\n"); + } + } if (gflag) { diff --git a/src/examples/dlt-example-user-func.c b/src/examples/dlt-example-user-func.c index 777f340..68b3397 100644 --- a/src/examples/dlt-example-user-func.c +++ b/src/examples/dlt-example-user-func.c @@ -116,8 +116,8 @@ int main(int argc, char* argv[]) int index; int c; char *text; - int num,maxnum; - int delay; + int num,maxnum; + int delay; opterr = 0; @@ -223,7 +223,7 @@ int main(int argc, char* argv[]) } else { - maxnum = 10; + maxnum = 10; } if (dvalue) @@ -235,35 +235,35 @@ int main(int argc, char* argv[]) delay = 500 * 1000; } - if (gflag) + if (gflag) { /* DLT messages to test Fibex non-verbose description: dlt-example-non-verbose.xml */ - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,10)>0) - { - dlt_user_log_write_finish(&mycontextdata); - } - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,11)>0) - { - dlt_user_log_write_uint16(&mycontextdata,1011); - dlt_user_log_write_finish(&mycontextdata); - } - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,12)>0) - { - dlt_user_log_write_uint32(&mycontextdata,1012); - dlt_user_log_write_uint32(&mycontextdata,1013); - dlt_user_log_write_finish(&mycontextdata); - } - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,13)>0) - { - dlt_user_log_write_uint8(&mycontextdata,123); - dlt_user_log_write_float32(&mycontextdata,1.12); - dlt_user_log_write_finish(&mycontextdata); - } - if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,14)>0) - { - dlt_user_log_write_string(&mycontextdata,"DEAD BEEF"); - dlt_user_log_write_finish(&mycontextdata); - } + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,10)>0) + { + dlt_user_log_write_finish(&mycontextdata); + } + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,11)>0) + { + dlt_user_log_write_uint16(&mycontextdata,1011); + dlt_user_log_write_finish(&mycontextdata); + } + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,12)>0) + { + dlt_user_log_write_uint32(&mycontextdata,1012); + dlt_user_log_write_uint32(&mycontextdata,1013); + dlt_user_log_write_finish(&mycontextdata); + } + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,13)>0) + { + dlt_user_log_write_uint8(&mycontextdata,123); + dlt_user_log_write_float32(&mycontextdata,1.12); + dlt_user_log_write_finish(&mycontextdata); + } + if (dlt_user_log_write_start_id(&mycontext,&mycontextdata,DLT_LOG_INFO,14)>0) + { + dlt_user_log_write_string(&mycontextdata,"DEAD BEEF"); + dlt_user_log_write_finish(&mycontextdata); + } } for (num=0;num<maxnum;num++) diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c index 5822fde..3479ee8 100644 --- a/src/examples/dlt-example-user.c +++ b/src/examples/dlt-example-user.c @@ -106,7 +106,7 @@ void usage() #ifdef DLT_TEST_ENABLE printf(" -c Corrupt user header\n"); printf(" -s size Corrupt message size\n"); - printf(" -z size Size of message\n"); + printf(" -z size Size of message\n"); #endif /* DLT_TEST_ENABLE */ } @@ -134,11 +134,11 @@ int main(int argc, char* argv[]) int index; int c; - char *text; - int num,maxnum; - int delay; + char *text; + int num,maxnum; + int delay; - int state=-1,newstate; + int state=-1,newstate; opterr = 0; #ifdef DLT_TEST_ENABLE @@ -273,11 +273,11 @@ int main(int argc, char* argv[]) text = message; - if(mvalue) - { + if(mvalue) + { printf("Set log mode to %d\n",atoi(mvalue)); - dlt_set_log_mode(atoi(mvalue)); - } + dlt_set_log_mode(atoi(mvalue)); + } if (gflag) @@ -292,7 +292,7 @@ int main(int argc, char* argv[]) if (kflag) { - DLT_LOG_MARKER(); + DLT_LOG_MARKER(); } if (nvalue) @@ -301,7 +301,7 @@ int main(int argc, char* argv[]) } else { - maxnum = 10; + maxnum = 10; } if (dvalue) @@ -331,44 +331,44 @@ int main(int argc, char* argv[]) #ifdef DLT_TEST_ENABLE if (cflag) { - dlt_user_test_corrupt_user_header(1); + dlt_user_test_corrupt_user_header(1); } if (svalue) { - dlt_user_test_corrupt_message_size(1,atoi(svalue)); + dlt_user_test_corrupt_message_size(1,atoi(svalue)); + } + if (zvalue) + { + char* buffer = malloc(atoi(zvalue)); + if(buffer==0) + { + /* no message, show usage and terminate */ + fprintf(stderr,"Cannot allocate buffer memory!\n"); + return -1; + } + DLT_LOG(mycontext,DLT_LOG_WARN,DLT_STRING(text),DLT_RAW(buffer,atoi(zvalue))); + free(buffer); } - if (zvalue) - { - char* buffer = malloc(atoi(zvalue)); - if(buffer==0) - { - /* no message, show usage and terminate */ - fprintf(stderr,"Cannot allocate buffer memory!\n"); - return -1; - } - DLT_LOG(mycontext,DLT_LOG_WARN,DLT_STRING(text),DLT_RAW(buffer,atoi(zvalue))); - free(buffer); - } #endif /* DLT_TEST_ENABLE */ for (num=0;num<maxnum;num++) { printf("Send %d %s\n",num,text); - newstate = dlt_get_log_state(); - if(state!=newstate) - { - state = newstate; - if(state == -1) { - printf("Client unknown state!\n"); - } - else if(state == 0) { - printf("Client disconnected!\n"); - } - else if(state == 1) { - printf("Client connected!\n"); - } - } + newstate = dlt_get_log_state(); + if(state!=newstate) + { + state = newstate; + if(state == -1) { + printf("Client unknown state!\n"); + } + else if(state == 0) { + printf("Client disconnected!\n"); + } + else if(state == 1) { + printf("Client connected!\n"); + } + } if (gflag) { @@ -414,10 +414,10 @@ int dlt_user_injection_callback(uint32_t service_id, void *data, uint32_t length void dlt_user_log_level_changed_callback(char context_id[DLT_ID_SIZE],uint8_t log_level,uint8_t trace_status) { - char text[5]; - text[4]=0; + char text[5]; + text[4]=0; - memcpy(text,context_id,DLT_ID_SIZE); + memcpy(text,context_id,DLT_ID_SIZE); printf("Log level changed of context %s, LogLevel=%u, TraceState=%u \n",text,log_level,trace_status); } |