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 ++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) (limited to 'AudioManagerDaemon') 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) -- cgit v1.2.1