Logging
This commit is contained in:
parent
1dc12ff5c1
commit
82fc95a00d
2 changed files with 6 additions and 9 deletions
|
@ -67,11 +67,11 @@ func (r *Device) readReg(addr byte) (byte, error) {
|
||||||
tx := make([]uint8, 2)
|
tx := make([]uint8, 2)
|
||||||
tx[0] = addr & 0x7f
|
tx[0] = addr & 0x7f
|
||||||
tx[1] = 0
|
tx[1] = 0
|
||||||
log.Printf("read %x", addr)
|
|
||||||
rx, err := r.SpiDevice.Xfer(tx)
|
rx, err := r.SpiDevice.Xfer(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
log.Printf("read %x: %x", addr, rx[1])
|
||||||
return rx[1], err
|
return rx[1], err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,8 +322,7 @@ func (r *Device) readRSSI(forceTrigger bool) (rssi int, err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var data byte
|
data, err := r.readReg(REG_RSSIVALUE)
|
||||||
data, err = r.readReg(REG_RSSIVALUE)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
10
spi_linux.go
10
spi_linux.go
|
@ -84,10 +84,8 @@ int spi_xfer(int fd, char* tx, char* rx, int length) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import "unsafe"
|
||||||
"log"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
import "errors"
|
import "errors"
|
||||||
|
|
||||||
// SPIDevice device
|
// SPIDevice device
|
||||||
|
@ -110,9 +108,9 @@ func NewSPIDevice() (*SPIDevice, error) {
|
||||||
func (d *SPIDevice) Xfer(tx []byte) ([]byte, error) {
|
func (d *SPIDevice) Xfer(tx []byte) ([]byte, error) {
|
||||||
length := len(tx)
|
length := len(tx)
|
||||||
rx := make([]byte, length)
|
rx := make([]byte, length)
|
||||||
log.Print("sending", tx)
|
//log.Print("sending", tx)
|
||||||
ret := C.spi_xfer(d.fd, (*C.char)(unsafe.Pointer(&tx[0])), (*C.char)(unsafe.Pointer(&rx[0])), C.int(length))
|
ret := C.spi_xfer(d.fd, (*C.char)(unsafe.Pointer(&tx[0])), (*C.char)(unsafe.Pointer(&rx[0])), C.int(length))
|
||||||
log.Print("got", rx)
|
//log.Print("got", rx)
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, errors.New("could not xfer")
|
return nil, errors.New("could not xfer")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue