0

I'm working with an array of ~1400 dotstar LED's running off a Raspberry Pi 3 B+ with raspian 4.19. The program is in python 3.5 using the DotStar package and I'm running into an issue. Specifically, when trying to set up the board with:

dotstar.DotStar(board.SCK, board.MOSI, 1364, brightness=0.2)

I get the following error:

OverflowError: Argument list size exceeds 4096 bytes.

I've tried setting spidev.bufsiz=32768 in cmdline.txt, which seems to have taken, but I'm still getting the same error. Is there anywhere else I need to change the spidev buffersize to get things working?

Full trace:

Traceback (most recent call last):
  File "/home/pi/Desktop/Mike Test 1.py", line 9, in <module>
    dots[dot] = (0,0,255)
  File "/usr/local/lib/python3.5/dist-packages/adafruit_dotstar.py", line 200, in __setitem__
    self.show()
  File "/usr/local/lib/python3.5/dist-packages/adafruit_dotstar.py", line 269, in show
    self._spi.write(buf)
  File "/home/pi/.local/lib/python3.5/site-packages/busio.py", line 138, in write
    return self._spi.write(buf, start, end)
  File "/home/pi/.local/lib/python3.5/site-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 56, in write
    self._spi.writebytes([x for x in buf[start:end]])
OverflowError: Argument list size exceeds 4096 bytes.

Full Code:

import board
import adafruit_dotstar as dotstar

dots = dotstar.DotStar(board.SCK, board.MOSI, 1364, brightness=0.2)

n_dots = len(dots)

for dot in range(n_dots):
        dots[dot] = (0,0,255)
  • You need to give detail. We should not have to guess the software you are using or the programming language. I tend to ignore questions if sufficient information isn't provided. – joan Aug 2 at 17:12
  • @joan Edited; does that give enough info? – mcimolin Aug 2 at 17:14
1

Alright, found a solution:

In spi.py I needed to change:

self._spi.writebytes([x for x in buf[start:end]])

to:

self._spi.writebytes2(buf[start:end])

as apparently the 4k limit is baked into spidev where the dotstar library is concerned.

  • 1
    This didn't even appear in your "Full Code:" – Milliways Aug 2 at 23:42
  • this does not seem to be the answer to the question because the info in the answer does not match the info in the question – jsotola Aug 3 at 1:30
  • @Milliways the problem wasn't with my code, it was with one of the libraries that one of the libraries I was importing depended on. If you check the stack trace you'll see that the overflow error is happening in spi.py. Normally, changing the Spidev buffersize should have fixed this but apparently the adafruit_dotstar library is precompiled against a version that's capped out at 4k, so changing the line in spi.pi that I changed allows for multiple 4k packets to be written out, instead of overflowing when it hit the buffer cap. – mcimolin Aug 4 at 0:09
  • @mcimolin either way it is a simple Python error in undisclosed code. The original code is poor practice, your fix not much better, and the error is almost certainly a Python stack limitation. You should report to the code author - it is not a Pi problem. – Milliways Aug 4 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.