If your strips are NeoPixels, the link will not help; except for some insight and how to loose the use of String (capital S).
Your problem is that he NeoPixel libraries (both Adafruit and FastLed) disable the interrupts while they are updating the led strip. So a received byte will be stuck in the UART register till the the interrupt is enabled again at the end of the update of the strip. If another byte arrives, it will either overwrite what is in the UART register or it’s lost (not sure which one, I’m reasonably sure it’s the former).
So your sending application has to slow down the sending. That can be e.g. send a character once a second till the complete message is done (silly example) or send a character, wait till it’s echoed back, send the next character, wait till it’s echoed back etc.
The snippet you posted suggests you’re using a String type for the variable stringKey. But that’s all I can say… the problem is usually in the part you didn’t post.
Okay so I’ve changed my reading program so that it reads until I receive a terminating character ‘<’, and that’s working without a problem so far
In java, i changed my program to break up the information and It’s sending about 50-90 bytes, waiting a second, then sending again.
Now the problem is that using a serial monitor (an application, not the arduino one lol) , it shows me that after about 3 cycles of 300 bytes total being (divided as mentioned above), the data that is being sent from java is stuck on STATUS_PENDING… I don’t see this being a problem with java seeing as ive sent more data faster before, so I’m guessing it’s with the arduino which is weird seeing as 90 bytes/second is easy for the arduino (Ive changed the serial buffer to 256, if that makes a difference)
Where could my problem be? Here’s my reading code
**note: I would have used a terminating character ‘>’ instead of using my beginning twice but for some reason the serial monitor showed that my java program would not send a terminating character at all, which is super weird.
if(Serial.available() > 0)
char c = Serial.read();
if(c == '<') //if it's the beginning symbol
if(!reading) //if its the first time receiving this, go on
reading = true;
}else //if its the second time, this means end of a new line
reading = false;
reading = true;
arrIndex = 0;
if(reading && c != '\n')
chars[arrIndex] = c;