Files
esp-modbus/Kconfig
2025-08-27 11:28:14 +01:00

258 lines
10 KiB
Plaintext

menu "Modbus configuration"
config FMB_COMM_MODE_TCP_EN
bool "Enable Modbus stack support for TCP communication mode"
default y
help
Enable Modbus TCP option for stack.
config FMB_TCP_PORT_DEFAULT
int "Modbus TCP port number"
range 0 65535
default 502
depends on FMB_COMM_MODE_TCP_EN
help
Modbus default port number used by Modbus TCP stack
config FMB_TCP_PORT_MAX_CONN
int "Maximum allowed connections for TCP stack"
range 1 LWIP_MAX_SOCKETS
default 5
depends on FMB_COMM_MODE_TCP_EN
help
Maximum allowed connections number for Modbus TCP stack.
This is used by Modbus master and slave port layer to establish connections.
This parameter may decrease performance of Modbus stack and can cause
increasing of processing time (increase only if absolutely necessary).
config FMB_TCP_CONNECTION_TOUT_SEC
int "Modbus TCP connection timeout"
range 1 7200
default 2
depends on FMB_COMM_MODE_TCP_EN
help
Modbus TCP connection timeout in seconds.
Once expired the current connection with the client will be closed
and Modbus TCP slave will be waiting for new connection to accept.
This timeout is applicable for Modbus TCP master when it tries to connect to the Modbus TCP slaves.
config FMB_TCP_KEEP_ALIVE_TOUT_SEC
int "Modbus TCP keep alive timeout (seconds)"
default 4
range 1 7200
depends on FMB_COMM_MODE_TCP_EN
help
This option is used to set keep-alive time for Modbus TCP connections.
This timeout is the interval after which the device sends keep-alive messages
to maintain a connection with a server before register the error.
The keep-alive time can be configured and should be set based on the actual needs of the application,
considering the trade-off between keeping the connection alive and minimizing system load.
config FMB_TCP_UID_ENABLED
bool "Modbus TCP enable UID (Unit Identifier) support"
default n
depends on FMB_COMM_MODE_TCP_EN
help
If this option is set the Modbus stack uses UID (Unit Identifier) field in MBAP frame.
Else the UID is ignored by master and slave.
config FMB_COMM_MODE_RTU_EN
bool "Enable Modbus stack support for RTU mode"
default y
help
Enable RTU Modbus communication mode option for Modbus serial stack.
config FMB_COMM_MODE_ASCII_EN
bool "Enable Modbus stack support for ASCII mode"
default y
help
Enable ASCII Modbus communication mode option for Modbus serial stack.
config FMB_MASTER_TIMEOUT_MS_RESPOND
int "Slave respond timeout (Milliseconds)"
default 10000
range 150 30000
help
If master sends a frame which is not broadcast, it has to wait some time for slave response.
if slave is not respond in this time, the master will process timeout error.
config FMB_MASTER_DELAY_MS_CONVERT
int "Slave conversion delay (Milliseconds)"
default 200
range 150 2000
help
If master sends a broadcast frame, it has to wait conversion time to delay,
then master can send next frame.
config FMB_QUEUE_LENGTH
int "Modbus event task queue length"
range 10 500
default 50
help
Modbus event queue length. It is used by event queue tasks
for corresponding communication mode.
config FMB_PORT_TASK_STACK_SIZE
int "Modbus port task stack size"
range 2048 16384
default 4096
help
Modbus port task stack size for rx/tx event processing.
It may be adjusted when debugging is enabled (for example).
config FMB_BUFFER_SIZE
int "Modbus RX/TX buffer size"
range 256 2048
default 260 if FMB_COMM_MODE_TCP_EN
default 256 if !FMB_COMM_MODE_TCP_EN
help
Modbus RX/TX buffer size for UART driver initialization.
This buffer is used for modbus frame transfer. The Modbus protocol maximum
frame size is 260 bytes (TCP). Bigger size can be used for non standard implementations.
config FMB_SERIAL_ASCII_BITS_PER_SYMB
int "Number of data bits per ASCII character"
default 8
range 7 8
depends on FMB_COMM_MODE_ASCII_EN
help
This option defines the number of data bits per ASCII character.
config FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS
int "Response timeout for ASCII communication mode (ms)"
default 1000
range 200 5000
depends on FMB_COMM_MODE_ASCII_EN
help
This option defines response timeout of slave in milliseconds for ASCII communication mode.
Thus the timeout will expire and allow the master program to handle the error.
config FMB_PORT_TASK_PRIO
int "Modbus port task priority"
range 3 23
default 10
help
Modbus port data processing task priority.
The priority of Modbus controller task is equal to (CONFIG_FMB_PORT_TASK_PRIO - 1).
choice FMB_PORT_TASK_AFFINITY
prompt "Modbus task affinity"
default FMB_PORT_TASK_AFFINITY_CPU0
depends on !FREERTOS_UNICORE
help
Allows setting the core affinity of the Modbus controller task, i.e. whether the task is pinned to
particular CPU, or allowed to run on any CPU.
config FMB_PORT_TASK_AFFINITY_NO_AFFINITY
bool "No affinity"
config FMB_PORT_TASK_AFFINITY_CPU0
bool "CPU0"
config FMB_PORT_TASK_AFFINITY_CPU1
bool "CPU1"
endchoice
config FMB_PORT_TASK_AFFINITY
hex
default FREERTOS_NO_AFFINITY if FMB_PORT_TASK_AFFINITY_NO_AFFINITY || FREERTOS_UNICORE
default 0x0 if FMB_PORT_TASK_AFFINITY_CPU0
default 0x1 if FMB_PORT_TASK_AFFINITY_CPU1
config FMB_CONTROLLER_SLAVE_ID_SUPPORT
bool "Modbus controller slave ID support"
default y
help
Modbus slave ID support enable.
When enabled the Modbus <Report Slave ID> command is supported by stack.
config FMB_CONTROLLER_SLAVE_ID
hex "Modbus controller slave ID"
range 0 4294967295
default 0x00112233
depends on FMB_CONTROLLER_SLAVE_ID_SUPPORT
help
Modbus slave ID value to identify modbus device
in the network using <Report Slave ID> command.
Most significant byte of ID is used as short device ID and
other three bytes used as long ID.
config FMB_CONTROLLER_SLAVE_ID_MAX_SIZE
int "Modbus Slave ID maximum buffer size (bytes)"
range 4 255
default 32
depends on FMB_CONTROLLER_SLAVE_ID_SUPPORT
help
Modbus slave ID buffer size used to store vendor specific ID information
for the <Report Slave ID> command.
config FMB_CONTROLLER_NOTIFY_TIMEOUT
int "Modbus controller notification timeout (ms)"
range 0 200
default 20
help
Modbus controller notification timeout in milliseconds.
This timeout is used to send notification about accessed parameters.
config FMB_CONTROLLER_NOTIFY_QUEUE_SIZE
int "Modbus controller notification queue size"
range 0 200
default 20
help
Modbus controller notification queue size.
The notification queue is used to get information about accessed parameters.
config FMB_CONTROLLER_STACK_SIZE
int "Modbus controller stack size"
range 2048 32768
default 4096
help
Modbus controller task stack size. The Stack size may be adjusted when
debug mode is used which requires more stack size (for example).
config FMB_EVENT_QUEUE_TIMEOUT
int "Modbus stack event queue timeout (ms)"
range 10 500
default 20
help
Modbus stack event queue timeout in milliseconds. This may help to optimize
Modbus stack event processing time.
config FMB_TIMER_USE_ISR_DISPATCH_METHOD
bool "Modbus timer uses ISR dispatch method"
default n
select ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD
select UART_ISR_IN_IRAM
help
If this option is set the Modbus stack uses ISR dispatch method
to send timeout events from the callback function called from ISR.
This option has dependency with the UART_ISR_IN_IRAM option which places UART interrupt
handler into IRAM to prevent delays related to processing of UART events.
config FMB_EXT_TYPE_SUPPORT
bool "Modbus uses extended types to support third party devices"
default n
help
If this option is set the Modbus stack supports extended list of types
in data dictionary and conversion API to work with the extended types
otherwise the only legacy types are supported. The extended types include
integer, float, double types with different endianness and size.
config FMB_FUNC_HANDLERS_MAX
int "Maximum number of Modbus function handlers"
range 16 255
default 16
help
This option defines the maximum number of Modbus command handlers for Modbus master and slave.
The option can be useful to register additional commands and its handlers.
config FMB_COMPILER_STATIC_ANALYZER_ENABLE
bool "Enable compiler static analyzer for Modbus library"
default "n"
depends on IDF_TOOLCHAIN_GCC
help
Enable compiler static analyzer for Modbus library.
This is workaround to avoid false-positives for some IDF related components.
When enabled, the library files will be analysed with GCC static analyzer.
endmenu