PseudoResonance / Pixy2JavaAPI

Pixy2 API ported to Java for FIRST Robotics RoboRIO
37 stars 11 forks source link

Get "LLVL Error: out of memory" with large number of blocks #15

Open fovea1959 opened 3 years ago

fovea1959 commented 3 years ago

Using 1.4 (can't use 1.4.1, not on WPILIB 2021), we get "LLVL Error: out of memory" when we get a result with a large number (>10) of blocks.

We are SPI connected.

Working around it right now (better Pixy tuning!), will dig into it after March with a test case.

PseudoResonance commented 3 years ago

That sounds like a crash caused by the underlying C libraries, so it's probably out of the scope of this project. I think it's probably due to the internal data buffer filling up? The Pixy2 can send a lot of data at once, and I vaguely remember having this error in the past with a lot of blocks.

I don't really know a ton about the inner workings of WPILib, but I'd guess it's somewhere around here in SPIJNI.cpp, perhaps with the resizing of the buffers. Pixy2JavaAPI works by receiving a header for the packet that gives a size, which will eventually result in JNI calling this spiReadB method, and resizing the buffers to match the size requested by my API.