From be40c6bbad18cee0444c50069d98967cd26b6c3b Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 19 十二月 2023 20:10:24 +0800 Subject: [PATCH] plc读写参数调整,读写方式调整 --- pkg/plc/modbusx/modbusrtu.go | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/plc/modbusx/modbusrtu.go b/pkg/plc/modbusx/modbusrtu.go index 253bc88..d6c1236 100644 --- a/pkg/plc/modbusx/modbusrtu.go +++ b/pkg/plc/modbusx/modbusrtu.go @@ -16,9 +16,9 @@ return } -func WriteByRTU(c *common.RTUConfig, address uint16, value int) (err error) { +func WriteByRTU(c *common.RTUConfig, address uint16, value int, endian string, length int) (err error) { var bytesVal []byte - bytesVal = intToBytes(value) + bytesVal = intToBytes(value, endian, length) cli := getModbusRTUConnection(c) _, err = cli.WriteMultipleRegisters(address, uint16(len(bytesVal)), bytesVal) dealRTUErr(err, c.SerialName) -- Gitblit v1.8.0