プロジェクトでは、RS485 シリアル ラインに接続された 4 つの modbus デバイスがあります。デバイスは正常に動作しており、コントローラーを作成しているので、 のパフォーマンスに非常に不満がありpymodbus
ます。
私はこのスレッドのPython modbus ライブラリを見つけました。より良い Python modbus ライブラリがあるように思えます。pymodbus
使いやすいので、できれば使い続けたいです。
ただし、読み取り/書き込みルーチンが戻るのにかかる時間はタイムアウトに等しいことがわかりました。これは私には正しくないように思われるので、簡単なテストを書きました:
from pymodbus.client.sync import ModbusSerialClient
import time
for t in xrange(1, 11):
client = ModbusSerialClient("rtu", port="/dev/ttyUSB0", baudrate=9600, timeout=t)
start = time.time()
data = client.read_holding_registers(0x9000, count=7, unit=2)
stop = time.time()
if data:
succ = "was successful"
else:
succ = "failed"
print "timeout: %ss, read %s, time spent reading: %fs" % (t, succ, stop-start)
これは私が得た出力です
timeout: 1s, read was successful, time spent reading: 1.039731s
timeout: 2s, read was successful, time spent reading: 2.038965s
timeout: 3s, read was successful, time spent reading: 3.041441s
timeout: 4s, read was successful, time spent reading: 4.040762s
timeout: 5s, read was successful, time spent reading: 5.043523s
timeout: 6s, read was successful, time spent reading: 6.040139s
timeout: 7s, read was successful, time spent reading: 7.042159s
timeout: 8s, read was successful, time spent reading: 8.045216s
timeout: 9s, read was successful, time spent reading: 9.047682s
timeout: 10s, read was successful, time spent reading: 10.048799s
さまざまな RS845<->USB コンバーターでテストしましたが、常に同様の結果が得られます。
他の誰かがこれを確認できますか? ModbusSerialClient
または、のパフォーマンスを向上させる文書化されていない引数が欠落していますか?