Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modbus: add an option to disable log #3035

Merged
merged 1 commit into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions modbus/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,13 @@ config MB_MASTER_FUNC_READWRITE_HOLDING_ENABLED

endif # MB_ASCII_MASTER || MB_RTU_MASTER
endif # MODBUS

config MODBUS_DISABLE_LOG
bool "Disable logging for FreeModBus"
default !FILE_STREAM
---help---
Disable all logging features for FreeModBus which can be useful
for small optimized systems without console or log file support.
This also must be enabled when fputs() is not supported.

endmenu # FreeModBus
4 changes: 4 additions & 0 deletions modbus/nuttx/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,22 @@
MB_LOG_ERROR = 0,
MB_LOG_WARN = 1,
MB_LOG_INFO = 2,
MB_LOG_DEBUG = 3

Check failure on line 74 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 74 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
} eMBPortLogLevel;

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

Check failure on line 80 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 80 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
void vMBPortEnterCritical(void);

Check failure on line 81 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 81 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
void vMBPortExitCritical(void);
#ifndef CONFIG_MODBUS_DISABLE_LOG

Check failure on line 83 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 83 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 83 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 83 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 83 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 83 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 83 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 83 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
void vMBPortLog(eMBPortLogLevel eLevel, const char *szModule,

Check failure on line 84 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 84 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
const char *szFmt, ...) printf_like(3, 4);
#else
# define vMBPortLog(l, m, c, ...)
#endif

Check failure on line 88 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 88 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
void vMBPortTimerPoll(void);

Check failure on line 89 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found

Check failure on line 89 in modbus/nuttx/port.h

View workflow job for this annotation

GitHub Actions / check

Mixed case identifier found
bool xMBPortSerialPoll(void);
bool xMBPortSerialSetTimeout(uint32_t dwTimeoutMs);

Expand Down
2 changes: 2 additions & 0 deletions modbus/nuttx/portother.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ void vMBPortLogFile(FILE * fNewLogFile)
fLogFile = fNewLogFile;
}

#ifndef CONFIG_MODBUS_DISABLE_LOG
void vMBPortLog(eMBPortLogLevel eLevel, const char * szModule,
const char * szFmt, ...)
{
Expand Down Expand Up @@ -104,6 +105,7 @@ void vMBPortLog(eMBPortLogLevel eLevel, const char * szModule,
}
}
}
#endif

void vMBPortEnterCritical(void)
{
Expand Down
Loading