From eed439a67a26f79f524bdad7e53516917f0b657e Mon Sep 17 00:00:00 2001 From: Frank Herchet Date: Fri, 24 Feb 2012 11:11:56 +0100 Subject: * [GAM-11]: modify cmake and add compile flag WITH_DLT --- AudioManagerDaemon/CMakeLists.txt | 52 +++++++++++++++++++++++++++++---------- CMakeLists.txt | 10 ++++++-- cmake/config.cmake | 1 + 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/AudioManagerDaemon/CMakeLists.txt b/AudioManagerDaemon/CMakeLists.txt index 8e5297c..beb1a74 100644 --- a/AudioManagerDaemon/CMakeLists.txt +++ b/AudioManagerDaemon/CMakeLists.txt @@ -70,12 +70,17 @@ ENDIF(WITH_SOCKETHANDLER_LOOP) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${DLT_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} ${AUDIO_INCLUDES_FOLDER} ${INCLUDES_FOLDER} ) +IF(WITH_DLT) +INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} + ${DLT_INCLUDE_DIRS} +) +ENDIF(WITH_DLT) + IF(WITH_DBUS_WRAPPER) INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${DBUS_ARCH_INCLUDE_DIR} @@ -86,18 +91,22 @@ ENDIF(WITH_DBUS_WRAPPER) ADD_EXECUTABLE(AudioManager ${AUDIOMAN_SRCS_CXX}) IF(WITH_DBUS_WRAPPER) -TARGET_LINK_LIBRARIES(AudioManager - ${SQLITE_LIBRARIES} - ${DLT_LIBRARIES} - ${DBUS_LIBRARY} -) + TARGET_LINK_LIBRARIES(AudioManager + ${SQLITE_LIBRARIES} + ${DBUS_LIBRARY} + ) ELSE(WITH_DBUS_WRAPPER) TARGET_LINK_LIBRARIES(AudioManager ${SQLITE_LIBRARIES} - ${DLT_LIBRARIES} -) + ) ENDIF(WITH_DBUS_WRAPPER) +IF(WITH_DLT) + TARGET_LINK_LIBRARIES(AudioManager + ${DLT_LIBRARIES} + ) +ENDIF(WITH_DLT) + IF(WITH_TESTS) add_subdirectory (test) ENDIF(WITH_TESTS) @@ -123,9 +132,26 @@ INSTALL(DIRECTORY "${AUDIO_INCLUDES_FOLDER}/" COMPONENT dev ) -SET(ADD_DEPEND "sqlite3(>=3.6.22)" "dlt" "libdbus-1-3(>=1.2.16)") -set_property(GLOBAL APPEND PROPERTY bin_prop "${ADD_DEPEND}") +# General packet dependency +SET(ADD_DEPEND_BIN_PROP "sqlite3(>=3.6.22)") + +# Optional packet dependency +IF(WITH_DLT) + SET(ADD_DEPEND_BIN_PROP ${ADD_DEPEND_BIN_PROP} "dlt") +ENDIF(WITH_DLT) + +IF(WITH_DBUS_WRAPPER) + SET(ADD_DEPEND_BIN_PROP ${ADD_DEPEND_BIN_PROP} "libdbus-1-3(>=1.2.16)") +ENDIF() + +# Additional Dev packet dependency +SET(ADD_DEPEND_DEV_PROP "audiomanager-bin" ${ADD_DEPEND_BIN_PROP}) + +MESSAGE(STATUS "bin packet dependency: ${ADD_DEPEND_BIN_PROP}") +MESSAGE(STATUS "dev dependency: ${ADD_DEPEND_DEV_PROP}") + +set_property(GLOBAL APPEND PROPERTY bin_prop "${ADD_DEPEND_BIN_PROP}") +set_property(GLOBAL APPEND PROPERTY dev_prop "${ADD_DEPEND_DEV_PROP}") + -SET(ADD_DEPEND "audiomanager-bin" "sqlite3(>=3.6.22)" "dlt" "libdbus-1-3(>=1.2.16)") -set_property(GLOBAL APPEND PROPERTY dev_prop "${ADD_DEPEND}") diff --git a/CMakeLists.txt b/CMakeLists.txt index d33ca05..2ba0790 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,8 +46,13 @@ execute_process(COMMAND git log --pretty=short WORKING_DIRECTORY ${CMAKE_CURRENT PROJECT(AudioManagerDeamon) +FIND_PACKAGE(PkgConfig) + OPTION( WITH_DBUS_WRAPPER "Enable Dbus Wrapper Support" ON ) + +OPTION( WITH_DLT + "Enable automotive-DLT Support" ON ) OPTION( WITH_SOCKETHANDLER_LOOP "Enable SocketHandler Support (cannot work with SimpleDBusLoop)" ON ) @@ -128,8 +133,9 @@ SET(INTROSPECTION_COMMAND_XML_FILE "${AUDIO_INCLUDES_FOLDER}/dbus/CommandInterfa CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.cmake ${CMAKE_SOURCE_DIR}/includes/config.h ) -FIND_PACKAGE(PkgConfig) -pkg_check_modules(DLT REQUIRED automotive-dlt) +IF(WITH_DLT) + pkg_check_modules(DLT REQUIRED automotive-dlt) +ENDIF(WITH_DLT) IF(WITH_DOCUMENTATION) find_package(Doxygen) diff --git a/cmake/config.cmake b/cmake/config.cmake index c753c32..f5db584 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -4,6 +4,7 @@ #cmakedefine DAEMONVERSION "@DAEMONVERSION@" #cmakedefine WITH_DBUS_WRAPPER +#cmakedefine WITH_DLT #cmakedefine WITH_SOCKETHANDLER_LOOP #cmakedefine WITH_SIMPLEDBUS_LOOP #cmakedefine WITH_PPOLL -- cgit v1.2.1 From c05c98fe354cfa8172deb1daff0f0240a740a552 Mon Sep 17 00:00:00 2001 From: Frank Herchet Date: Fri, 24 Feb 2012 13:29:02 +0100 Subject: * [GAM-11] make project compilable without DLT --- AudioManagerDaemon/src/DLTWrapper.cpp | 30 ++++++++++++++++++ includes/DLTWrapper.h | 57 +++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/AudioManagerDaemon/src/DLTWrapper.cpp b/AudioManagerDaemon/src/DLTWrapper.cpp index 33a48e8..a5b51ac 100644 --- a/AudioManagerDaemon/src/DLTWrapper.cpp +++ b/AudioManagerDaemon/src/DLTWrapper.cpp @@ -22,6 +22,7 @@ * */ + #include "DLTWrapper.h" #include @@ -36,7 +37,9 @@ DLTWrapper *DLTWrapper::instance() void DLTWrapper::unregisterContext(DltContext & handle) { +#ifdef WITH_DLT dlt_unregister_context(&handle); +#endif } DLTWrapper::DLTWrapper() : @@ -47,71 +50,98 @@ DLTWrapper::DLTWrapper() : void DLTWrapper::registerApp(const char *appid, const char *description) { +#ifdef WITH_DLT dlt_register_app(appid, description); //register a default context dlt_register_context(&mDltContext, "def", "default Context registered by DLTWrapper CLass"); +#endif } void DLTWrapper::registerContext(DltContext& handle, const char *contextid, const char *description) { +#ifdef WITH_DLT dlt_register_context(&handle, contextid, description); +#endif } void DLTWrapper::init(DltLogLevelType loglevel, DltContext* context) { if (!context) context = &mDltContext; +#ifdef WITH_DLT dlt_user_log_write_start(context, &mDltContextData, loglevel); +#endif + } void DLTWrapper::send() { +#ifdef WITH_DLT dlt_user_log_write_finish(&mDltContextData); +#endif } void DLTWrapper::append(const int8_t value) { +#ifdef WITH_DLT dlt_user_log_write_int8(&mDltContextData, value); +#endif } void DLTWrapper::append(const uint8_t value) { +#ifdef WITH_DLT dlt_user_log_write_uint8(&mDltContextData, value); +#endif } void DLTWrapper::append(const int16_t value) { +#ifdef WITH_DLT dlt_user_log_write_int16(&mDltContextData, value); +#endif } void DLTWrapper::append(const uint16_t value) { +#ifdef WITH_DLT dlt_user_log_write_uint16(&mDltContextData, value); +#endif } void DLTWrapper::append(const int32_t value) { +#ifdef WITH_DLT dlt_user_log_write_int32(&mDltContextData, value); +#endif } void DLTWrapper::append(const uint32_t value) { +#ifdef WITH_DLT dlt_user_log_write_uint32(&mDltContextData, value); +#endif } void DLTWrapper::append(const char*& value) { +#ifdef WITH_DLT dlt_user_log_write_string(&mDltContextData, value); +#endif } void DLTWrapper::append(const std::string& value) { +#ifdef WITH_DLT dlt_user_log_write_string(&mDltContextData, value.c_str()); +#endif } void DLTWrapper::append(const bool value) { +#ifdef WITH_DLT dlt_user_log_write_bool(&mDltContextData, static_cast(value)); +#endif } DLTWrapper::~DLTWrapper() diff --git a/includes/DLTWrapper.h b/includes/DLTWrapper.h index dcce4ab..7d72836 100644 --- a/includes/DLTWrapper.h +++ b/includes/DLTWrapper.h @@ -25,7 +25,64 @@ #ifndef DLTWRAPPER_H_ #define DLTWRAPPER_H_ +#include "config.h" + +#ifdef WITH_DLT #include +#else + +#include + +#define DLT_USER_BUF_MAX_SIZE 2048 + +/** + * This structure is used for every context used in an application. + */ +typedef struct +{ + char contextID[4]; /**< context id */ + int32_t log_level_pos; /**< offset in user-application context field */ +} DltContext; + +/** + * Definitions of DLT log level + */ +typedef enum +{ + DLT_LOG_DEFAULT = -1, /**< Default log level */ + DLT_LOG_OFF = 0x00, /**< Log level off */ + DLT_LOG_FATAL = 0x01, /**< fatal system error */ + DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */ + DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */ + DLT_LOG_INFO = 0x04, /**< informational */ + DLT_LOG_DEBUG = 0x05, /**< debug */ + DLT_LOG_VERBOSE = 0x06 /**< highest grade of information */ +} DltLogLevelType; + +/** + * This structure is used for context data used in an application. + */ +typedef struct +{ + DltContext *handle; /**< pointer to DltContext */ + unsigned char buffer[DLT_USER_BUF_MAX_SIZE]; /**< buffer for building log message*/ + int32_t size; /**< payload size */ + int32_t log_level; /**< log level */ + int32_t trace_status; /**< trace status */ + int32_t args_num; /**< number of arguments for extended header*/ + uint8_t mcnt; /**< message counter */ + char* context_description; /**< description of context */ +} DltContextData; + +#define DLT_DECLARE_CONTEXT(CONTEXT) \ +DltContext CONTEXT; + + +#define DLT_IMPORT_CONTEXT(CONTEXT) \ +extern DltContext CONTEXT; + +#endif + #include class DLTWrapper -- cgit v1.2.1 From 7abe8302898461aaa342224de2d00ce1c80eb8c2 Mon Sep 17 00:00:00 2001 From: Frank Herchet Date: Tue, 28 Feb 2012 15:45:50 +0100 Subject: * [GAM-11] remove dependency from DLT in DLTWrapper if WITH_DLT is undefined * [GAM-11] add some structs and enums to be compatible to DLT-interface --- AudioManagerDaemon/src/DLTWrapper.cpp | 68 ++++++++++++++++++++++++++++++++--- includes/DLTWrapper.h | 13 +++++-- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/AudioManagerDaemon/src/DLTWrapper.cpp b/AudioManagerDaemon/src/DLTWrapper.cpp index a5b51ac..cdb1a1e 100644 --- a/AudioManagerDaemon/src/DLTWrapper.cpp +++ b/AudioManagerDaemon/src/DLTWrapper.cpp @@ -24,14 +24,18 @@ #include "DLTWrapper.h" -#include +#include +#include +#include DLTWrapper* DLTWrapper::mDLTWrapper = NULL; -DLTWrapper *DLTWrapper::instance() +DLTWrapper *DLTWrapper::instance(const bool enableNoDLTDebug) { if (!mDLTWrapper) - mDLTWrapper = new DLTWrapper; + mDLTWrapper = new DLTWrapper(enableNoDLTDebug); + if(enableNoDLTDebug) + mDLTWrapper->enableNoDLTDebug(true); return mDLTWrapper; } @@ -42,10 +46,16 @@ void DLTWrapper::unregisterContext(DltContext & handle) #endif } -DLTWrapper::DLTWrapper() : +DLTWrapper::DLTWrapper(const bool enableNoDLTDebug) : +#ifndef WITH_DLT + mEnableNoDLTDebug(enableNoDLTDebug), +#endif mDltContext(), // mDltContextData() { +#ifndef WITH_DLT + std::cout << "[DLT] Running without DLT-support" << std::endl; +#endif } void DLTWrapper::registerApp(const char *appid, const char *description) @@ -61,6 +71,15 @@ void DLTWrapper::registerContext(DltContext& handle, const char *contextid, cons { #ifdef WITH_DLT dlt_register_context(&handle, contextid, description); +#else + memcpy(&mDltContext.contextID,contextid,4); + strlen(description); + const size_t str_len = strlen(description); + if(str_len < 2000) + { + mDltContextData.context_description = new char[str_len + 1]; + (void) strcpy(mDltContextData.context_description,description); + } #endif } @@ -78,6 +97,11 @@ void DLTWrapper::send() { #ifdef WITH_DLT dlt_user_log_write_finish(&mDltContextData); +#else + if(mEnableNoDLTDebug) + std::cout << "[" << mDltContext.contextID << "] " << std::string(mDltContextData.buffer) << std::endl; + + mDltContextData.size = 0; #endif } @@ -85,6 +109,8 @@ void DLTWrapper::append(const int8_t value) { #ifdef WITH_DLT dlt_user_log_write_int8(&mDltContextData, value); +#else + appendNoDLT(value); #endif } @@ -92,6 +118,8 @@ void DLTWrapper::append(const uint8_t value) { #ifdef WITH_DLT dlt_user_log_write_uint8(&mDltContextData, value); +#else + appendNoDLT(value); #endif } @@ -99,6 +127,8 @@ void DLTWrapper::append(const int16_t value) { #ifdef WITH_DLT dlt_user_log_write_int16(&mDltContextData, value); +#else + appendNoDLT(value); #endif } @@ -106,6 +136,8 @@ void DLTWrapper::append(const uint16_t value) { #ifdef WITH_DLT dlt_user_log_write_uint16(&mDltContextData, value); +#else + appendNoDLT(value); #endif } @@ -113,6 +145,8 @@ void DLTWrapper::append(const int32_t value) { #ifdef WITH_DLT dlt_user_log_write_int32(&mDltContextData, value); +#else + appendNoDLT(value); #endif } @@ -120,6 +154,8 @@ void DLTWrapper::append(const uint32_t value) { #ifdef WITH_DLT dlt_user_log_write_uint32(&mDltContextData, value); +#else + appendNoDLT(value); #endif } @@ -127,6 +163,9 @@ void DLTWrapper::append(const char*& value) { #ifdef WITH_DLT dlt_user_log_write_string(&mDltContextData, value); +#else + memcpy((mDltContextData.buffer+mDltContextData.size),value,strlen(value)); + mDltContextData.size += strlen(value); #endif } @@ -134,6 +173,9 @@ void DLTWrapper::append(const std::string& value) { #ifdef WITH_DLT dlt_user_log_write_string(&mDltContextData, value.c_str()); +#else + memcpy((mDltContextData.buffer+mDltContextData.size),value.c_str(),value.size()); + mDltContextData.size += value.size(); #endif } @@ -141,9 +183,27 @@ void DLTWrapper::append(const bool value) { #ifdef WITH_DLT dlt_user_log_write_bool(&mDltContextData, static_cast(value)); +#else + appendNoDLT(value); #endif } +#ifndef WITH_DLT +template void DLTWrapper::appendNoDLT(T value) +{ + if((mDltContextData.size + sizeof(value)) < DLT_USER_BUF_MAX_SIZE) + { + memcpy((mDltContextData.buffer+mDltContextData.size),&(value),sizeof(value)); + mDltContextData.size += sizeof(value); + } +} + +void DLTWrapper::enableNoDLTDebug(const bool enableNoDLTDebug) +{ + mEnableNoDLTDebug = enableNoDLTDebug; +} +#endif + DLTWrapper::~DLTWrapper() { if (mDLTWrapper) diff --git a/includes/DLTWrapper.h b/includes/DLTWrapper.h index 7d72836..3a9482a 100644 --- a/includes/DLTWrapper.h +++ b/includes/DLTWrapper.h @@ -65,7 +65,7 @@ typedef enum typedef struct { DltContext *handle; /**< pointer to DltContext */ - unsigned char buffer[DLT_USER_BUF_MAX_SIZE]; /**< buffer for building log message*/ + char buffer[DLT_USER_BUF_MAX_SIZE]; /**< buffer for building log message*/ int32_t size; /**< payload size */ int32_t log_level; /**< log level */ int32_t trace_status; /**< trace status */ @@ -88,7 +88,7 @@ extern DltContext CONTEXT; class DLTWrapper { public: - static DLTWrapper* instance(); + static DLTWrapper* instance(const bool enableNoDLTDebug = false); void registerApp(const char *appid, const char * description); void registerContext(DltContext& handle, const char *contextid, const char * description); void unregisterContext(DltContext& handle); @@ -103,9 +103,16 @@ public: void append(const char*& value); void append(const std::string& value); void append(const bool value); +#ifndef WITH_DLT + void enableNoDLTDebug(const bool enableNoDLTDebug = true); +#endif ~DLTWrapper(); private: - DLTWrapper(); //is private because of singleton pattern + DLTWrapper(const bool enableNoDLTDebug); //is private because of singleton pattern +#ifndef WITH_DLT + template void appendNoDLT(T value); + bool mEnableNoDLTDebug; +#endif DltContext mDltContext; DltContextData mDltContextData; static DLTWrapper* mDLTWrapper; -- cgit v1.2.1 From 70c815798674609aee710a29667293c1f49a0df3 Mon Sep 17 00:00:00 2001 From: Frank Herchet Date: Wed, 29 Feb 2012 09:59:38 +0100 Subject: * fix compile error in DLTWrapper.cpp --- AudioManagerDaemon/src/DLTWrapper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AudioManagerDaemon/src/DLTWrapper.cpp b/AudioManagerDaemon/src/DLTWrapper.cpp index cdb1a1e..ad03692 100644 --- a/AudioManagerDaemon/src/DLTWrapper.cpp +++ b/AudioManagerDaemon/src/DLTWrapper.cpp @@ -34,8 +34,10 @@ DLTWrapper *DLTWrapper::instance(const bool enableNoDLTDebug) { if (!mDLTWrapper) mDLTWrapper = new DLTWrapper(enableNoDLTDebug); +#ifndef WITH_DLT if(enableNoDLTDebug) mDLTWrapper->enableNoDLTDebug(true); +#endif return mDLTWrapper; } -- cgit v1.2.1