0

Im using AsyncUDP in an ESP32 project, where I initialize AsyncUDP udpSender and call udpSender.write(sendbuffer, sendbuffer_size) from both cores, with different buffers on each core.

One core is continually collecting GY-91 (accel/gyro/magnet) sensor data many times a second and sending it via UDP multiple times a second (after every collection), and the other one is collecting some other data like temperature once a second, as well as responding to commands a server sends.

So I'm basically using one sender on both cores and wondering if this is "thread-safe", if that terminology even applies to this scenario.

Can this cause problems? Is there a specific way this should be done? Like using semaphores?

0

I don't know if it's thread safe or not. However I would be inclined to play it sage and use a queue and notifications.

  1. Create a queue
  2. Create a "sender" thread that waits for notification then sends anything in the queue through UDP
  3. Create any number of "sensor" threads that place items into the queue then notify the sender thread.
| improve this answer | |

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.