|
|
|
@ -101,7 +101,7 @@ func (b *i2cBus) ReadByte(addr byte) (byte, error) {
|
|
|
|
|
return bytes[0], nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *i2cBus) ReadBytes(addr byte) ([]byte, error) {
|
|
|
|
|
func (b *i2cBus) ReadBytes(addr byte, num int) ([]byte, error) {
|
|
|
|
|
b.mu.Lock()
|
|
|
|
|
defer b.mu.Unlock()
|
|
|
|
|
|
|
|
|
@ -113,16 +113,10 @@ func (b *i2cBus) ReadBytes(addr byte) ([]byte, error) {
|
|
|
|
|
return []byte{0}, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info, err := b.file.Stat()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return []byte{0}, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size := int(info.Size())
|
|
|
|
|
bytes := make([]byte, size)
|
|
|
|
|
bytes := make([]byte, num)
|
|
|
|
|
n, _ := b.file.Read(bytes)
|
|
|
|
|
|
|
|
|
|
if n != size {
|
|
|
|
|
if n != num {
|
|
|
|
|
return []byte{0}, fmt.Errorf("i2c: Unexpected number (%v) of bytes read", n)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|