Validate comset parameter
This commit is contained in:
parent
6fd6d7472c
commit
93e5fd39d4
1 changed files with 7 additions and 1 deletions
|
|
@ -156,7 +156,13 @@ func NewConnection(uri, device, comset string, baudrate int, wire WireFormat, sl
|
|||
}
|
||||
|
||||
if device != "" {
|
||||
if baudrate == 0 || comset == "" {
|
||||
switch strings.ToUpper(comset) {
|
||||
case "8N1", "8E1":
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid invalid comset: %s", comset)
|
||||
}
|
||||
|
||||
if baudrate == 0 {
|
||||
return nil, errors.New("invalid modbus configuration: need baudrate and comset")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue