Rename Kconfig options (components/freemodbus)

This commit is contained in:
Roland Dobai 2019-04-26 18:47:21 +02:00
parent 64c2aa15aa
commit 976d2a4b7f
16 changed files with 75 additions and 57 deletions

View File

@ -1,6 +1,6 @@
menu "Modbus configuration"
config MB_MASTER_TIMEOUT_MS_RESPOND
config FMB_MASTER_TIMEOUT_MS_RESPOND
int "Slave respond timeout (Milliseconds)"
default 150
range 50 400
@ -9,7 +9,7 @@ menu "Modbus configuration"
If master sends a frame which is not broadcast, it has to wait sometime for slave response.
if slave is not respond in this time, the master will process timeout error.
config MB_MASTER_DELAY_MS_CONVERT
config FMB_MASTER_DELAY_MS_CONVERT
int "Slave conversion delay (Milliseconds)"
default 200
range 50 400
@ -18,7 +18,7 @@ menu "Modbus configuration"
If master sends a broadcast frame, it has to wait conversion time to delay,
then master can send next frame.
config MB_QUEUE_LENGTH
config FMB_QUEUE_LENGTH
int "Modbus serial task queue length"
range 0 200
default 20
@ -26,7 +26,7 @@ menu "Modbus configuration"
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
config FMB_SERIAL_TASK_STACK_SIZE
int "Modbus serial task stack size"
range 768 8192
default 2048
@ -34,7 +34,7 @@ menu "Modbus configuration"
Modbus serial task stack size for event queue task.
It may be adjusted when debugging is enabled (for example).
config MB_SERIAL_BUF_SIZE
config FMB_SERIAL_BUF_SIZE
int "Modbus serial task RX/TX buffer size"
range 0 2048
default 256
@ -43,33 +43,33 @@ menu "Modbus configuration"
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
config FMB_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).
The priority of Modbus controller task is equal to (CONFIG_FMB_SERIAL_TASK_PRIO - 1).
config MB_CONTROLLER_SLAVE_ID_SUPPORT
config FMB_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
config FMB_CONTROLLER_SLAVE_ID
hex "Modbus controller slave ID"
range 0 4294967295
default 0x00112233
depends on MB_CONTROLLER_SLAVE_ID_SUPPORT
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 MB_CONTROLLER_NOTIFY_TIMEOUT
config FMB_CONTROLLER_NOTIFY_TIMEOUT
int "Modbus controller notification timeout (ms)"
range 0 200
default 20
@ -77,7 +77,7 @@ menu "Modbus configuration"
Modbus controller notification timeout in milliseconds.
This timeout is used to send notification about accessed parameters.
config MB_CONTROLLER_NOTIFY_QUEUE_SIZE
config FMB_CONTROLLER_NOTIFY_QUEUE_SIZE
int "Modbus controller notification queue size"
range 0 200
default 20
@ -85,7 +85,7 @@ menu "Modbus configuration"
Modbus controller notification queue size.
The notification queue is used to get information about accessed parameters.
config MB_CONTROLLER_STACK_SIZE
config FMB_CONTROLLER_STACK_SIZE
int "Modbus controller stack size"
range 0 8192
default 4096
@ -93,7 +93,7 @@ menu "Modbus configuration"
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
config FMB_EVENT_QUEUE_TIMEOUT
int "Modbus stack event queue timeout (ms)"
range 0 500
default 20
@ -101,21 +101,21 @@ menu "Modbus configuration"
Modbus stack event queue timeout in milliseconds. This may help to optimize
Modbus stack event processing time.
config MB_TIMER_PORT_ENABLED
config FMB_TIMER_PORT_ENABLED
bool "Modbus slave 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
config FMB_TIMER_GROUP
int "Modbus Timer group number"
range 0 1
default 0
help
Modbus Timer group number that is used for timeout measurement.
config MB_TIMER_INDEX
config FMB_TIMER_INDEX
int "Modbus Timer index in the group"
range 0 1
default 0

View File

