Test on string received by serial interface.

edited October 2015 in Library Questions

Hi, I'm still in trouble with the receiving data via serial interface.

After have solved some issues addressed in previous post, I'm now in troble with the this problem :

Using microPython I send a string like this : '$$$','z1','N','22','30','23','45','N','N','N','N','N','N','N','1144'

Using Processing2 I receive the data ,split by ',' and fill in a string array. If I print all single array elements , I see exactly the same data that send, and the same if with a data scope I trace the received data.

Now the question is :

Why if I try to check if the first element in the array is "SSS" or if the second is "z1" the code is not working while if I display the data are right ?? :-?

Here part of code :

void serialEvent(Serial myPort)

{ String inBuffer_str = myPort.readStringUntil('\n');

println(inBuffer_str); // < --- here It's all right

String[] inBuffer = split(inBuffer_str.trim(), ",");

println(inBuffer[0].length()); // < ---this show 3

println(inBuffer[0].trim()); // < ---this show $$$

if (inBuffer[0]=="$$$")

{ println("ok");} // < ---never arrive at this point

}

I've also tryied to test the string instead that as $$$ like 363636 but nothing to do ?

And btw , it happens if I try to test in the same way any other element of the inBuffer array.

What is wrong in my code ? In which way can I test the string ? :(

Answers

Sign In or Register to comment.