zhangqian
2023-10-26 620d904921c76b6b29d1b69787da7a82121d4c31
pkg/plc/apacheplc4x/modbus.go
@@ -19,7 +19,7 @@
   // 创建一个上下文,并设置 3 秒超时
   ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
   defer cancel()
   conn, err := newGetModbusConnection(ctx, ipAddr)
   conn, err := newModbusConnection(ctx, ipAddr)
   if err != nil {
      logx.Errorf("new modbus connection err: %v", err.Error())
      return nil, err
@@ -27,7 +27,7 @@
   return conn, nil
}
func newGetModbusConnection(ctx context.Context, ipAddr string) (plc4go.PlcConnection, error) {
func newModbusConnection(ctx context.Context, ipAddr string) (plc4go.PlcConnection, error) {
   // 创建驱动管理器
   driverManager := plc4go.NewPlcDriverManager()
   // 注册TCP传输