@ -21,14 +21,14 @@
#include "esp_modbus_callbacks.h" // for modbus callbacks function pointers declaration
#include "mbc_serial_slave.h" // for create function of serial port
#ifdef CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT
#ifdef CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
#define MB_ID_BYTE0(id) ((uint8_t)(id))
#define MB_ID_BYTE1(id) ((uint8_t)(((uint16_t)(id) >> 8) & 0xFF))
#define MB_ID_BYTE2(id) ((uint8_t)(((uint32_t)(id) >> 16) & 0xFF))
#define MB_ID_BYTE3(id) ((uint8_t)(((uint32_t)(id) >> 24) & 0xFF))
#define MB_CONTROLLER_SLAVE_ID (CONFIG_MB_CONTROLLER_SLAVE_ID)
#define MB_CONTROLLER_SLAVE_ID (CONFIG_FMB_CONTROLLER_SLAVE_ID)
#define MB_SLAVE_ID_SHORT (MB_ID_BYTE3(MB_CONTROLLER_SLAVE_ID))
// Slave ID constant
@ -127,7 +127,7 @@ esp_err_t mbc_slave_start()
MB_SLAVE_CHECK((slave_interface_ptr->start != NULL),
ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized.");
#ifdef CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT
#ifdef CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
// Set the slave ID if the KConfig option is selected
eMBErrorCode status = eMBSetSlaveID(MB_SLAVE_ID_SHORT, TRUE, (UCHAR*)mb_slave_id, sizeof(mb_slave_id));
MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE, "mb stack set slave ID failure.");
@ -252,4 +252,4 @@ eMBErrorCode eMBRegInputCB(UCHAR * pucRegBuffer, USHORT usAddress,
"Slave interface is not correctly initialized.");
error = slave_interface_ptr->slave_reg_cb_input(pucRegBuffer, usAddress, usNRegs);
return error;
}
}

View File

@ -18,8 +18,8 @@
#include "driver/uart.h" // for UART types
#define MB_CONTROLLER_STACK_SIZE (CONFIG_MB_CONTROLLER_STACK_SIZE) // Stack size for Modbus controller
#define MB_CONTROLLER_PRIORITY (CONFIG_MB_SERIAL_TASK_PRIO - 1) // priority of MB controller task
#define MB_CONTROLLER_STACK_SIZE (CONFIG_FMB_CONTROLLER_STACK_SIZE) // Stack size for Modbus controller
#define MB_CONTROLLER_PRIORITY (CONFIG_FMB_SERIAL_TASK_PRIO - 1) // priority of MB controller task
// Default port defines
#define MB_DEVICE_ADDRESS (1) // Default slave device address in Modbus

View File

@ -26,8 +26,8 @@
#define MB_INST_MIN_SIZE (2) // The minimal size of Modbus registers area in bytes
#define MB_INST_MAX_SIZE (65535 * 2) // The maximum size of Modbus area in bytes
#define MB_CONTROLLER_NOTIFY_QUEUE_SIZE (CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE) // Number of messages in parameter notification queue
#define MB_CONTROLLER_NOTIFY_TIMEOUT (pdMS_TO_TICKS(CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT)) // notification timeout
#define MB_CONTROLLER_NOTIFY_QUEUE_SIZE (CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE) // Number of messages in parameter notification queue
#define MB_CONTROLLER_NOTIFY_TIMEOUT (pdMS_TO_TICKS(CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT)) // notification timeout
#define MB_SLAVE_TAG "MB_CONTROLLER_SLAVE"

View File

@ -101,7 +101,7 @@ PR_BEGIN_EXTERN_C
#define MB_FUNC_OTHER_REP_SLAVEID_BUF ( 32 )
/*! \brief If the <em>Report Slave ID</em> function should be enabled. */
#define MB_FUNC_OTHER_REP_SLAVEID_ENABLED ( CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT )
#define MB_FUNC_OTHER_REP_SLAVEID_ENABLED ( CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT )
/*! \brief If the <em>Read Input Registers</em> function should be enabled. */
#define MB_FUNC_READ_INPUT_ENABLED ( 1 )
@ -138,11 +138,11 @@ PR_BEGIN_EXTERN_C
#if MB_MASTER_RTU_ENABLED || MB_MASTER_ASCII_ENABLED
/*! \brief If master send a broadcast frame, the master will wait time of convert to delay,
* then master can send other frame */
#define MB_MASTER_DELAY_MS_CONVERT ( CONFIG_MB_MASTER_DELAY_MS_CONVERT )
#define MB_MASTER_DELAY_MS_CONVERT ( CONFIG_FMB_MASTER_DELAY_MS_CONVERT )
/*! \brief If master send a frame which is not broadcast,the master will wait sometime for slave.
* And if slave is not respond in this time,the master will process this timeout error.
* Then master can send other frame */
#define MB_MASTER_TIMEOUT_MS_RESPOND ( CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND )
#define MB_MASTER_TIMEOUT_MS_RESPOND ( CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND )
/*! \brief The total slaves in Modbus Master system.
* \note : The slave ID must be continuous from 1.*/
#define MB_MASTER_TOTAL_SLAVE_NUM ( 247 )

