Pages: [1]   Go Down
Author Topic: Serial connection can't catch '\n' symbol!  (Read 386 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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???
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8669
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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'.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Edison Member
*
Karma: 9
Posts: 1015
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

The example is working just as it is supposed to.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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"???
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8669
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Sydney, Australia
Online Online
Edison Member
*
Karma: 33
Posts: 1251
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much! )
Logged

Pages: [1]   Go Up
Jump to: