From 26cde1dc945786fab5d63f3be64829031ba13978 Mon Sep 17 00:00:00 2001 From: Claudio Scordino Date: Tue, 29 Jan 2019 11:58:16 +0100 Subject: [PATCH] Introduce platform-specific EC_PRINT Rationale: not all operating systems use function printf for printing console messages. This commits allows to define platform-specific functions. --- osal/intime/osal_defs.h | 9 +++++++++ osal/linux/osal_defs.h | 9 +++++++++ osal/rtems/osal_defs.h | 9 +++++++++ osal/rtk/osal_defs.h | 9 +++++++++ osal/vxworks/osal_defs.h | 9 +++++++++ osal/win32/osal_defs.h | 9 +++++++++ soem/ethercatconfig.c | 8 -------- 7 files changed, 54 insertions(+), 8 deletions(-) diff --git a/osal/intime/osal_defs.h b/osal/intime/osal_defs.h index 1325963..34a9e87 100644 --- a/osal/intime/osal_defs.h +++ b/osal/intime/osal_defs.h @@ -11,6 +11,15 @@ extern "C" { #endif +// define if debug printf is needed +//#define EC_DEBUG + +#ifdef EC_DEBUG +#define EC_PRINT printf +#else +#define EC_PRINT(...) do {} while (0) +#endif + #ifndef PACKED #ifdef _MSC_VER #define PACKED_BEGIN __pragma(pack(push, 1)) diff --git a/osal/linux/osal_defs.h b/osal/linux/osal_defs.h index 7140754..6ec32ef 100644 --- a/osal/linux/osal_defs.h +++ b/osal/linux/osal_defs.h @@ -11,6 +11,15 @@ extern "C" { #endif +// define if debug printf is needed +//#define EC_DEBUG + +#ifdef EC_DEBUG +#define EC_PRINT printf +#else +#define EC_PRINT(...) do {} while (0) +#endif + #ifndef PACKED #define PACKED_BEGIN #define PACKED __attribute__((__packed__)) diff --git a/osal/rtems/osal_defs.h b/osal/rtems/osal_defs.h index 7140754..6ec32ef 100644 --- a/osal/rtems/osal_defs.h +++ b/osal/rtems/osal_defs.h @@ -11,6 +11,15 @@ extern "C" { #endif +// define if debug printf is needed +//#define EC_DEBUG + +#ifdef EC_DEBUG +#define EC_PRINT printf +#else +#define EC_PRINT(...) do {} while (0) +#endif + #ifndef PACKED #define PACKED_BEGIN #define PACKED __attribute__((__packed__)) diff --git a/osal/rtk/osal_defs.h b/osal/rtk/osal_defs.h index c848b42..162a42e 100644 --- a/osal/rtk/osal_defs.h +++ b/osal/rtk/osal_defs.h @@ -11,6 +11,15 @@ extern "C" { #endif +// define if debug printf is needed +//#define EC_DEBUG + +#ifdef EC_DEBUG +#define EC_PRINT printf +#else +#define EC_PRINT(...) do {} while (0) +#endif + #ifndef PACKED #define PACKED_BEGIN #define PACKED __attribute__((__packed__)) diff --git a/osal/vxworks/osal_defs.h b/osal/vxworks/osal_defs.h index 1a3310d..3aafb73 100644 --- a/osal/vxworks/osal_defs.h +++ b/osal/vxworks/osal_defs.h @@ -6,6 +6,15 @@ #ifndef _osal_defs_ #define _osal_defs_ +// define if debug printf is needed +//#define EC_DEBUG + +#ifdef EC_DEBUG +#define EC_PRINT printf +#else +#define EC_PRINT(...) do {} while (0) +#endif + #ifndef PACKED #define PACKED_BEGIN #define PACKED __attribute__((__packed__)) diff --git a/osal/win32/osal_defs.h b/osal/win32/osal_defs.h index d24c6a8..2587aa7 100644 --- a/osal/win32/osal_defs.h +++ b/osal/win32/osal_defs.h @@ -11,6 +11,15 @@ extern "C" { #endif +// define if debug printf is needed +//#define EC_DEBUG + +#ifdef EC_DEBUG +#define EC_PRINT printf +#else +#define EC_PRINT(...) do {} while (0) +#endif + #ifndef PACKED #define PACKED_BEGIN __pragma(pack(push, 1)) #define PACKED diff --git a/soem/ethercatconfig.c b/soem/ethercatconfig.c index 4bfc540..878e426 100644 --- a/soem/ethercatconfig.c +++ b/soem/ethercatconfig.c @@ -22,14 +22,6 @@ #include "ethercatsoe.h" #include "ethercatconfig.h" -// define if debug printf is needed -//#define EC_DEBUG - -#ifdef EC_DEBUG -#define EC_PRINT printf -#else -#define EC_PRINT(...) do {} while (0) -#endif typedef struct {