Modbus 通信での接続時のタイ​ムアウトはどのように​設定しますか?

조회 수: 21 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2025년 8월 15일
답변: MathWorks Support Team 2025년 8월 15일

「modbus」関数を使用して別のデバイスに接続する際、接続に失敗した場合は約20秒でタイムアウトが発生します。
Modbus オブジェクトの Timeout パラメータを変更してみましたが無視されている様子でタイムアウトまでの時間は変わりません。
接続時のタイムアウトの最大時間を調整することは可能ですか?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2025년 8월 15일
Modbus オブジェクトの Timeout パラメータは、read/write メソッドによる読み取りおよび書き込み操作のタイムアウトを設定しますので、接続時のタイムアウト時間には影響しません。 「modbus」関数を使用して接続時ののタイムアウト値を設定するには、以下の方法があります。
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> と <port> はそれぞれの値に置き換える必要があります。

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Modbus Communication에 대해 자세히 알아보기

태그

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!