Go Down

Topic: How do i send a CR without a LF? (Read 2460 times) previous topic - next topic

mfriesen

I'm trying to write a sketch where values are client.printed to a Telnet terminal session so new data overwrites the last data on the same line.  In "the old days" with Wyse terminals and the like all you needed to do was send a CR without the LF.   With my Arduino sketch no matter how I try to send a CR without the LF I still get a new line added to my Telnet session.  One of the ways I tried was client.print('\r') but I still got a recieved LF. Anyone know how to do this?

CrossRoads

Use Serial.write or Serial.print, and look up the CR character at asciitable.com to send as the last piece of data.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Nick Gammon


 One of the ways I tried was client.print('\r') but I still got a recieved LF. Anyone know how to do this?


That should have worked. Perhaps if you post your code?

Read this before posting a programming question
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

PeterH


One of the ways I tried was client.print('\r') but I still got a recieved LF.


It may be that your telnet client was misleading you by being Windows/UNIX line termination tolerant. How do you know what characters you actually received?
I only provide help via the forum - please do not contact me for private consultancy.

mfriesen

Quote
It may be that your telnet client was misleading you by being Windows/UNIX line termination tolerant. How do you know what characters you actually received?


I'm not.  I have used both putty and the mircosoft Telnet client that comes with Win7.  I checked both Telnet client settings to see if there was a CR/LF type setting on the receive side.  I couldn't find a setting that fixed it.  I searched the WEB and I found someone else complaining about Arduino code always inserting the LF.  He may be wrong as well.  Can anyone confirm that I can send a LF only?

WizenedEE

I have sent \r and \n independently and received them with gnu screen on linux.

Nick Gammon


 Can anyone confirm that I can send a LF only?


Can you post an example piece of code that exhibits this problem please?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

mfriesen

Code: [Select]
void sendTime()
 
 {
   
  if ((client.connected())&& ( connectFlag == 1 ) && ( t != 0 )){
  client.println();
  client.print(hours);
  client.print(":");
  client.print(M);
  client.print(m);
  client.print(":");
  client.print(S);
  client.print(s);
  client.print('\r');
 }
 
 }


LOL. Thanks alot.  I've been working on this all day and there it is!!  WTF is that first client.println() doing in there!  Thanks for making me post the code.  I wouldn't have found it for days.  Boy do I feel stupid.

Thanls for your help.
1:45:30

Go Up