Pages: [1]   Go Down
Author Topic: How do i send a CR without a LF?  (Read 1710 times)
0 Members and 1 Guest are viewing this topic.
Vancouver Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Use Serial.write or Serial.print, and look up the CR character at asciitable.com to send as the last piece of data.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 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
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11195
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

I only provide help via the forum - please do not contact me for private consultancy.

Vancouver Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 17
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 Can anyone confirm that I can send a LF only?

Can you post an example piece of code that exhibits this problem please?
Logged

Vancouver Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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
Logged

Pages: [1]   Go Up
Jump to: