emelianov / modbus-esp8266

Most complete Modbus library for Arduino. A library that allows your Arduino board to communicate via Modbus protocol, acting as a master, slave or both. Supports network transport (Modbus TCP) and Serial line/RS-485 (Modbus RTU). Supports Modbus TCP Security for ESP8266/ESP32.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Seeking Guidance on Controlling Retry Mechanism in modbus-esp8266 Library

alansehsu opened this issue · comments

Hello! I am reaching out for some guidance and help regarding a specific need and challenge I encountered while using the modbus-esp8266 library for a project.

In our project, which involves the use of Modbus RTU communication, we have observed that if a device is not powered on or does not respond, the library automatically attempts to retry the previously inputted writeHreg command. This behavior is not always desirable in certain scenarios. Thus, we are looking for ways to more precisely control this retry mechanism. Specifically, we are interested in capabilities or settings that relate to the following aspects:

Stopping retries: We'd appreciate an option to stop automatic retries when a device does not respond.
Removing submitted commands: If it is known that certain commands should no longer be attempted due to some conditions, we'd like to remove these commands from the pending queue.
Setting the number of retries: If possible, we'd like to set a limit on the number of retries to prevent infinite attempts.
During our attempts to find solutions, we first checked the Modbus.cpp source file but did not find commands or settings directly related to our needs. We then focused on RTU communication and reviewed the ModbusSettings.h file; although we found some settings related to timeouts and maximum read wait times, they seemed not to directly address our queries.

We would greatly appreciate any advice on how we might implement the above requirements or guidance on where to look for possible solutions. Do we need to customize the library, or are there existing parameter settings that could meet our needs? Any suggestions or directions would be immensely helpful.

Thank you for taking the time to read this message. I look forward to your response.

Best regards

The library ModbusRTU implementation does not perform any buffering or other data manipulations during sending. So data frame is sending exactly once during corresponding function. Any data sent retry attempts are performed outside the library. Definitely.