View File

@ -57,7 +57,7 @@
static xQueueHandle xQueueHdl;
#define MB_EVENT_QUEUE_SIZE (1)
#define MB_EVENT_QUEUE_TIMEOUT (pdMS_TO_TICKS(CONFIG_MB_EVENT_QUEUE_TIMEOUT))
#define MB_EVENT_QUEUE_TIMEOUT (pdMS_TO_TICKS(CONFIG_FMB_EVENT_QUEUE_TIMEOUT))
/* ----------------------- Start implementation -----------------------------*/
BOOL

View File

@ -61,14 +61,14 @@
#define MB_UART_RTS (CONFIG_MB_UART_RTS)
#define MB_BAUD_RATE_DEFAULT (115200)
#define MB_QUEUE_LENGTH (CONFIG_MB_QUEUE_LENGTH)
#define MB_QUEUE_LENGTH (CONFIG_FMB_QUEUE_LENGTH)
#define MB_SERIAL_TASK_PRIO (CONFIG_MB_SERIAL_TASK_PRIO)
#define MB_SERIAL_TASK_STACK_SIZE (CONFIG_MB_SERIAL_TASK_STACK_SIZE)
#define MB_SERIAL_TASK_PRIO (CONFIG_FMB_SERIAL_TASK_PRIO)
#define MB_SERIAL_TASK_STACK_SIZE (CONFIG_FMB_SERIAL_TASK_STACK_SIZE)
#define MB_SERIAL_TOUT (3) // 3.5*8 = 28 ticks, TOUT=3 -> ~24..33 ticks
// Set buffer size for transmission
#define MB_SERIAL_BUF_SIZE (CONFIG_MB_SERIAL_BUF_SIZE)
#define MB_SERIAL_BUF_SIZE (CONFIG_FMB_SERIAL_BUF_SIZE)
// Note: This code uses mixed coding standard from legacy IDF code and used freemodbus stack

View File

@ -54,14 +54,14 @@
/* ----------------------- Defines ------------------------------------------*/
#define MB_BAUD_RATE_DEFAULT (115200)
#define MB_QUEUE_LENGTH (CONFIG_MB_QUEUE_LENGTH)
#define MB_QUEUE_LENGTH (CONFIG_FMB_QUEUE_LENGTH)
#define MB_SERIAL_TASK_PRIO (CONFIG_MB_SERIAL_TASK_PRIO)
#define MB_SERIAL_TASK_STACK_SIZE (CONFIG_MB_SERIAL_TASK_STACK_SIZE)
#define MB_SERIAL_TASK_PRIO (CONFIG_FMB_SERIAL_TASK_PRIO)
#define MB_SERIAL_TASK_STACK_SIZE (CONFIG_FMB_SERIAL_TASK_STACK_SIZE)
#define MB_SERIAL_TOUT (3) // 3.5*8 = 28 ticks, TOUT=3 -> ~24..33 ticks
// Set buffer size for transmission
#define MB_SERIAL_BUF_SIZE (CONFIG_MB_SERIAL_BUF_SIZE)
#define MB_SERIAL_BUF_SIZE (CONFIG_FMB_SERIAL_BUF_SIZE)
#define MB_SERIAL_TX_TOUT_MS (100)
#define MB_SERIAL_TX_TOUT_TICKS pdMS_TO_TICKS(MB_SERIAL_TX_TOUT_MS) // timeout for transmission

View File

@ -51,7 +51,7 @@
#include "sdkconfig.h"
#include "port_serial_slave.h"
#ifdef CONFIG_MB_TIMER_PORT_ENABLED
#ifdef CONFIG_FMB_TIMER_PORT_ENABLED
#define MB_US50_FREQ (20000) // 20kHz 1/20000 = 50mks
#define MB_DISCR_TIME_US (50) // 50uS = one discreet for timer
@ -61,8 +61,8 @@
#define MB_TIMER_DIVIDER ((TIMER_BASE_CLK / 1000000UL) * MB_DISCR_TIME_US - 1) // divider for 50uS
#define MB_TIMER_WITH_RELOAD (1)
static const USHORT usTimerIndex = CONFIG_MB_TIMER_INDEX; // Modbus Timer index used by stack
static const USHORT usTimerGroupIndex = CONFIG_MB_TIMER_GROUP; // Modbus Timer group index used by stack
static const USHORT usTimerIndex = CONFIG_FMB_TIMER_INDEX; // Modbus Timer index used by stack
static const USHORT usTimerGroupIndex = CONFIG_FMB_TIMER_GROUP; // Modbus Timer group index used by stack
static timg_dev_t *MB_TG[2] = {&TIMERG0, &TIMERG1};
@ -82,7 +82,7 @@ static void IRAM_ATTR vTimerGroupIsr(void *param)
BOOL xMBPortTimersInit(USHORT usTim1Timerout50us)
{
#ifdef CONFIG_MB_TIMER_PORT_ENABLED
#ifdef CONFIG_FMB_TIMER_PORT_ENABLED
MB_PORT_CHECK((usTim1Timerout50us > 0), FALSE,
"Modbus timeout discreet is incorrect.");
esp_err_t xErr;
@ -123,7 +123,7 @@ BOOL xMBPortTimersInit(USHORT usTim1Timerout50us)
void vMBPortTimersEnable()
{
#ifdef CONFIG_MB_TIMER_PORT_ENABLED
#ifdef CONFIG_FMB_TIMER_PORT_ENABLED
ESP_ERROR_CHECK(timer_pause(usTimerGroupIndex, usTimerIndex));
ESP_ERROR_CHECK(timer_set_counter_value(usTimerGroupIndex, usTimerIndex, 0ULL));
ESP_ERROR_CHECK(timer_enable_intr(usTimerGroupIndex, usTimerIndex));
@ -133,7 +133,7 @@ void vMBPortTimersEnable()
void vMBPortTimersDisable()
{
#ifdef CONFIG_MB_TIMER_PORT_ENABLED
#ifdef CONFIG_FMB_TIMER_PORT_ENABLED
ESP_ERROR_CHECK(timer_pause(usTimerGroupIndex, usTimerIndex));
ESP_ERROR_CHECK(timer_set_counter_value(usTimerGroupIndex, usTimerIndex, 0ULL));
// Disable timer interrupt
@ -143,7 +143,7 @@ void vMBPortTimersDisable()
void vMBPortTimerClose()
{
#ifdef CONFIG_MB_TIMER_PORT_ENABLED
#ifdef CONFIG_FMB_TIMER_PORT_ENABLED
ESP_ERROR_CHECK(timer_pause(usTimerGroupIndex, usTimerIndex));
ESP_ERROR_CHECK(timer_disable_intr(usTimerGroupIndex, usTimerIndex));
#endif

View File

@ -50,8 +50,8 @@
#define MB_TIMER_WITH_RELOAD (1)
// Timer group and timer number to measure time (configurable in KConfig)
#define MB_TIMER_INDEX CONFIG_MB_TIMER_INDEX
#define MB_TIMER_GROUP CONFIG_MB_TIMER_GROUP
#define MB_TIMER_INDEX CONFIG_FMB_TIMER_INDEX
#define MB_TIMER_GROUP CONFIG_FMB_TIMER_GROUP
#define MB_TIMER_IO_LED 0

View File

@ -0,0 +1,18 @@
# sdkconfig replacement configurations for deprecated options formatted as
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND
CONFIG_MB_MASTER_DELAY_MS_CONVERT CONFIG_FMB_MASTER_DELAY_MS_CONVERT
CONFIG_MB_QUEUE_LENGTH CONFIG_FMB_QUEUE_LENGTH
CONFIG_MB_SERIAL_TASK_STACK_SIZE CONFIG_FMB_SERIAL_TASK_STACK_SIZE
CONFIG_MB_SERIAL_BUF_SIZE CONFIG_FMB_SERIAL_BUF_SIZE
CONFIG_MB_SERIAL_TASK_PRIO CONFIG_FMB_SERIAL_TASK_PRIO
CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
CONFIG_MB_CONTROLLER_SLAVE_ID CONFIG_FMB_CONTROLLER_SLAVE_ID
CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT
CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE
CONFIG_MB_CONTROLLER_STACK_SIZE CONFIG_FMB_CONTROLLER_STACK_SIZE
CONFIG_MB_EVENT_QUEUE_TIMEOUT CONFIG_FMB_EVENT_QUEUE_TIMEOUT
CONFIG_MB_TIMER_PORT_ENABLED CONFIG_FMB_TIMER_PORT_ENABLED
CONFIG_MB_TIMER_GROUP CONFIG_FMB_TIMER_GROUP
CONFIG_MB_TIMER_INDEX CONFIG_FMB_TIMER_INDEX

View File

@ -95,7 +95,7 @@ static esp_err_t mbc_serial_slave_start(void)
(eMBParity)mbs_opts->mbs_comm.parity);
MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE,
"mb stack initialization failure, eMBInit() returns (0x%x).", status);
#ifdef CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT
#ifdef CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
status = eMBSetSlaveID(MB_SLAVE_ID_SHORT, TRUE, (UCHAR*)mb_slave_id, sizeof(mb_slave_id));
MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE, "mb stack set slave ID failure.");
#endif

View File

@ -23,8 +23,8 @@
#include "esp_modbus_common.h" // for common defines
/* ----------------------- Defines ------------------------------------------*/
#define MB_CONTROLLER_NOTIFY_QUEUE_SIZE (CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE) // Number of messages in parameter notification queue
#define MB_CONTROLLER_NOTIFY_TIMEOUT (pdMS_TO_TICKS(CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT)) // notification timeout
#define MB_CONTROLLER_NOTIFY_QUEUE_SIZE (CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE) // Number of messages in parameter notification queue
#define MB_CONTROLLER_NOTIFY_TIMEOUT (pdMS_TO_TICKS(CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT)) // notification timeout
/*
* @brief Initialize Modbus controller and stack

View File

@ -66,7 +66,7 @@ The blocking call to function waits for event specified in the input parameter a
.. doxygenfunction:: mbc_slave_get_param_info
The function gets information about accessed parameters from modbus controller event queue. The KConfig 'CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE' key can be used to configure the notification queue size. The timeout parameter allows to specify timeout for waiting notification. The :cpp:type:`mb_param_info_t` structure contain information about accessed parameter.
The function gets information about accessed parameters from modbus controller event queue. The KConfig 'CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE' key can be used to configure the notification queue size. The timeout parameter allows to specify timeout for waiting notification. The :cpp:type:`mb_param_info_t` structure contain information about accessed parameter.
Modbus serial master interface API overview

View File

@ -1,11 +1,11 @@
#
# Modbus configuration
#
CONFIG_MB_TIMER_PORT_ENABLED=y
CONFIG_MB_TIMER_GROUP=0
CONFIG_MB_TIMER_INDEX=0
CONFIG_MB_MASTER_DELAY_MS_CONVERT=200
CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND=150
CONFIG_FMB_TIMER_PORT_ENABLED=y
CONFIG_FMB_TIMER_GROUP=0
CONFIG_FMB_TIMER_INDEX=0
CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200
CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150
CONFIG_MB_UART_RXD=22
CONFIG_MB_UART_TXD=23
CONFIG_MB_UART_RTS=18
CONFIG_MB_UART_RTS=18

View File

@ -3,4 +3,4 @@
#
CONFIG_MB_UART_RXD=22
CONFIG_MB_UART_TXD=23
CONFIG_MB_UART_RTS=18
CONFIG_MB_UART_RTS=18