Working around UDP issues

The plan was to use Spark Cores to control LEDs with the Art-Net stage lighting protocol. The first naive attempt at porting an Arduino library failed, and I learned about these UDP issues with the Core: . The problem seems to be that consecutive packets get combined into one big read(), and things like available() also return the size of multiple packets.

Thankfully, Art-Net has both a length field and a “magic” string at the beginning of packets to identify the start of packets. I think it will be possible to code around the issues / particularities of the Core’s UDP, but it’s hard to debug, so I’m asking for your help…

I made some pseudo-code to encode the logic, but I don’t know when to call read(), available() and parsePacket.
Can packets get split across multiple reads if one of the buffers is full?

while (true) {
  read 18 bytes of headers
  if (header.magic == 'Art-Net') {
    read header.length of data
  else { 
    flush ;

Attempts thus far have resulted in various kinds of crashes – red light, flashing cyan, and needing to reset the core in order to flash it again.

Turns out my main problem was just a bug in my code. I can receive data, but having trouble receiving at high rates – one packet every 33 ms is fine, two packets does not work.

If I read the firmware code correctly, I can’t read() more than 512 bytes at once, and I can’t even receive full packets larger than 512. This is a blocker, so I will try to call the socket interface directly, if possible.

1 Like

I wrote some new code which uses select() and recv(). This worked for rates of a bit more than 30 packets per second. Beyond that I’m pretty sure it started dropping packets (not combining them into one buffer, even though my buffer size was 2048).

The spark will be useful in this way, but it would be great to push more packets. Is 30-40 packets per second a limit of the CC33000 chip?

I’m also currently looking at code for receiving Art-Net.

I’ve been playing with some existing published code such as

I’t will work for a second or two and then just halt.

How is your code going? are you interested in sharing?

1 Like

Cool that someone else is trying it too. The code works quite OK for 30 fps with a single universe. A bit of jitter every now and then, but quite usable.

I don’t have the code here, working on it at a friend’s house, so I’ll try to remember to post it when I get a chance.

We had better success with the arduino due with an ethernet shield, and also the uno even though we expected a memory problem with many neopixels. These could drive at least 2 universes very well. We have still left to try the CC33000 chip with the arduino, that will be quite interesting.

Would love to give your code a go when you get a chance to post it. Sounds like you have worked around the UDP issues.

The Spark has such a potential to be a cool little wireless ArtNet node.

I’m aware that the Arduino’s are working well for this purpose as we have done a bunch of ArtNet pixel mapping with them in the past, i’m really after wireless.

Here is the code :slight_smile: There is some extra junk in there, and no comments, sorry about that

Thanks for posting your code, Il’l give it a go.

Most appreciated