Update ds248x.go

pull/13/head
Audrius Paskevicius 5 years ago committed by GitHub
parent 41e667c14f
commit 790eaf7deb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -199,23 +199,23 @@ func (d *Dev) ChannelSelect(ch int) error {
// SelectedChannel function is to read with 1-w channel selected on DS2482-800. // SelectedChannel function is to read with 1-w channel selected on DS2482-800.
// On other chips it always returns 0. It is expected that application keeps track of // On other chips it always returns 0. It is expected that application keeps track of
// with 1-w device is connected to with channel. // with 1-w device is connected to with channel.
// On error returns 255. // On error returns -1.
func (d *Dev) SelectedChannel() int { func (d *Dev) SelectedChannel() int {
switch d.isDS248x { switch d.isDS248x {
case isDS2482x800: case isDS2482x800:
var sch [1]byte var sch [1]byte
if err := d.i2c.Tx([]byte{cmdSetReadPtr, regCSR}, sch[:]); err != nil { if err := d.i2c.Tx([]byte{cmdSetReadPtr, regCSR}, sch[:]); err != nil {
return 255 return -1
} }
ch := bytes.Index(cscr[:], sch[:]) ch := bytes.Index(cscr[:], sch[:])
if ch < 0 || ch > 7 { if ch < 0 || ch > 7 {
return 255 return -1
} }
return ch return ch
case isDS2482x100, isDS2483: case isDS2482x100, isDS2483:
return 0 return 0
default: default:
return 255 return -1
} }
} }

Loading…
Cancel
Save