Hi to all , I'm quite new of Processing and I've a problem with the serial data receiving.
I must receive the below csv string from the serial interface and split character by character into an array ,but all the tentatives to do it have no success . This is the string to be parsed : "$,$,$,z,1,y,2,2,3,0,2,3,4,5,y,y,y,y,y,y,y,5,6,7,8,z,2,y,1,2,1,0,1,2,3,0,y,y,y,y,y,y,y,2,3,2,3,4,4,4,4,4,4,4,4,2,0,1,5,0,8,2,7,1,2,3,3,0"
This is the code:
while (myPort.available() > 0)
{
String inBuffer = myPort.readStringUntil('\n');
if (inBuffer != null)
{println(inBuffer); // till this point all works fine.
String[] to_char = split(inBuffer,',');
print(to_char[1]);
}
}
If instead of print(to_char[1]) i put print(to_char[0]) i see correctly $ otherwise i gote an error that say ArrayIndexOutOfBoundException as just the first element of the array is available.
Could someone give me a good suggestion to solve this problem ? Thank . Roberto