This example adds functionality to support basic communication in RS485 networks using Modbus protocol. This example uses FreeModbus stack and regular UART driver API to communicate in RS485 half duplex mode. Added initial support of modbus controller pure C api to access device parameters over Modbus transport. Move freemodbus stack and port files into components folder Move the modbus_controller interface into components idf folder Source files updated after review. Add modbus interface documentation docs/en/api-reference/protocols/modbus.rst porttimer.c: fix bug with timer1 selected in the Kconfig Add support of cmake system (added cmake files) Closes https://github.com/espressif/esp-idf/issues/858
133 lines
4.1 KiB
Text
133 lines
4.1 KiB
Text
menu "Modbus configuration"
|
|
|
|
config MB_UART_RXD
|
|
int "UART RXD pin number"
|
|
range 0 34
|
|
default 22
|
|
help
|
|
GPIO number for UART RX pin. See UART documentation for more information
|
|
about available pin numbers for UART.
|
|
|
|
config MB_UART_TXD
|
|
int "UART TXD pin number"
|
|
range 0 34
|
|
default 23
|
|
help
|
|
GPIO number for UART TX pin. See UART documentation for more information
|
|
about available pin numbers for UART.
|
|
|
|
config MB_UART_RTS
|
|
int "UART RTS pin number"
|
|
range 0 34
|
|
default 18
|
|
help
|
|
GPIO number for UART RTS pin. This pin is connected to
|
|
~RE/DE pin of RS485 transceiver to switch direction.
|
|
|
|
config MB_QUEUE_LENGTH
|
|
int "Modbus serial task queue length"
|
|
range 0 200
|
|
default 20
|
|
help
|
|
Modbus serial driver queue length. It is used by event queue task.
|
|
See the serial driver API for more information.
|
|
|
|
config MB_SERIAL_TASK_STACK_SIZE
|
|
int "Modbus serial task stack size"
|
|
range 768 8192
|
|
default 2048
|
|
help
|
|
Modbus serial task stack size for event queue task.
|
|
It may be adjusted when debugging is enabled (for example).
|
|
|
|
config MB_SERIAL_BUF_SIZE
|
|
int "Modbus serial task RX/TX buffer size"
|
|
range 0 2048
|
|
default 256
|
|
help
|
|
Modbus serial task RX and TX buffer size for UART driver initialization.
|
|
This buffer is used for modbus frame transfer. The Modbus protocol maximum
|
|
frame size is 256 bytes. Bigger size can be used for non standard implementations.
|
|
|
|
config MB_SERIAL_TASK_PRIO
|
|
int "Modbus serial task priority"
|
|
range 3 10
|
|
default 10
|
|
help
|
|
Modbus UART driver event task priority.
|
|
The priority of Modbus controller task is equal to (CONFIG_MB_SERIAL_TASK_PRIO - 1).
|
|
|
|
config MB_CONTROLLER_SLAVE_ID_SUPPORT
|
|
bool "Modbus controller slave ID support"
|
|
default n
|
|
help
|
|
Modbus slave ID support enable.
|
|
When enabled the Modbus <Report Slave ID> command is supported by stack.
|
|
|
|
config MB_CONTROLLER_SLAVE_ID
|
|
hex "Modbus controller slave ID"
|
|
range 0 4294967295
|
|
default 0x00112233
|
|
depends on MB_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 MB_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 MB_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 MB_CONTROLLER_STACK_SIZE
|
|
int "Modbus controller stack size"
|
|
range 0 8192
|
|
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 MB_EVENT_QUEUE_TIMEOUT
|
|
int "Modbus stack event queue timeout (ms)"
|
|
range 0 500
|
|
default 20
|
|
help
|
|
Modbus stack event queue timeout in milliseconds. This may help to optimize
|
|
Modbus stack event processing time.
|
|
|
|
config MB_TIMER_PORT_ENABLED
|
|
bool "Modbus stack use timer for 3.5T symbol time measurement"
|
|
default y
|
|
help
|
|
If this option is set the Modbus stack uses timer for T3.5 time measurement.
|
|
Else the internal UART TOUT timeout is used for 3.5T symbol time measurement.
|
|
|
|
config MB_TIMER_GROUP
|
|
int "Modbus Timer group number"
|
|
range 0 1
|
|
depends on MB_TIMER_PORT_ENABLED
|
|
default 0
|
|
help
|
|
Modbus Timer group number that is used for timeout measurement.
|
|
|
|
config MB_TIMER_INDEX
|
|
int "Modbus Timer index in the group"
|
|
range 0 1
|
|
depends on MB_TIMER_PORT_ENABLED
|
|
default 0
|
|
help
|
|
Modbus Timer Index in the group that is used for timeout measurement.
|
|
|
|
endmenu
|