Hello,
I threw some code together based on what you were sending…
I adapted my Arduino code to send a random extra line and also got an expected ArrayIndexOutOfBoundsException.
https://forum.processing.org/two/discussion/8070/why-do-i-get-an-arrayindexoutofboundsexception
This tested for it:
if (data > 4)
println("Corrupt data!");
else
sLidarData [data++] = serialData;
Often people are just using the “canned” Arduino examples and try to work with that.
I did not provide a complete working solution… just some code to get you started.
Adapt or rewrite your code as required and as errors show up.
Also search through the forum for some insights.
:)