| | |
| | | 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 { |