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

6 vues (au cours des 30 derniers jours)

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?

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 21 Juil 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.

Plus de réponses (0)

Catégories

En savoir plus sur Modbus Communication dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by