/** * @licence app begin@ * Copyright (C) 2012 BMW AG * * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps. * * Contributions are licensed to the GENIVI Alliance under one or more * Contribution License Agreements. * * \copyright * This Source Code Form is subject to the terms of the * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * * * \author Alexander Wenzel BMW 2011-2012 * * \file dlt-test-user.c * For further information see http://www.genivi.org/. * @licence end@ */ /******************************************************************************* ** ** ** SRC-MODULE: dlt-test-user.c ** ** ** ** TARGET : linux ** ** ** ** PROJECT : DLT ** ** ** ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** ** Markus Klein ** ** ** ** PURPOSE : ** ** ** ** REMARKS : ** ** ** ** PLATFORM DEPENDANT [yes/no]: yes ** ** ** ** TO BE CHANGED BY USER [yes/no]: no ** ** ** *******************************************************************************/ /******************************************************************************* ** Author Identity ** ******************************************************************************** ** ** ** Initials Name Company ** ** -------- ------------------------- ---------------------------------- ** ** aw Alexander Wenzel BMW ** ** mk Markus Klein Fraunhofer ESK ** *******************************************************************************/ /******************************************************************************* ** Revision Control History ** *******************************************************************************/ /* * $LastChangedRevision: 1670 $ * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $ * $LastChangedBy$ Initials Date Comment aw 13.01.2010 initial */ #include /* for printf() and fprintf() */ #include #include /* for atoi(), abort() */ #include /* for memset() */ #include /* for isprint() */ #include "dlt.h" #define DLT_TEST_NUM_CONTEXT 7 /* Test functions... */ /* for macro interface */ int test1m(void); int test2m(void); int test3m(void); int test4m(void); int test5m(void); int test6m(void); int test7m(void); /* for function interface */ int test1f(void); int test2f(void); int test3f(void); int test4f(void); int test5f(void); int test6f(void); int test7f(void); /* Declaration of callback functions */ int test_injection_macro_callback(uint32_t service_id, void *data, uint32_t length); int test_injection_function_callback(uint32_t service_id, void *data, uint32_t length); /* Context declaration.. */ DLT_DECLARE_CONTEXT(context_info); /* for macro interface */ DLT_DECLARE_CONTEXT(context_macro_callback); DLT_DECLARE_CONTEXT(context_macro_test[DLT_TEST_NUM_CONTEXT]); /* for function interface */ DltContext context_function_callback; DltContext context_function_test[DLT_TEST_NUM_CONTEXT]; DltContextData context_data; /** * Print usage information of tool. */ void usage() { char version[255]; dlt_get_version(version); printf("Usage: dlt-test-user [options]\n"); printf("Test user application providing several Tests.\n"); printf("%s \n", version); printf("Options:\n"); printf(" -v Verbose mode\n"); printf(" -f filename Use local log file instead of sending to daemon\n"); printf(" -n count Repeats of tests (Default: 1)\n"); printf("Tests:\n"); printf(" 1m: (Macro IF) Test all log levels\n"); printf(" 2m: (Macro IF) Test all variable types (verbose) \n"); printf(" 3m: (Macro IF) Test all variable types (non-verbose) \n"); printf(" 4m: (Macro IF) Test different message sizes\n"); printf(" 5m: (Macro IF) Test high-level API\n"); printf(" 6m: (Macro IF) Test local printing\n"); printf(" 7m: (Macro IF) Test network trace\n"); printf(" 1f: (Function IF) Test all log levels\n"); printf(" 2f: (Function IF) Test all variable types (verbose) \n"); printf(" 3f: (Function IF) Test all variable types (non-verbose) \n"); printf(" 4f: (Function IF) Test different message sizes\n"); printf(" 5f: (Function IF) Test high-level API\n"); printf(" 6f: (Function IF) Test local printing\n"); printf(" 7f: (Function IF) Test network trace\n"); } /** * Main function of tool. */ int main(int argc, char* argv[]) { //int vflag = 0; char *fvalue = 0; char *nvalue = 0; int c; int i; char ctid[4], ctdesc[255]; int num,maxnum; opterr = 0; while ((c = getopt (argc, argv, "vf:n:")) != -1) { switch (c) { case 'v': { //vflag = 1; break; } case 'f': { fvalue = optarg; break; } case 'n': { nvalue = optarg; break; } case '?': { if (optopt == 'd' || optopt == 'f' || optopt == 'n') { fprintf (stderr, "Option -%c requires an argument.\n", optopt); } else if (isprint (optopt)) { fprintf (stderr, "Unknown option `-%c'.\n", optopt); } else { fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt); } /* unknown or wrong option used, show usage information and terminate */ usage(); return -1; } default: { abort (); } } } if (fvalue) { /* DLT is intialised automatically, except another output target will be used */ if (dlt_init_file(fvalue)<0) /* log to file */ { return -1; } } if (nvalue) { maxnum = atoi(nvalue); } else { maxnum = 1; } /* Register APP */ DLT_REGISTER_APP("DIFT","DLT Interface Test"); /* Register CONTEXTS... */ DLT_REGISTER_CONTEXT(context_info,"INFO","Information context"); /* used for macro interface tests */ DLT_REGISTER_CONTEXT(context_macro_callback,"CBM","Callback Test context for macro interface"); for (i=0;i0) { dlt_print_mixed_string(text,1024,data,length,0); printf("%s \n", text); } return 0; } int test_injection_function_callback(uint32_t service_id, void *data, uint32_t length) { char text[1024]; memset(text,0,1024); snprintf(text,1024,"Injection received (function IF). ID: 0x%.4x, Length: %d",service_id,length); printf("%s \n", text); memset(text,0,1024); if (length>0) { dlt_print_mixed_string(text,1024,data,length,0); printf("%s \n", text); } return 0; }