From 7feddfe828414c876af27ba7e425ff4da989f4e2 Mon Sep 17 00:00:00 2001 From: Alexander Wenzel Date: Thu, 15 May 2014 10:47:05 +0200 Subject: Added new examples which can be manually build against DLt library. Signed-off-by: Alexander Wenzel --- examples/README.txt | 4 + examples/example1/CMakeLists.txt | 56 +++++++++++++ examples/example1/example1.c | 64 +++++++++++++++ examples/example2/CMakeLists.txt | 56 +++++++++++++ examples/example2/dlt_id.h | 10 +++ examples/example2/example2.c | 73 +++++++++++++++++ examples/example2/example2.xml | 167 +++++++++++++++++++++++++++++++++++++++ examples/example3/CMakeLists.txt | 56 +++++++++++++ examples/example3/dlt_id.h | 10 +++ examples/example3/example3.c | 73 +++++++++++++++++ examples/example3/example3.xml | 167 +++++++++++++++++++++++++++++++++++++++ 11 files changed, 736 insertions(+) create mode 100644 examples/README.txt create mode 100755 examples/example1/CMakeLists.txt create mode 100644 examples/example1/example1.c create mode 100755 examples/example2/CMakeLists.txt create mode 100644 examples/example2/dlt_id.h create mode 100644 examples/example2/example2.c create mode 100644 examples/example2/example2.xml create mode 100755 examples/example3/CMakeLists.txt create mode 100644 examples/example3/dlt_id.h create mode 100644 examples/example3/example3.c create mode 100644 examples/example3/example3.xml (limited to 'examples') diff --git a/examples/README.txt b/examples/README.txt new file mode 100644 index 0000000..728e5c2 --- /dev/null +++ b/examples/README.txt @@ -0,0 +1,4 @@ +This folder contains several examples of applications using the DLT library. These examples will be extended in the future to show different Use Cases. + +Example1: Minimal DLT Example +Example2-3: Non Verbose Mode Examples with different AppIdds diff --git a/examples/example1/CMakeLists.txt b/examples/example1/CMakeLists.txt new file mode 100755 index 0000000..363a567 --- /dev/null +++ b/examples/example1/CMakeLists.txt @@ -0,0 +1,56 @@ +####### +# Dlt - Diagnostic Log and Trace +# @licence make begin@ +# +# Copyright (C) 2011-2014, BMW AG - Alexander Wenzel +# +# Contributions are licensed to the GENIVI Alliance under one or more +# Contribution License Agreements. +# +# 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/. +# +# @licence end@ +######## + +# +# DLT example implementation +# + +cmake_minimum_required( VERSION 2.6 ) +project( automotive-dlt-example1 ) + +# +# set prefix +# + +set( CMAKE_INSTALL_PREFIX "/usr" ) + +# +# find dependency packages +# + +find_package(PkgConfig) +pkg_check_modules(DLT REQUIRED automotive-dlt) + +# +# include directories +# + +include_directories( + ${DLT_INCLUDE_DIRS} +) + +# +# build project +# + +set(dlt_example1_SRCS example1.c) +add_executable(dlt-example1 ${dlt_example1_SRCS}) +target_link_libraries(dlt-example1 ${DLT_LIBRARIES}) +set_target_properties(dlt-example1 PROPERTIES LINKER_LANGUAGE C) + +install(TARGETS dlt-example1 + RUNTIME DESTINATION bin + COMPONENT base) diff --git a/examples/example1/example1.c b/examples/example1/example1.c new file mode 100644 index 0000000..4c812dd --- /dev/null +++ b/examples/example1/example1.c @@ -0,0 +1,64 @@ +/** + * @licence app begin@ + * Copyright (C) 2014 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-example-user.c + * For further information see http://www.genivi.org/. + * @licence end@ + */ + + +/******************************************************************************* +** ** +** SRC-MODULE: example1.c ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** +** ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ + +#include /* for printf() and fprintf() */ +#include /* for atoi() and exit() */ + +#include + +DLT_DECLARE_CONTEXT(con_exa1); + +int main() +{ + DLT_REGISTER_APP("EXA1","First Example"); + + DLT_REGISTER_CONTEXT(con_exa1,"CON","First context"); + + DLT_LOG(con_exa1,DLT_LOG_INFO,DLT_STRING("Hello world!")); + + usleep(1000); + + DLT_UNREGISTER_CONTEXT(con_exa1); + + DLT_UNREGISTER_APP(); +} diff --git a/examples/example2/CMakeLists.txt b/examples/example2/CMakeLists.txt new file mode 100755 index 0000000..65efbce --- /dev/null +++ b/examples/example2/CMakeLists.txt @@ -0,0 +1,56 @@ +####### +# Dlt - Diagnostic Log and Trace +# @licence make begin@ +# +# Copyright (C) 2011-2014, BMW AG - Alexander Wenzel +# +# Contributions are licensed to the GENIVI Alliance under one or more +# Contribution License Agreements. +# +# 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/. +# +# @licence end@ +######## + +# +# DLT example implementation +# + +cmake_minimum_required( VERSION 2.6 ) +project( automotive-dlt-example2 ) + +# +# set prefix +# + +set( CMAKE_INSTALL_PREFIX "/usr" ) + +# +# find dependency packages +# + +find_package(PkgConfig) +pkg_check_modules(DLT REQUIRED automotive-dlt) + +# +# include directories +# + +include_directories( + ${DLT_INCLUDE_DIRS} +) + +# +# build project +# + +set(dlt_example2_SRCS example2.c) +add_executable(dlt-example2 ${dlt_example2_SRCS}) +target_link_libraries(dlt-example2 ${DLT_LIBRARIES}) +set_target_properties(dlt-example2 PROPERTIES LINKER_LANGUAGE C) + +install(TARGETS dlt-example2 + RUNTIME DESTINATION bin + COMPONENT base) diff --git a/examples/example2/dlt_id.h b/examples/example2/dlt_id.h new file mode 100644 index 0000000..e5d1dbc --- /dev/null +++ b/examples/example2/dlt_id.h @@ -0,0 +1,10 @@ +// generated file, do not edit + +#ifndef DLT_ID_H +#define DLT_ID_H + +#define DLT_EXA2_CON_EXA2_ID1 1000 +#define DLT_EXA2_CON_EXA2_ID2 1001 +#define DLT_EXA2_CON_EXA2_ID3 1002 + +#endif /* DLT_ID_H */ diff --git a/examples/example2/example2.c b/examples/example2/example2.c new file mode 100644 index 0000000..7daa9a9 --- /dev/null +++ b/examples/example2/example2.c @@ -0,0 +1,73 @@ +/** + * @licence app begin@ + * Copyright (C) 2014 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-example-user.c + * For further information see http://www.genivi.org/. + * @licence end@ + */ + + +/******************************************************************************* +** ** +** SRC-MODULE: example2.c ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** +** ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ + +#include /* for printf() and fprintf() */ +#include /* for atoi() and exit() */ + +#include + +#include "dlt_id.h" + +DLT_DECLARE_CONTEXT(con_exa2); + +int main() +{ + int num; + + DLT_REGISTER_APP("EXA2","Third Example"); + DLT_REGISTER_CONTEXT(con_exa2,"CON","First context"); + + DLT_NONVERBOSE_MODE(); + + for(num=0;num<10;num++) + { + DLT_LOG_ID(con_exa2,DLT_LOG_INFO,DLT_EXA2_CON_EXA2_ID1,DLT_INT32(12345678),DLT_STRING("Hello world 1!")); + DLT_LOG_ID(con_exa2,DLT_LOG_ERROR,DLT_EXA2_CON_EXA2_ID2,DLT_INT32(87654321),DLT_STRING("Hello world 2!")); + DLT_LOG_ID(con_exa2,DLT_LOG_WARN,DLT_EXA2_CON_EXA2_ID3,DLT_INT32(11223344),DLT_STRING("Hello world 3!")); + usleep(1000); + } + + DLT_UNREGISTER_CONTEXT(con_exa2); + + DLT_UNREGISTER_APP(); +} diff --git a/examples/example2/example2.xml b/examples/example2/example2.xml new file mode 100644 index 0000000..4a6b15c --- /dev/null +++ b/examples/example2/example2.xml @@ -0,0 +1,167 @@ + + + + projectEntry + + + + + Entry + + unknown + + + EXA2 + Third Example + + + CON + First context + + + + + + + + + + PDU_1000_0 + 4 + OTHER + + + 0 + + + + + + PDU_1000_1 + 0 + OTHER + + + 0 + + + + + + PDU_1001_0 + 4 + OTHER + + + 0 + + + + + + PDU_1001_1 + 0 + OTHER + + + 0 + + + + + + PDU_1002_0 + 4 + OTHER + + + 0 + + + + + + PDU_1002_1 + 0 + OTHER + + + 0 + + + + + + + + ID_1000 + 4 + OTHER + + + + 0 + + + + 1 + + + + DLT_TYPE_LOG + DLT_LOG_INFO + EXA2 + CON + /home/alex/workspace/ascgit/dlt-daemon/examples/example2/example2.c + 64 + + + + ID_1001 + 4 + OTHER + + + + 0 + + + + 1 + + + + DLT_TYPE_LOG + DLT_LOG_ERROR + EXA2 + CON + /home/alex/workspace/ascgit/dlt-daemon/examples/example2/example2.c + 65 + + + + ID_1002 + 4 + OTHER + + + + 0 + + + + 1 + + + + DLT_TYPE_LOG + DLT_LOG_WARN + EXA2 + CON + /home/alex/workspace/ascgit/dlt-daemon/examples/example2/example2.c + 66 + + + + + diff --git a/examples/example3/CMakeLists.txt b/examples/example3/CMakeLists.txt new file mode 100755 index 0000000..52c4f8a --- /dev/null +++ b/examples/example3/CMakeLists.txt @@ -0,0 +1,56 @@ +####### +# Dlt - Diagnostic Log and Trace +# @licence make begin@ +# +# Copyright (C) 2011-2014, BMW AG - Alexander Wenzel +# +# Contributions are licensed to the GENIVI Alliance under one or more +# Contribution License Agreements. +# +# 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/. +# +# @licence end@ +######## + +# +# DLT example implementation +# + +cmake_minimum_required( VERSION 2.6 ) +project( automotive-dlt-example3 ) + +# +# set prefix +# + +set( CMAKE_INSTALL_PREFIX "/usr" ) + +# +# find dependency packages +# + +find_package(PkgConfig) +pkg_check_modules(DLT REQUIRED automotive-dlt) + +# +# include directories +# + +include_directories( + ${DLT_INCLUDE_DIRS} +) + +# +# build project +# + +set(dlt_example3_SRCS example3.c) +add_executable(dlt-example3 ${dlt_example3_SRCS}) +target_link_libraries(dlt-example3 ${DLT_LIBRARIES}) +set_target_properties(dlt-example3 PROPERTIES LINKER_LANGUAGE C) + +install(TARGETS dlt-example3 + RUNTIME DESTINATION bin + COMPONENT base) diff --git a/examples/example3/dlt_id.h b/examples/example3/dlt_id.h new file mode 100644 index 0000000..844de3c --- /dev/null +++ b/examples/example3/dlt_id.h @@ -0,0 +1,10 @@ +// generated file, do not edit + +#ifndef DLT_ID_H +#define DLT_ID_H + +#define DLT_EXA3_CON_EXA3_ID1 1000 +#define DLT_EXA3_CON_EXA3_ID2 1001 +#define DLT_EXA3_CON_EXA3_ID3 1002 + +#endif /* DLT_ID_H */ diff --git a/examples/example3/example3.c b/examples/example3/example3.c new file mode 100644 index 0000000..bd72671 --- /dev/null +++ b/examples/example3/example3.c @@ -0,0 +1,73 @@ +/** + * @licence app begin@ + * Copyright (C) 2014 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-example-user.c + * For further information see http://www.genivi.org/. + * @licence end@ + */ + + +/******************************************************************************* +** ** +** SRC-MODULE: example3.c ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** +** ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ + +#include /* for printf() and fprintf() */ +#include /* for atoi() and exit() */ + +#include + +#include "dlt_id.h" + +DLT_DECLARE_CONTEXT(con_exa3); + +int main() +{ + int num; + + DLT_REGISTER_APP("EXA3","Third Example"); + DLT_REGISTER_CONTEXT(con_exa3,"CON","First context"); + + DLT_NONVERBOSE_MODE(); + + for(num=0;num<10;num++) + { + DLT_LOG_ID(con_exa3,DLT_LOG_INFO,DLT_EXA3_CON_EXA3_ID1,DLT_INT32(12345678),DLT_STRING("Hello world 1!")); + DLT_LOG_ID(con_exa3,DLT_LOG_ERROR,DLT_EXA3_CON_EXA3_ID2,DLT_INT32(87654321),DLT_STRING("Hello world 2!")); + DLT_LOG_ID(con_exa3,DLT_LOG_WARN,DLT_EXA3_CON_EXA3_ID3,DLT_INT32(11223344),DLT_STRING("Hello world 3!")); + usleep(1000); + } + + DLT_UNREGISTER_CONTEXT(con_exa3); + + DLT_UNREGISTER_APP(); +} diff --git a/examples/example3/example3.xml b/examples/example3/example3.xml new file mode 100644 index 0000000..706c0b5 --- /dev/null +++ b/examples/example3/example3.xml @@ -0,0 +1,167 @@ + + + + projectEntry + + + + + Entry + + unknown + + + EXA3 + Third Example + + + CON + First context + + + + + + + + + + PDU_1000_0 + 4 + OTHER + + + 0 + + + + + + PDU_1000_1 + 0 + OTHER + + + 0 + + + + + + PDU_1001_0 + 4 + OTHER + + + 0 + + + + + + PDU_1001_1 + 0 + OTHER + + + 0 + + + + + + PDU_1002_0 + 4 + OTHER + + + 0 + + + + + + PDU_1002_1 + 0 + OTHER + + + 0 + + + + + + + + ID_1000 + 4 + OTHER + + + + 0 + + + + 1 + + + + DLT_TYPE_LOG + DLT_LOG_INFO + EXA3 + CON + /home/alex/workspace/ascgit/dlt-daemon/examples/example3/example3.c + 64 + + + + ID_1001 + 4 + OTHER + + + + 0 + + + + 1 + + + + DLT_TYPE_LOG + DLT_LOG_ERROR + EXA3 + CON + /home/alex/workspace/ascgit/dlt-daemon/examples/example3/example3.c + 65 + + + + ID_1002 + 4 + OTHER + + + + 0 + + + + 1 + + + + DLT_TYPE_LOG + DLT_LOG_WARN + EXA3 + CON + /home/alex/workspace/ascgit/dlt-daemon/examples/example3/example3.c + 66 + + + + + -- cgit v1.2.1