adafruit / Adafruit_DotStar_Pi

DotStar module for Python on Raspberry Pi
GNU General Public License v3.0
60 stars 30 forks source link

Fixed header and footer bug with hardware SPI. #9

Closed chrisrossx closed 8 years ago

chrisrossx commented 8 years ago

The bug

The commit 8638cb5a7284e3c752a1b38fc0fb05681e056b59 on Sep 14 introduced a bug into the hardware SPI mode.

The call to ioctl in raw_write returns with -22 "EINVA"

This is due to both the tx_buf and rx_buf of the spi_ioc_transfer of the header and footer being set to null. This appears to not be allowed by the SPI libraries.

The fix

Header

I have added the same header code back in from the previous fix.

Footer

For the footer, The code creates and initialize an array every call to raw_write in order to keep the new method of determining the footer Length.

I had orignally though of creating and caching the footer in begin like the header, but that would only work if numLEDs was set by the user. Because there is an option of passing in raw_data, I kept it all in the raw_write method.

Other

I have also moved the .speed_hz settings back into being, as they shouldn't need to be set every raw_write call.

PaintYourDragon commented 8 years ago

What version of the OS and spidev library are you running? NULL buffer sends zeros according to spidev documentation (and confirmed working on my test system).

chrisrossx commented 8 years ago

Raspbian 3.18.11-v7+, installed from Noobs 1.4.2 on Raspberry Model 2

To be honest, I am learning this, I am not sure how to tell which version of spidev is on my system. I can view the file under /usr/include/linux/spi/spidev.h but I don't see a version number of that file. I believe however the GNU C Library is version 2.13

Do you have a link to the documentation? I tried to review the spi source code, to see which check was returning EINVAL, but couldn't tell exactly.