diff --git a/rfm69device.go b/rfm69device.go index c6f4b22..900d46a 100644 --- a/rfm69device.go +++ b/rfm69device.go @@ -67,11 +67,11 @@ func (r *Device) readReg(addr byte) (byte, error) { tx := make([]uint8, 2) tx[0] = addr & 0x7f tx[1] = 0 - log.Printf("read %x", addr) rx, err := r.SpiDevice.Xfer(tx) if err != nil { log.Println(err) } + log.Printf("read %x: %x", addr, rx[1]) 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 { return } diff --git a/spi_linux.go b/spi_linux.go index f8668a1..419a092 100644 --- a/spi_linux.go +++ b/spi_linux.go @@ -84,10 +84,8 @@ int spi_xfer(int fd, char* tx, char* rx, int length) { } */ import "C" -import ( - "log" - "unsafe" -) +import "unsafe" + import "errors" // SPIDevice device @@ -110,9 +108,9 @@ func NewSPIDevice() (*SPIDevice, error) { func (d *SPIDevice) Xfer(tx []byte) ([]byte, error) { length := len(tx) 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)) - log.Print("got", rx) + //log.Print("got", rx) if ret < 0 { return nil, errors.New("could not xfer") }