Go Down

Topic: Serial communication: Which character am I missing? (Read 908 times) previous topic - next topic

GoingForGold

Hi!

Im interfacing with a windows forms application over USB, which works pretty well. But one strange point: On the arduino, I run "Serial.println("connect"). I read this string on the computer and make "If message = "connect" Then..." which is always a false. If I make "If message.Substring(0,7) = "connect" Then..." I always get a true. The Substring function just takes the 7 first letters beginning from the first. So for me, this means, the Arduino sends one character more. If I let the Arduino print the ASCII numbers for what hes sending to the serial monitor, there also only appear 7 characters, and the last one is the "t" from the "connect".

What character am I missing, what should the software check for?

Thanks!

tuxduino


GoingForGold

Thanks for your answer.

Yes, this is what I was thinking too, but I don't know how I should check for this character (since the Arduino doesn't send an ASCII code for this, according to the serial monitor. Only print() is not possible, since the SerialPort Class doesn't accept it as "finished".

tuxduino


PaulS

The println() method adds '\n' and '\r' to the output. On the receiving end, you should be looking for these characters, and NOT storing them in the array to be compared.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy