forkineye / ESPAsyncE131

Asynchronous E1.31 (sACN) library for Arduino ESP8266 and ESP32

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ringbuffer library has issues with ESP32

drvkmr opened this issue · comments

Hello,
This has been already mentioned in #8 , I spent a significant amount of time trying to figure this out.
Basically the problem is with using ringbuffer which for some reason breaks ESP32 sooner or later. Apparently it's because of the way ESP32 uses multiple cores but I don't really knpw.

I am transferring a relatively large amount of data (24 universes), which works surprisingly well generally until it suddenly stops. It can happen within a few seconds or after a couple of minutes. The interesting thing is lot of other parts of the program still keep working and I have no clue why.

For a long time, I tried to fix the issue in my code, but eventually the warnings-

"This library only fully supports AVR and ESP8266 Boards."
 "Operations on the buffer in ISRs are not safe!"

drew my attention I decided to get rid of ringbuffer. This took some time but once it was done there have been no issues even if I run at 60fps for hours.

I have a larger bytearray wsRawData in my code and am simply using memcpy in the callback like this -

void onNewPacketReceived(e131_packet_t* packet, void* userInfo) {
    uint16_t offset = (htons(packet->universe) - 1) * CHANNELS_PER_UNIVERSE;
    memcpy(wsRawData+offset, packet->property_values + 1, CHANNELS_PER_UNIVERSE);  // +1 to skip the start code }

Here packet is sbuff (which I made public) not pbuff.

Now I don't know what's the best way to fix this for the library itself because my implementation is similar to #9 but it does force you to go to a lower level and deal with the data yourself which is not ideal.

I found this from Espressif but not sure how to implement this or if it's even possible.

is this bug still valid ? drvkmr what was the fix you made ? can you share ?

Yes I simply eliminated the use of ring buffer which fixed the issue. Here is the fork if you want to try out.
Did not open any pull request because it doesn't look like the repository is being maintained anymore.

anyone ported to esp-idf ?