esp-idf icon indicating copy to clipboard operation
esp-idf copied to clipboard

Expose stop bit in modbus communication config (IDFGH-11906)

Open mattiaVDM opened this issue 1 year ago • 2 comments

Is your feature request related to a problem?

I have a specification in my project which is asking to change stop bit configuration of ModBus slave stack at runtime. I see no option to do so in mb_communication_info_t struct.

/**
     * @brief Device communication structure to setup Modbus controller
     */
    typedef union
    {
        // Serial communication structure
        struct
        {
            mb_mode_type_t mode;  /*!< Modbus communication mode */
            uint8_t slave_addr;   /*!< Modbus slave address field (dummy for master) */
            uart_port_t port;     /*!< Modbus communication port (UART) number */
            uint32_t baudrate;    /*!< Modbus baudrate */
            uart_parity_t parity; /*!< Modbus UART parity settings */
            uint16_t dummy_port;  /*!< Dummy field, unused */
        };
        // TCP/UDP communication structure
        struct
        {
            mb_mode_type_t ip_mode;          /*!< Modbus communication mode */
            uint16_t ip_port;                /*!< Modbus port */
            mb_tcp_addr_type_t ip_addr_type; /*!< Modbus address type */
            void *ip_addr;                   /*!< Modbus address table for connection */
            void *ip_netif_ptr;              /*!< Modbus network interface */
        };
    } mb_communication_info_t;

Describe the solution you'd like.

Expose the option to set stop bits when configuring the modbus stack.

Describe alternatives you've considered.

I tried to read the source code but could not figure out how to set it by myself after slave/master initialization. Is there a workaround to do it?

Additional context.

No response

mattiaVDM avatar Jan 16 '24 15:01 mattiaVDM

Looks to be a duplicate of https://github.com/espressif/esp-idf/issues/8003 which has a solution for changing the stop bits

atanisoft avatar Jan 16 '24 22:01 atanisoft

Here is additional duplicate issue against esp-modbus: https://github.com/espressif/esp-modbus/issues/25

See also the options in v2.0.0_beta release: serial options example

alisitsyn avatar Jan 17 '24 08:01 alisitsyn