From 98ea38910b2795c86023c54b83d70030c7bb08c5 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期六, 16 九月 2023 22:06:18 +0800 Subject: [PATCH] 更改:UINT to DINT --- pkg/plc/apacheplc4x/modbus.go | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/plc/apacheplc4x/modbus.go b/pkg/plc/apacheplc4x/modbus.go index f44a92a..4a07521 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,8 +131,8 @@ 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() -- Gitblit v1.8.0