summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorasanoaozora <fifitaneki@hotmail.com>2017-06-08 13:58:58 +0200
committerasanoaozora <fifitaneki@hotmail.com>2017-06-08 13:58:58 +0200
commit3d9f1eed3df79c19b5b1ed0dc14697575be945fa (patch)
treed192559e657bf02e457372d4cbb95552e3a1ada8 /src
parent5420be5d3ac3de46962677536b1a26c0c29c1074 (diff)
downloadpoi-service-3d9f1eed3df79c19b5b1ed0dc14697575be945fa.tar.gz
extend test for mapviewer and add a signal for debugging
Diffstat (limited to 'src')
-rwxr-xr-xsrc/navigation/build.sh4
-rw-r--r--src/navigation/map-viewer/mapviewercontrol-plugin/CMakeLists.txt2
-rw-r--r--src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx64
-rw-r--r--src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx64
-rw-r--r--src/navigation/navigation-common/log.h154
5 files changed, 240 insertions, 48 deletions
diff --git a/src/navigation/build.sh b/src/navigation/build.sh
index 23d5ec5..d5d3873 100755
--- a/src/navigation/build.sh
+++ b/src/navigation/build.sh
@@ -103,6 +103,10 @@ else
fi
cd ../
echo 'build navigation'
+if [ "$capi" = 1 ]
+then
+ echo 'delete <selective> option because DBus does not manage it'
+fi
if [ "$clean" = 1 ]
then
cmake $dlt_option $commonapi_tools_option ../
diff --git a/src/navigation/map-viewer/mapviewercontrol-plugin/CMakeLists.txt b/src/navigation/map-viewer/mapviewercontrol-plugin/CMakeLists.txt
index 2b83ce0..9165e80 100644
--- a/src/navigation/map-viewer/mapviewercontrol-plugin/CMakeLists.txt
+++ b/src/navigation/map-viewer/mapviewercontrol-plugin/CMakeLists.txt
@@ -51,4 +51,4 @@ set(genivi_mapviewer_mapviewercontrol_LIBRARY_DIRS ${PLUGIN_LIBRARIES})
module_add_library(genivi_mapviewer_mapviewercontrol genivi_mapviewer_mapviewercontrol.cxx ${DBUS_GENERATED_INCLUDE_DIR}/map-viewer/genivi-mapviewer-mapviewercontrol_adaptor.h ${DBUS_GENERATED_INCLUDE_DIR}/navigation-core/genivi-navigationcore-routing_proxy.h ${DBUS_GENERATED_INCLUDE_DIR}/navigation-core/genivi-navigationcore-session_proxy.h ${DBUS_GENERATED_INCLUDE_DIR}/navigation-core/genivi-navigationcore-mapmatchedposition_proxy.h)
add_dependencies(genivi_mapviewer_mapviewercontrol ${API_DIR}/map-viewer)
-
+target_link_libraries(genivi_mapviewer_mapviewercontrol ${LIBRARIES})
diff --git a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx
index 6093567..cd73751 100644
--- a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx
+++ b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx
@@ -66,6 +66,10 @@
#include "navigation-common-dbus.h"
+#include "log.h"
+
+DLT_DECLARE_CONTEXT(gCtx);
+
#if (!DEBUG_ENABLED)
#undef dbg
#define dbg(level,...) ;
@@ -138,8 +142,8 @@ class MapViewerControlObj
void MoveMap(void);
void SetFollowCarMode(uint32_t SessionHandle, bool active);
void GetFollowCarMode(bool& active);
- void SetCameraHeadingAngle(uint32_t sessionHandle, double angle);
- void GetCameraHeadingAngle(double &angle);
+ void SetCameraHeadingAngle(uint32_t sessionHandle, int32_t angle);
+ void GetCameraHeading(DBusCommonAPIEnumeration& headingType, int32_t& headingAngle, ::DBus::Struct< double, double >& target);
void SetCameraTiltAngle(uint32_t sessionHandle, double angle);
void GetCameraTiltAngle(double &angle);
void SetCameraRollAngle(uint32_t sessionHandle, double angle);
@@ -189,7 +193,8 @@ class Routing
: DBus::ObjectProxy(connection, "/org/genivi/navigationcore","org.genivi.navigation.navigationcore.Routing")
{
m_mapviewerobj=obj;
- }
+ LOG_INFO_MSG(gCtx,"routing client");
+ }
void RouteDeleted(const uint32_t& routeHandle)
@@ -243,7 +248,8 @@ class NavigationCoreSession
NavigationCoreSession(DBus::Connection &connection)
: DBus::ObjectProxy(connection, "/org/genivi/navigationcore","org.genivi.navigation.navigationcore.Session")
{
- }
+ LOG_INFO_MSG(gCtx,"session client");
+ }
void SessionDeleted(const uint32_t& sessionHandle)
{
}
@@ -262,7 +268,8 @@ class MapMatchedPosition
: DBus::ObjectProxy(connection, "/org/genivi/navigationcore","org.genivi.navigation.navigationcore.MapMatchedPosition")
{
cb=callback_new_2(callback_cast(position_update), this, v);
- }
+ LOG_INFO_MSG(gCtx,"map matched position client");
+ }
void PositionUpdate(const std::vector< DBusCommonAPIEnumeration >& changedValues)
{
@@ -344,7 +351,8 @@ class MapViewerControl
MapViewerControl(DBus::Connection &connection)
: DBus::ObjectAdaptor(connection, "/org/genivi/mapviewer")
{
- }
+ LOG_INFO_MSG(gCtx,"map viewer control server");
+ }
void
CreateMapViewInstance(const uint32_t& sessionHandle, const ::DBus::Struct< uint16_t, uint16_t >& mapViewSize, const DBusCommonAPIEnumeration& mapViewType, int32_t& error, uint32_t& mapViewInstanceHandle)
@@ -386,9 +394,12 @@ class MapViewerControl
SetMapViewPerspective(const uint32_t& sessionHandle, const uint32_t& mapViewInstanceHandle, const DBusCommonAPIEnumeration& perspective)
{
MapViewerControlObj *obj=handles[mapViewInstanceHandle];
- if (!obj)
- throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle");
- else obj->SetMapViewPerspective(sessionHandle, perspective);
+ if (!obj)
+ throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle");
+ else{
+ obj->SetMapViewPerspective(sessionHandle, perspective);
+ MapViewPerspectiveChanged(mapViewInstanceHandle,perspective);
+ }
}
DBusCommonAPIEnumeration
@@ -417,8 +428,10 @@ class MapViewerControl
throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle");
else {
obj->SetMapViewScale(SessionHandle, ScaleID);
- //todo: manage the isminmax indicator
- MapViewScaleChanged(MapViewInstanceHandle,ScaleID,GENIVI_MAPVIEWER_INVALID);
+ uint8_t current_scale;
+ DBusCommonAPIEnumeration is_min_max;
+ obj->GetMapViewScale(current_scale,is_min_max);
+ MapViewScaleChanged(MapViewInstanceHandle,current_scale,is_min_max);
}
}
@@ -723,7 +736,10 @@ class MapViewerControl
MapViewerControlObj *obj=handles[mapViewInstanceHandle];
if (!obj)
throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle");
- else obj->SetMapViewRotation(sessionHandle, rotationAngle, rotationAnglePerSecond);
+ else {
+ obj->SetMapViewRotation(sessionHandle, rotationAngle, rotationAnglePerSecond);
+ MapViewRotated(mapViewInstanceHandle);
+ }
}
void
@@ -848,7 +864,7 @@ class MapViewerControl
MapViewerControlObj *obj=handles[mapViewInstanceHandle];
if (!obj)
throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle");
- else obj->SetCameraHeadingTrackUp(sessionHandle);
+ else obj->SetCameraHeadingTrackUp(sessionHandle);
}
void
@@ -866,8 +882,11 @@ class MapViewerControl
void
GetCameraHeading(const uint32_t& mapViewInstanceHandle, DBusCommonAPIEnumeration& headingType, int32_t& headingAngle, ::DBus::Struct< double, double >& target)
{
- throw DBus::ErrorNotSupported("Not yet supported");
- }
+ MapViewerControlObj *obj=handles[mapViewInstanceHandle];
+ if (!obj)
+ throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle");
+ else obj->GetCameraHeading(headingType,headingAngle,target);
+ }
std::vector< uint32_t >
DisplayCustomElements(const uint32_t& sessionHandle, const uint32_t& mapViewInstanceHandle, const std::vector< ::DBus::Struct< std::string, std::string, ::DBus::Struct< double, double >, ::DBus::Struct< int16_t, int16_t > > >& customElements)
@@ -1217,7 +1236,7 @@ MapViewerControlObj::GetFollowCarMode(bool& active)
}
void
-MapViewerControlObj::SetCameraHeadingAngle(uint32_t sessionHandle, double angle)
+MapViewerControlObj::SetCameraHeadingAngle(uint32_t sessionHandle, int32_t angle)
{
struct attr orientation={attr_orientation};
orientation.u.num=angle;
@@ -1226,10 +1245,13 @@ MapViewerControlObj::SetCameraHeadingAngle(uint32_t sessionHandle, double angle)
}
void
-MapViewerControlObj::GetCameraHeadingAngle(double &angle)
+MapViewerControlObj::GetCameraHeading(DBusCommonAPIEnumeration& headingType, int32_t& headingAngle, ::DBus::Struct< double, double >& target)
{
struct transformation *trans=navit_get_trans(m_navit.u.navit);
- angle=transform_get_yaw(trans);
+ headingAngle=transform_get_yaw(trans);
+ headingType=GENIVI_MAPVIEWER_INVALID;
+ target._1=0;
+ target._2=0;
}
void
@@ -1426,7 +1448,6 @@ MapViewerControlObj::SetMapViewRotation(uint32_t sessionHandle, double rotationA
m_rotationanglepersecond=rotationAnglePerSecond;
SetFollowCarMode(sessionHandle, false);
MoveMap();
-
}
void
@@ -1894,7 +1915,10 @@ static class MapViewerControl *server;
void
plugin_init(void)
{
- event_request_system("glib","genivi_mapviewercontrol");
+ DLT_REGISTER_APP("MPVS","MAP VIEWER CONTROL SERVER");
+ DLT_REGISTER_CONTEXT(gCtx,"MPVS","Global Context");
+
+ event_request_system("glib","genivi_mapviewercontrol");
int i;
for (i = 0 ; i < CONNECTION_AMOUNT ; i++) {
// init the dispatcher
diff --git a/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx b/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx
index bbacb2d..dd03d80 100644
--- a/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx
+++ b/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx
@@ -64,7 +64,6 @@
#include <MapMatchedPositionProxy.hpp>
#include <RoutingProxy.hpp>
#include <navigationcore/SessionProxy.hpp>
-
#include "log.h"
DLT_DECLARE_CONTEXT(gCtx);
@@ -120,7 +119,7 @@ class MapViewerControlObj
struct mapset *m_mapset;
uint32_t m_handle;
double m_scrolldirection, m_scrollspeed;
- double m_rotationangle, m_rotationanglepersecond;
+ double m_rotationangle, m_rotationanglepersecond;
struct callback *m_postdraw_callback;
struct callback *m_move_callback;
@@ -134,7 +133,9 @@ class MapViewerControlObj
uint16_t m_width;
uint16_t m_height;
- void MoveMap(void);
+ MapViewerControlObj(MapViewerControlServerStub *mapviewercontrol, NavigationTypes::Handle handle, const MapViewerControl::Dimension &MapViewSize);
+ ~MapViewerControlObj();
+ void MoveMap(void);
void SetFollowCarMode(NavigationTypes::Handle SessionHandle, bool active);
void GetFollowCarMode(bool& active);
void SetCameraHeadingAngle(NavigationTypes::Handle SessionHandle, double angle);
@@ -151,7 +152,7 @@ class MapViewerControlObj
void SetMapViewPerspective(NavigationTypes::Handle SessionHandle, MapViewerControl::MapPerspective MapViewPerspectiveMode);
void GetMapViewPerspective(MapViewerControl::MapPerspective &MapViewPerspectiveMode);
void GetScaleList(std::vector< MapViewerControl::MapScale >& ScalesList);
- void SetMapViewScale(NavigationTypes::Handle SessionHandle, uint32_t ScaleID);
+ void SetMapViewScale(NavigationTypes::Handle SessionHandle, uint8_t ScaleID);
void SetMapViewScaleByDelta(NavigationTypes::Handle SessionHandle, int16_t ScaleDelta);
void GetMapViewScale(uint8_t& ScaleID, MapViewerControl::MapScaleType &IsMinMax);
void GetMapViewType(MapViewerControl::MapViewType &MapViewType);
@@ -170,8 +171,6 @@ class MapViewerControlObj
void HideRoute(NavigationTypes::Handle SessionHandle, NavigationTypes::Handle RouteHandle);
void ConvertPixelCoordsToGeoCoords(NavigationTypes::Handle SessionHandle, const std::vector<MapViewerControl::Pixel> &pixelCoordinates, std::vector<NavigationTypes::Coordinate2D> &GeoCoordinates);
void ConvertGeoCoordsToPixelCoords(NavigationTypes::Handle SessionHandle, const std::vector<NavigationTypes::Coordinate2D> &geoCoordinates, std::vector<MapViewerControl::Pixel> &pixelCoordinates);
- MapViewerControlObj(MapViewerControlServerStub *mapviewercontrol, NavigationTypes::Handle handle, const MapViewerControl::Dimension &MapViewSize);
- ~MapViewerControlObj();
};
static std::map<uint32_t, MapViewerControlObj *> mp_handles;
@@ -323,6 +322,19 @@ class NavigationCoreSessionClientProxy
}
};
+class ClientStub : public CommonAPI::ClientId
+{
+public:
+ ~ClientStub(){}
+ bool operator==(ClientId& clientIdToCompare) {
+ return true;
+ }
+
+ std::size_t hashCode() {
+ return 0;
+ }
+};
+
class MapViewerControlServerStub : public MapViewerControlStubDefault
{
public:
@@ -336,7 +348,6 @@ class MapViewerControlServerStub : public MapViewerControlStubDefault
m_version.setVersionMinor(0);
m_version.setVersionMicro(0);
m_version.setDate("21-01-2014");
-
}
/**
@@ -447,6 +458,7 @@ class MapViewerControlServerStub : public MapViewerControlStubDefault
if (!obj)
throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle");
else obj->SetFollowCarMode(_sessionHandle, _followCarMode);
+ fireFollowCarModeChangedEvent(_mapViewInstanceHandle,_followCarMode);
_reply();
}
@@ -709,17 +721,17 @@ class MapViewerControlServerStub : public MapViewerControlStubDefault
/**
* description: setMapViewScale = This method sets the map scale by specifying a ScaleID
*/
- void setMapViewScale(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, uint16_t _scaleID, setMapViewScaleReply_t _reply){
- dbg(lvl_debug,"enter\n");
+ void setMapViewScale(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, uint8_t _scaleID, setMapViewScaleReply_t _reply){
+ MapViewerControl::MapScaleType is_min_max=MapViewerControl::MapScaleType::INVALID;
MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle];
if (!obj)
throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle");
else {
- obj->SetMapViewScale(_sessionHandle, _scaleID);
- uint8_t current_scale;
- MapViewerControl::MapScaleType is_min_max;
- obj->GetMapViewScale(current_scale,is_min_max);
- fireMapViewScaleChangedSelective(_mapViewInstanceHandle,current_scale,is_min_max);
+// obj->SetMapViewScale(_sessionHandle, _scaleID);
+// obj->GetMapViewScale(_scaleID,is_min_max);
+ fireMapViewScaleChangedSelective(_mapViewInstanceHandle,_scaleID,is_min_max);
+ fireFollowCarModeChangedEvent(_mapViewInstanceHandle,false);
+
}
_reply();
}
@@ -1069,7 +1081,6 @@ class MapViewerControlServerStub : public MapViewerControlStubDefault
throw DBus::ErrorNotSupported("Not yet supported");
}
-
private:
CommonTypes::Version m_version;
@@ -1188,18 +1199,17 @@ MapViewerControlObj::GetScaleList(std::vector<MapViewerControl::MapScale> &Scale
}
void
-MapViewerControlObj::SetMapViewScale(NavigationTypes::Handle SessionHandle, uint32_t ScaleID)
+MapViewerControlObj::SetMapViewScale(NavigationTypes::Handle SessionHandle, uint8_t ScaleID)
{
long scale=1 << ScaleID;
struct transformation *trans=navit_get_trans(m_navit.u.navit);
transform_set_scale(trans, scale);
- navit_draw(m_navit.u.navit);
+ navit_draw(m_navit.u.navit);
}
void
MapViewerControlObj::SetMapViewScaleByDelta(NavigationTypes::Handle SessionHandle, int16_t ScaleDelta)
{
- LOG_INFO(gCtx,"Delta=%d",ScaleDelta);
if (ScaleDelta < 0)
navit_zoom_in(m_navit.u.navit,1 << (-ScaleDelta),NULL);
else if (ScaleDelta > 0)
@@ -1983,34 +1993,34 @@ plugin_init(void)
// init the map viewer control server
const std::string domain = "local";
- const std::string instanceMapViewerControl = "MapViewerControl";
+ const std::string instanceMapViewerControlServer = "MapViewerControl";
std::shared_ptr<MapViewerControlServerStub> myServiceMapViewerControl = std::make_shared<MapViewerControlServerStub>();
- bool successfullyRegistered = runtime->registerService(domain, instanceMapViewerControl, myServiceMapViewerControl);
+ bool successfullyRegistered = runtime->registerService(domain, instanceMapViewerControlServer, myServiceMapViewerControl);
while (!successfullyRegistered) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
- successfullyRegistered = runtime->registerService(domain, instanceMapViewerControl, myServiceMapViewerControl);
+ successfullyRegistered = runtime->registerService(domain, instanceMapViewerControlServer, myServiceMapViewerControl);
}
LOG_INFO_MSG(gCtx,"map viewer control server");
//init the session client
- const std::string instanceNavigationCoreSession = "Session";
- mp_navigationCoreSessionClientProxy = new NavigationCoreSessionClientProxy(domain,instanceNavigationCoreSession);
+ const std::string instanceNavigationCoreSessionClient = "Session";
+ mp_navigationCoreSessionClientProxy = new NavigationCoreSessionClientProxy(domain,instanceNavigationCoreSessionClient);
LOG_INFO_MSG(gCtx,"session client");
//init the routing client
- const std::string instanceRouting = "Routing";
- mp_routingClientProxy = new RoutingClientProxy(domain,instanceRouting);
+ const std::string instanceRoutingClient = "Routing";
+ mp_routingClientProxy = new RoutingClientProxy(domain,instanceRoutingClient);
mp_routingClientProxy->setListeners();
LOG_INFO_MSG(gCtx,"routing client");
// init the map matched position client
- const std::string instanceMapMatchedPosition = "MapMatchedPosition";
- mp_mapMatchedPositionClientProxy = new MapMatchedPositionClientProxy(domain,instanceMapMatchedPosition);
+ const std::string instanceMapMatchedPositionClient = "MapMatchedPosition";
+ mp_mapMatchedPositionClientProxy = new MapMatchedPositionClientProxy(domain,instanceMapMatchedPositionClient);
mp_mapMatchedPositionClientProxy->setListeners();
LOG_INFO_MSG(gCtx,"map matched position client");
diff --git a/src/navigation/navigation-common/log.h b/src/navigation/navigation-common/log.h
new file mode 100644
index 0000000..4d946fb
--- /dev/null
+++ b/src/navigation/navigation-common/log.h
@@ -0,0 +1,154 @@
+/**************************************************************************
+* @licence app begin@
+*
+* SPDX-License-Identifier: MPL-2.0
+*
+* \ingroup GNSSService
+*
+* \copyright Copyright (C) BMW Car IT GmbH 2011
+* Copyright (C) 2013, XS Embedded GmbH
+*
+* \license
+* 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@
+**************************************************************************/
+
+#ifndef INCLUDE_LOG
+#define INCLUDE_LOG
+
+// turn-on via cmake define:
+// $ cmake -DWITH_DLT=1 -DDEBUG_ENABLED=1 ..
+
+#if (!DLT_ENABLED)
+/*****************************************************************************/
+// use printf
+#include <stdio.h>
+
+// some type-name used instead of DLT context
+typedef const char* NoDltContext;
+
+#define DLT_DECLARE_CONTEXT(CONTEXT) \
+ NoDltContext CONTEXT;
+
+#define DLT_IMPORT_CONTEXT(CONTEXT) \
+ extern NoDltContext CONTEXT;
+
+#define DLT_REGISTER_CONTEXT(CONTEXT, CONTEXT_ID, DESC) \
+ CONTEXT = CONTEXT_ID;
+
+#define DLT_REGISTER_APP(CONTEXT, DESC) ;
+
+#define DLT_UNREGISTER_CONTEXT(CONTEXT) ;
+#define DLT_UNREGISTER_APP() ;
+#define dlt_free() ;
+
+// log calls
+#if (!DEBUG_ENABLED)
+
+#define LOG_VERBOSE_MSG(context, msg) ;
+#define LOG_VERBOSE(context, fmt, ...) ;
+
+#define LOG_DEBUG_MSG(context, msg) ;
+#define LOG_DEBUG(context, fmt, ...) ;
+
+#define LOG_INFO_MSG(context, msg) ;
+#define LOG_INFO(context, fmt, ...) ;
+
+#define LOG_WARNING_MSG(context, msg) ;
+#define LOG_WARNING(context, fmt, ...) ;
+
+#else
+
+#define LOG_VERBOSE_MSG(context, msg) \
+ fprintf(stderr, "[VERBO][%4s] " msg "\n", context)
+#define LOG_VERBOSE(context, fmt, ...) \
+ fprintf(stderr, "[VERBO][%4s] " fmt "\n", context, __VA_ARGS__)
+
+#define LOG_DEBUG_MSG(context, msg) \
+ fprintf(stderr, "[DEBUG][%4s] " msg "\n", context)
+#define LOG_DEBUG(context, fmt, ...) \
+ fprintf(stderr, "[DEBUG][%4s] " fmt "\n", context, __VA_ARGS__)
+
+#define LOG_INFO_MSG(context, msg) \
+ fprintf(stderr, "[INFO ][%4s] " msg "\n", context)
+#define LOG_INFO(context, fmt, ...) \
+ fprintf(stderr, "[INFO ][%4s] " fmt "\n", context, __VA_ARGS__)
+
+#define LOG_WARNING_MSG(context, msg) \
+ fprintf(stderr, "[WARN ][%4s] " msg "\n", context)
+#define LOG_WARNING(context, fmt, ...) \
+ fprintf(stderr, "[WARN ][%4s] " fmt "\n", context, __VA_ARGS__)
+#endif
+
+#define LOG_ERROR_MSG(context, msg) \
+ fprintf(stderr, "[ERROR][%4s] " msg "\n", context)
+#define LOG_ERROR(context, fmt, ...) \
+ fprintf(stderr, "[ERROR][%4s] " fmt "\n", context, __VA_ARGS__)
+
+#define LOG_FATAL_MSG(context, msg) \
+ fprintf(stderr, "[FATAL][%4s] " msg "\n", context)
+#define LOG_FATAL(context, fmt, ...) \
+ fprintf(stderr, "[FATAL][%4s] " fmt "\n", context, __VA_ARGS__)
+
+#else /* DLT_ENABLED */
+/*****************************************************************************/
+// use DLT
+#include "dlt.h"
+
+typedef const char* Context;
+
+#define LOG_VERBOSE_MSG(context, msg) \
+ DLT_LOG(context, DLT_LOG_VERBOSE, DLT_STRING(msg));
+#define LOG_VERBOSE(context, fmt, ...) \
+ { \
+ char logBuffer[256]; \
+ sprintf(logBuffer, fmt, __VA_ARGS__); \
+ DLT_LOG(context, DLT_LOG_VERBOSE, DLT_STRING(logBuffer)); \
+ }
+#define LOG_DEBUG_MSG(context, msg) \
+ DLT_LOG(context, DLT_LOG_DEBUG, DLT_STRING(msg));
+#define LOG_DEBUG(context, fmt, ...) \
+ { \
+ char logBuffer[256]; \
+ sprintf(logBuffer, fmt, __VA_ARGS__); \
+ DLT_LOG(context, DLT_LOG_DEBUG, DLT_STRING(logBuffer)); \
+ }
+#define LOG_INFO_MSG(context, msg) \
+ DLT_LOG(context, DLT_LOG_INFO, DLT_STRING(msg));
+#define LOG_INFO(context, fmt, ...) \
+ { \
+ char logBuffer[256]; \
+ sprintf(logBuffer, fmt, __VA_ARGS__); \
+ DLT_LOG(context, DLT_LOG_INFO, DLT_STRING(logBuffer)); \
+ }
+#define LOG_WARNING_MSG(context, msg) \
+ DLT_LOG(context, DLT_LOG_WARN, DLT_STRING(msg));
+#define LOG_WARNING(context, fmt, ...) \
+ { \
+ char logBuffer[256]; \
+ sprintf(logBuffer, fmt, __VA_ARGS__); \
+ DLT_LOG(context, DLT_LOG_WARN, DLT_STRING(logBuffer)); \
+ }
+#define LOG_ERROR_MSG(context, msg) \
+ DLT_LOG(context, DLT_LOG_ERROR, DLT_STRING(msg));
+#define LOG_ERROR(context, fmt, ...) \
+ { \
+ char logBuffer[256]; \
+ sprintf(logBuffer, fmt, __VA_ARGS__); \
+ DLT_LOG(context, DLT_LOG_ERROR, DLT_STRING(logBuffer)); \
+ }
+#define LOG_FATAL_MSG(context, msg) \
+ DLT_LOG(context, DLT_LOG_FATAL, DLT_STRING(msg));
+#define LOG_FATAL(context, fmt, ...) \
+ { \
+ char logBuffer[256]; \
+ sprintf(logBuffer, fmt, __VA_ARGS__); \
+ DLT_LOG(context, DLT_LOG_FATAL, DLT_STRING(logBuffer)); \
+ }
+
+#endif /* DLT_ENABLED */
+
+#endif /* INCLUDE_LOG */