From 78c1a4bf72a52997347ca59503eaa7e878c49ad6 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Mon, 26 Aug 2019 12:07:15 +0000 Subject: [PATCH] allow ports to define included functions. Instead of requiring the library itself to be modified to enable/disable functions, allow the port layer to define what functions are included. This makes maintennance of a common freemodbus core library simpler. All functions retain their original defaults. Signed-off-by: Karl Palsson --- modbus/include/mbconfig.h | 40 +++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/modbus/include/mbconfig.h b/modbus/include/mbconfig.h index 02615cb..28483b3 100644 --- a/modbus/include/mbconfig.h +++ b/modbus/include/mbconfig.h @@ -95,34 +95,54 @@ PR_BEGIN_EXTERN_C #define MB_FUNC_OTHER_REP_SLAVEID_BUF ( 32 ) /*! \brief If the Report Slave ID function should be enabled. */ -#define MB_FUNC_OTHER_REP_SLAVEID_ENABLED ( 1 ) +#ifndef MB_FUNC_OTHER_REP_SLAVEID_ENABLED +#define MB_FUNC_OTHER_REP_SLAVEID_ENABLED ( 1 ) +#endif /*! \brief If the Read Input Registers function should be enabled. */ -#define MB_FUNC_READ_INPUT_ENABLED ( 1 ) +#ifndef MB_FUNC_READ_INPUT_ENABLED +#define MB_FUNC_READ_INPUT_ENABLED ( 1 ) +#endif /*! \brief If the Read Holding Registers function should be enabled. */ -#define MB_FUNC_READ_HOLDING_ENABLED ( 1 ) +#ifndef MB_FUNC_READ_HOLDING_ENABLED +#define MB_FUNC_READ_HOLDING_ENABLED ( 1 ) +#endif /*! \brief If the Write Single Register function should be enabled. */ -#define MB_FUNC_WRITE_HOLDING_ENABLED ( 1 ) +#ifndef MB_FUNC_WRITE_HOLDING_ENABLED +#define MB_FUNC_WRITE_HOLDING_ENABLED ( 1 ) +#endif /*! \brief If the Write Multiple registers function should be enabled. */ -#define MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED ( 1 ) +#ifndef MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED +#define MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED ( 1 ) +#endif /*! \brief If the Read Coils function should be enabled. */ -#define MB_FUNC_READ_COILS_ENABLED ( 1 ) +#ifndef MB_FUNC_READ_COILS_ENABLED +#define MB_FUNC_READ_COILS_ENABLED ( 1 ) +#endif /*! \brief If the Write Coils function should be enabled. */ -#define MB_FUNC_WRITE_COIL_ENABLED ( 1 ) +#ifndef MB_FUNC_WRITE_COIL_ENABLED +#define MB_FUNC_WRITE_COIL_ENABLED ( 1 ) +#endif /*! \brief If the Write Multiple Coils function should be enabled. */ -#define MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED ( 1 ) +#ifndef MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED +#define MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED ( 1 ) +#endif /*! \brief If the Read Discrete Inputs function should be enabled. */ -#define MB_FUNC_READ_DISCRETE_INPUTS_ENABLED ( 1 ) +#ifndef MB_FUNC_READ_DISCRETE_INPUTS_ENABLED +#define MB_FUNC_READ_DISCRETE_INPUTS_ENABLED ( 1 ) +#endif /*! \brief If the Read/Write Multiple Registers function should be enabled. */ -#define MB_FUNC_READWRITE_HOLDING_ENABLED ( 1 ) +#ifndef MB_FUNC_READWRITE_HOLDING_ENABLED +#define MB_FUNC_READWRITE_HOLDING_ENABLED ( 1 ) +#endif /*! @} */ #ifdef __cplusplus