You may not be keeping up at the receiving end.
Do the math for your BAUD rate and the size of your payload.
It is worthwhile to do some research on this.
I tested your code with a hardware serial port (not SerialUSB) and it worked with a BAUD as high as 2000000 (for testing only!)
If you want higher performance, throughout and control:
- Increase BAUD rate. Only as high as required and testing!
- Reduce size of your payload
- Optimize code on receiving end
- Consider handshaking between Arduino and Processing
- print() to console can impact performance; only use for development
//char pcOutBuffer[] = "Motorboard:Present_Posistion 1 20093774343;Present_Posistion 2 20093774343;Present_Posistion 3 20093774343;"; //typical payload
char pcOutBuffer[] = "20093774343,20093774343,20093774343"; //typical payload
Payload can be reduced further if necessary but work on above first.
serialEvent() that I tested with:
int t, tLast;
void serialEvent(Serial myPort)
{
String strIn = myPort.readString();
print(strIn);
//close loop control would happen here
t=millis();
println(t-tLast);
tLast = t;
myPort.write('\n');//command to arduino would fit here as well
}
At some point you may need these:
:)