Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial Monitor doesn't recognize Carriage Return #1223

Closed
gse76 opened this issue Jan 14, 2013 · 8 comments
Closed

Serial Monitor doesn't recognize Carriage Return #1223

gse76 opened this issue Jan 14, 2013 · 8 comments
Labels
Component: IDE Serial monitor Tools > Serial Monitor feature request A request to make an enhancement (not a bug fix) Type: Duplicate Another item already exists for this topic Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature
Milestone

Comments

@gse76
Copy link

gse76 commented Jan 14, 2013

With Arduino 1.0.3 the instruction "Serial.print('\r')" isn't displayed in the Serial Monitor. This instruction should return the carriage at the beginning of the current line in the terminal.
Using another terminal instead, such as Putty, this instruction works as expected.

I use it in order to display a single line updating (i.e.: to show a continuos changing sensor state)

@AlanTJohnstone
Copy link

In the first communication example - Reading a serial ASCII-encoded string.
the program looks for '/n' but does not find it.
The output of the following
Serial.println('/n'); // print as an ASCII-encoded decimal
Serial.println('/n', DEC); // print as an ASCII-encoded decimal
Serial.println('/n', HEX); // print as an ASCII-encoded hexadecimal
Serial.println('/n', OCT); // print as an ASCII-encoded octal
Serial.println('/n', BIN); // print as an ASCII-encoded binary

is
12142
12142
2F6E
27556
10111101101110
I do not see how any of these equate to Carriage Return which is ASCII 13 or LINEFEED which is 10

changeing the line
if (Serial.read() == '\n')
to
if (Serial.read() == 13)/)
and changing the drop down box at the bottom of the Monitor window to
Carriage return
then the program works

@cmaglie
Copy link
Member

cmaglie commented Jan 17, 2013

@gse76

yes this is a know problem with the Arduino IDE serial monitor.

@AlanTJohnstone

your problem is totally unrelated to the original issue, and it is probably better if you post such problems in the forum.

In any case you are confusing the escape sequence \n (with the backslash) with the two-characters sequence /n (with the normal slash).

'/n' is not an escape sequence but the concatenation of '/' and 'n' that are respectively 2F and 6E. This explains the numbers you're seeing (2F6E in various bases...), be sure to use '\n' instead.

@AlanTJohnstone
Copy link

You are quite correct of course. I typed in the wrong string when trying to understand the problem.
The fact remains that the code does not work no matter the setting at the bottom of Serial Monitor.

No line ending sends NO char (as you would expect)
Newline sends 10 only (as you would expect)
Carriage return sends 13 only (as you would expect)
NL and CR sends 13 only (as you would NOT expect)

I do not know what ‘\n’ is interpreted as in the “ if ” statement but replacing it with “ int(‘\n’) ”
is equivalent to 10 so works with the Newline setting above

Alan

@AlanTJohnstone
Copy link

I apologize if I should not be bothering you. If you could tell me where I should address these thoughts I will do so.

I have done more experimenting with the problem and converting the Serial.read() to a char by

char test=(char)Serial.read();
if(test=’\n’)......

does NOT work with “ Both NL and CR”

but it DOES work in the Serial Event example

There are two things that are different between the two instances
1 The if statement is in the serialEvent() function which does not seem a likely cause.

2 In the first program the test follows Serial.parseInt()

Can you mix the two forms of working?

Alan

@RobTillaart
Copy link

@AlanTJohnstone
Please open a discussion for this issue on the forum in the "Suggestions for the Arduino Project" subsection.
Post a link to that discussion here and when the forum reaches a solution it can be posted here again. That way we can help the Arduino core team to improve the core code.
Thanks,

@ffissore
Copy link
Contributor

@gse76, as @cmaglie said, this is a know limitation of Serial Monitor, unlikely to be fixed. Serial Monitor is not a terminal and it's unable to properly handle a handful of control codes. Please use tools like putty or cutecom instead
@AlanTJohnstone please open a specific issue with your request, if your enquiry is still valid

@ffissore ffissore added Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature Component: IDE The Arduino IDE labels May 27, 2015
@ffissore ffissore added this to the Release 1.6.5 milestone May 27, 2015
@ffissore ffissore self-assigned this May 27, 2015
@akilawickey
Copy link

akilawickey commented Nov 16, 2016

It's also cannot recognized on Linux screen serial monitor
screen /dev/ttyUSB0

@per1234
Copy link
Collaborator

per1234 commented Oct 4, 2017

Duplicate of #346

@per1234 per1234 marked this as a duplicate of #346 Oct 4, 2017
@per1234 per1234 added Component: IDE Serial monitor Tools > Serial Monitor Type: Duplicate Another item already exists for this topic and removed Component: IDE The Arduino IDE labels Oct 4, 2017
@per1234 per1234 added the feature request A request to make an enhancement (not a bug fix) label Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE Serial monitor Tools > Serial Monitor feature request A request to make an enhancement (not a bug fix) Type: Duplicate Another item already exists for this topic Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature
Projects
None yet
Development

No branches or pull requests

8 participants