From eaf07953842880673a7a04635661f44a4af0d174 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期一, 06 十一月 2023 11:45:19 +0800 Subject: [PATCH] fix --- constvar/const.go | 2 +- pkg/plc/apacheplc4x/modbusrtu.go | 2 +- pkg/plc/modbusx/connection_manager.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/constvar/const.go b/constvar/const.go index 8ab136b..0e126b8 100644 --- a/constvar/const.go +++ b/constvar/const.go @@ -80,7 +80,7 @@ ParityNull Parity = 3 //鏃犳牎楠� ) -func (p Parity) String() string { +func (p Parity) ToString() string { switch p { case ParityEven: return "E" diff --git a/pkg/plc/apacheplc4x/modbusrtu.go b/pkg/plc/apacheplc4x/modbusrtu.go index 6692a65..32a6169 100644 --- a/pkg/plc/apacheplc4x/modbusrtu.go +++ b/pkg/plc/apacheplc4x/modbusrtu.go @@ -15,7 +15,7 @@ func newModbusRTUConnection(c *common.RTUConfig) (plc4go.PlcConnection, error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) // 鍒涘缓涓�涓柊鐨� PLC 杩炴帴 - connectionString := fmt.Sprintf("modbus-rtu:serial://%s?baudrate=%d&databits=%d&stopbits=%d&parity=%s", c.SerialName, c.BaudRate, c.DataBit, c.StopBit, c.Parity) + connectionString := fmt.Sprintf("modbus-rtu:serial://%s?baudrate=%d&databits=%d&stopbits=%d&parity=%s", c.SerialName, c.BaudRate, c.DataBit, c.StopBit, c.Parity.ToString()) connectionRequestChanel := driverManager.GetConnection(connectionString) // 绛夊緟杩炴帴鍝嶅簲锛屽悓鏃惰�冭檻涓婁笅鏂囩殑瓒呮椂 select { diff --git a/pkg/plc/modbusx/connection_manager.go b/pkg/plc/modbusx/connection_manager.go index 57be879..b8b83ad 100644 --- a/pkg/plc/modbusx/connection_manager.go +++ b/pkg/plc/modbusx/connection_manager.go @@ -100,7 +100,7 @@ rtuHandler = modbus.NewRTUClientHandler(c.SerialName) rtuHandler.BaudRate = c.BaudRate rtuHandler.DataBits = c.DataBit - rtuHandler.Parity = c.Parity.String() + rtuHandler.Parity = c.Parity.ToString() rtuHandler.StopBits = c.StopBit rtuHandler.SlaveId = 1 rtuHandler.Timeout = 5 * time.Second -- Gitblit v1.8.0