Skip to content

Commit

Permalink
Some lint-type fixes, make RTU inputs ints not bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfl committed Mar 14, 2021
1 parent b6de1cc commit 133d396
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions rtu.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type rtu struct {
}

// NewRTU establishes a connection to a local COM port (windows) or serial device (others)
func NewRTU(device string, baud int, parity byte, stopbits byte, dtr bool) (Modbus, error) {
func NewRTU(device string, baud int, parity int, stopbits int, dtr bool) (Modbus, error) {
options := serial.Config{}
options.Name = device
options.Baud = baud
Expand All @@ -70,15 +70,15 @@ func NewRTU(device string, baud int, parity byte, stopbits byte, dtr bool) (Modb
case 'O':
options.Parity = serial.ParityOdd
default:
return nil, fmt.Errorf("Illegal parity %c", parity)
return nil, fmt.Errorf("illegal parity %c", parity)
}
switch stopbits {
case 1:
options.StopBits = serial.Stop1
case 2:
options.StopBits = serial.Stop2
default:
return nil, fmt.Errorf("Illegal stop bits %v", stopbits)
return nil, fmt.Errorf("illegal stop bits %v", stopbits)
}

options.ReadTimeout = time.Millisecond
Expand All @@ -100,10 +100,10 @@ func NewRTU(device string, baud int, parity byte, stopbits byte, dtr bool) (Modb
wp.name = device
wp.serial = port
wp.isopen = true
wp.closed = make(chan bool, 0)
wp.closed = make(chan bool)
wp.rxchar = make(chan byte, 300)
wp.rxto = make(chan bool, 0)
wp.rxtoc = make(chan bool, 0)
wp.rxto = make(chan bool)
wp.rxtoc = make(chan bool)
wp.txready = make(chan bool, 1)
wp.toTX = make(chan adu, 5)
wp.toDemux = make(chan adu, 5)
Expand Down

0 comments on commit 133d396

Please sign in to comment.