Modbus: fix using tcp instead of rtu over serial
This commit is contained in:
parent
14bfec15ac
commit
05bd765623
1 changed files with 4 additions and 4 deletions
|
|
@ -161,7 +161,7 @@ func ProtocolFromRTU(rtu *bool) Protocol {
|
|||
}
|
||||
|
||||
// NewConnection creates physical modbus device from config
|
||||
func NewConnection(uri, device, comset string, baudrate int, wire Protocol, slaveID uint8) (*Connection, error) {
|
||||
func NewConnection(uri, device, comset string, baudrate int, proto Protocol, slaveID uint8) (*Connection, error) {
|
||||
var conn meters.Connection
|
||||
|
||||
if device != "" && uri != "" {
|
||||
|
|
@ -181,10 +181,10 @@ func NewConnection(uri, device, comset string, baudrate int, wire Protocol, slav
|
|||
return nil, errors.New("invalid modbus configuration: need baudrate and comset")
|
||||
}
|
||||
|
||||
if wire == Rtu {
|
||||
conn = registeredConnection(device, meters.NewRTU(device, baudrate, comset))
|
||||
if proto == Ascii {
|
||||
conn = registeredConnection(device, meters.NewASCII(device, baudrate, comset))
|
||||
} else {
|
||||
conn = registeredConnection(uri, meters.NewASCII(device, baudrate, comset))
|
||||
conn = registeredConnection(device, meters.NewRTU(device, baudrate, comset))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue