Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ringbuffer library has issues with ESP32 #29

Open
drvkmr opened this issue Sep 5, 2023 · 3 comments
Open

Ringbuffer library has issues with ESP32 #29

drvkmr opened this issue Sep 5, 2023 · 3 comments

Comments

@drvkmr
Copy link

drvkmr commented Sep 5, 2023

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.

@riwalker
Copy link

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

@drvkmr
Copy link
Author

drvkmr commented Jan 30, 2024

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.

@riwalker
Copy link

anyone ported to esp-idf ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants