Skip to content

Commit e280e9b

Browse files
raiden00plcederom
authored andcommitted
modbus: add an option to disable log
Introduce new configuration option that allow disable all logging functionality for FreeModBus. This option is useful for small systems when we don't use any logging features. Signed-off-by: raiden00pl <[email protected]>
1 parent 4945546 commit e280e9b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

modbus/Kconfig

+9
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,13 @@ config MB_MASTER_FUNC_READWRITE_HOLDING_ENABLED
251251

252252
endif # MB_ASCII_MASTER || MB_RTU_MASTER
253253
endif # MODBUS
254+
255+
config MODBUS_DISABLE_LOG
256+
bool "Disable logging for FreeModBus"
257+
default !FILE_STREAM
258+
---help---
259+
Disable all logging features for FreeModBus which can be useful
260+
for small optimized systems without console or log file support.
261+
This also must be enabled when fputs() is not supported.
262+
254263
endmenu # FreeModBus

modbus/nuttx/port.h

+4
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ typedef enum
7979

8080
void vMBPortEnterCritical(void);
8181
void vMBPortExitCritical(void);
82+
#ifndef CONFIG_MODBUS_DISABLE_LOG
8283
void vMBPortLog(eMBPortLogLevel eLevel, const char *szModule,
8384
const char *szFmt, ...) printf_like(3, 4);
85+
#else
86+
# define vMBPortLog(l, m, c, ...)
87+
#endif
8488
void vMBPortTimerPoll(void);
8589
bool xMBPortSerialPoll(void);
8690
bool xMBPortSerialSetTimeout(uint32_t dwTimeoutMs);

modbus/nuttx/portother.c

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ void vMBPortLogFile(FILE * fNewLogFile)
7373
fLogFile = fNewLogFile;
7474
}
7575

76+
#ifndef CONFIG_MODBUS_DISABLE_LOG
7677
void vMBPortLog(eMBPortLogLevel eLevel, const char * szModule,
7778
const char * szFmt, ...)
7879
{
@@ -103,6 +104,7 @@ void vMBPortLog(eMBPortLogLevel eLevel, const char * szModule,
103104
}
104105
}
105106
}
107+
#endif
106108

107109
void vMBPortEnterCritical(void)
108110
{

0 commit comments

Comments
 (0)