Go Down

Topic: Serial connection can't catch '\n' symbol! (Read 489 times) previous topic - next topic

IvanDeft

Hello! I'm from Russia, and sorry for english at first! )
I can't send long strings over serial connection because my Uno can't catch '\n' symbol!!!
This Example (http://arduino.cc/en/Tutorial/SerialEvent) not working!
But other symbols working normally!!!
What i do wrong??
Or what i must do something else to send over serial connection long strings, not "one shot" chars???

johnwasser


What i do wrong??


Are you using the Arduino Serial Monitor window?

At the bottom of the Serial Monitor is a menu for selecting the line ending character.  If it is set to one of the options that does not send '\n' that would explain why your sketch is not receiving '\n'.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Krodal

The example explains that the '\n' is used as a end of string.

Code: [Select]
if (inChar == '\n') {
  stringComplete = true;
  }


The example is working just as it is supposed to.

IvanDeft

Thank you!
)))
But now it's working in Serial Monitor. What will be if i want connect tho boards and send long strings from one to second???
It will be working without checking "new line symbol"???

johnwasser


But now it's working in Serial Monitor. What will be if i want connect tho boards and send long strings from one to second??? It will be working without checking "new line symbol"???


If you want to send 'messages' instead of 'characters' you need a way for the receiving system to recognize when it has received the end of the 'message'.  You can use '\n' or some other character that is not going to be part of your message.  Even if your messages are fixed in length (always the same number of characters) it is good to add special characters before and after the message to protect against data loss or data inserted due to noise.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

marco_c

If you send the string make sure you add the new line indicator to the end when you send it.. You need some sort of delimiter between messages or it will be hard to synch up if you get garbled messages (which will happen).
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com


Go Up