Update ds248x.go

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

@ -179,8 +179,8 @@ func (d *Dev) ChannelSelect(ch int) error {
var err error = nil
switch d.isDS248x {
case isDS2482x100:
err = errors.New("unsupported (ds2482-100 has only channel 0)")
return fmt.Errorf("ds2482-100: error while selecting channel: %s", err)
// err = errors.New("unsupported (ds2482-100 has only channel 0)")
// return fmt.Errorf("ds2482-100: error while selecting channel: %s", err)
case isDS2482x800:
if ch < 0 || ch > 7 {
err = errors.New("channel out of range 0...7")
@ -191,8 +191,8 @@ func (d *Dev) ChannelSelect(ch int) error {
return fmt.Errorf("ds2482-800: error while selecting channel: %s", err)
}
case isDS2483:
err = errors.New("unsupported (ds2483 has only channel 0)")
return fmt.Errorf("ds2483: error while selecting channel: %s", err)
// err = errors.New("unsupported (ds2483 has only channel 0)")
// return fmt.Errorf("ds2483: error while selecting channel: %s", err)
default:
err = errors.New("wrong chip")
return fmt.Errorf("ds248x: error while selecting channel: %s", err)
@ -214,7 +214,7 @@ func (d *Dev) SelectedChannel() int {
if err := d.i2c.Tx([]byte{cmdSetReadPtr, regCSR}, sch[:]); err != nil {
return 255
}
ch = bytes.Index(cscr, []byte{sch[0]})
ch = bytes.Index(cscr[:], sch[:])
if ch < 0 {
return 255
}
@ -435,4 +435,4 @@ const (
)
var cscw = [...]byte{cscIO0w, cscIO1w, cscIO2w, cscIO3w, cscIO4w, cscIO5w, cscIO6w, cscIO7w}
var cscr = []byte{cscIO0r, cscIO1r, cscIO2r, cscIO3r, cscIO4r, cscIO5r, cscIO6r, cscIO7r}
var cscr = [...]byte{cscIO0r, cscIO1r, cscIO2r, cscIO3r, cscIO4r, cscIO5r, cscIO6r, cscIO7r}

Loading…
Cancel
Save