From 181733a7142ee4de79061f7e5796f9cdb21fc7d8 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期日, 17 九月 2023 15:45:30 +0800 Subject: [PATCH] 发阻塞消息超时增加统一日志 --- pkg/plc/apacheplc4x/modbus.go | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/plc/apacheplc4x/modbus.go b/pkg/plc/apacheplc4x/modbus.go index f44a92a..d9ef045 100644 --- a/pkg/plc/apacheplc4x/modbus.go +++ b/pkg/plc/apacheplc4x/modbus.go @@ -52,7 +52,7 @@ func readHoldingRegisterSingle(connection plc4go.PlcConnection, address int) ([]byte, error) { tag := fmt.Sprintf("tag:%v", address) - tagAddress := fmt.Sprintf("holding-register:%d:UINT", address) + tagAddress := fmt.Sprintf("holding-register:%d:DINT", address) // 璇绘ā寮� readRequest, err := connection.ReadRequestBuilder().AddTagAddress(tag, tagAddress).Build() @@ -82,7 +82,7 @@ func readHoldingRegisterList(connection plc4go.PlcConnection, address, length int) ([]byte, error) { tag := fmt.Sprintf("tag:%v:%v", address, length) - tagAddress := fmt.Sprintf("holding-register:%d:UINT[%d]", address, length) + tagAddress := fmt.Sprintf("holding-register:%d:DINT[%d]", address, length) // 璇绘ā寮� readRequest, err := connection.ReadRequestBuilder().AddTagAddress(tag, tagAddress).Build() @@ -117,8 +117,8 @@ func ReadHoldingRegister(ipAddr string, address, length int) ([]byte, error) { connection, err := GetModbusConnection(ipAddr) + dealErr(err, ipAddr) if err != nil { - dealErr(err, ipAddr) return nil, err } defer connection.Close() @@ -131,13 +131,13 @@ func WriteHoldingRegister(ipAddr string, address int, value any) (string, error) { connection, err := GetModbusConnection(ipAddr) + dealErr(err, ipAddr) if err != nil { - dealErr(err, ipAddr) return "", err } defer connection.Close() tag := fmt.Sprintf("tag:%v:w", address) - tagAddress := fmt.Sprintf("holding-register:%d:UINT", address) + tagAddress := fmt.Sprintf("holding-register:%d:DINT", address) // 鍐欐ā寮� writeRequest, err := connection.WriteRequestBuilder().AddTagAddress(tag, tagAddress, value).Build() -- Gitblit v1.8.0