How to configure the Timeout Property Using the Modbus function in MATLAB R2024a?

2 views (last 30 days)

I am trying to connect to another device using the "modbus" function but am experiencing timeouts at approximately 20 seconds. I have tried setting the "Timeout" parameter to 20, however it did not work. Is it possible to control the max duration of a connection timeout? If so, how?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Jul 2025
The timeout parameter is designed to set the timeout value only for read and write operations and does not affect the connection itself. To set the timeout value of the connection using the "modbus" function, please consider the following workaround:
modbusIP = <ip_address>; modbusPort = <port>; tcpipObject = matlabshared.transportlib.internal.TransportFactory. ... getTransport('tcpip', modbusIP, modbusPort); tcpipObject.ConnectTimeout = 1 %% Set this property to your desired connection timeout value m = modbus('tcpip', tcpipObject)
<ip_address> and <port> should be replaced with their respective values.

More Answers (0)

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!