Loading...
Pages: [1]   Go Down
Author Topic: terminal commands  (Read 5077 times)
0 Members and 1 Guest are viewing this topic.
Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

hi

I'm wondering if we could put in terminal-oriented commands into the Serial function for use in the serial monitor... things like
CLS for clear screen and CR for carriage return?


D
« Last Edit: March 29, 2007, 01:10:21 am by Daniel » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 7
Posts: 3532
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, you can use Serial.print('\r') to get a carriage return... or Serial.println() which sends a carriage return and a newline.  I suppose we could use something like the page feed character (byte 12) to clear the serial monitor, but I'm not sure how useful it is.  What kind of uses do you have in mind?
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks

I was just thinking it would be nice to have a "clear screen" command in serialPrint, so that the long scrolling list of data could be replaced by a single number that updates.

D
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Clearscreen is going to change values depending on what you are connected to. vt100 emulators will clear screen on "<ESC>[2J", and maybe on a formfeed, CTRL-L. If you have a small ascii LED or LCD module on your serial port then it will take something else, like "\354\001". Maybe this is better covered in an example than making a well named function that will do the wrong thing for some people.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 7
Posts: 3532
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yea, having one updating number instead of a long scrolling list could be nice, but I wonder if there's a simple/clean enough way to do it that makes it worthwhile.  I'm not sure there's a way to do it consistently across terminal emulators, and it would require some hacking the serial monitor to get it to working there.  Plus, I'm reluctant to add a function to the core libraries just for this.  But maybe there's a nice way to do it.
Logged

0
Offline Offline
Faraday Member
**
Karma: 6
Posts: 2504
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I was just thinking it would be nice to have a "clear screen" command in serialPrint, so that the long scrolling list of data could be replaced by a single number that updates.

Just print a carriage return without a linefeed and (if your terminal application is behaving properly) it will continuously overwrite that same line.

toy example:
Code:
Serial.print(value, DEC);
delay(5000);
Serial.print("\r");
Serial.print(newvalue, DEC);

-j
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just tried the Serial.print('\r') but it doesn't work in the serial monitor. As if the "\r" is ignored.
Logged

0
Offline Offline
Faraday Member
**
Karma: 6
Posts: 2504
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I just tried the Serial.print('\r') but it doesn't work in the serial monitor. As if the "\r" is ignored.

That's why I said "if your terminal application is behaving properly." smiley  The serial monitor isn't a true terminal application.

Try using some other terminal program e.g. hyperterm on windows, minicom on linux, not sure on mac OS X; I think ZTerm is popular.  I use kermit, but then I've been using kermit since I got it for my C64.

Oh, and my example may not be quite right - you may want to use
Code:
Serial.print("\r             \r");
instead of
Code:
Serial.print("\r");
 so that you make sure you overwrite the old values all the time (e.g., if the old value is 100 and the new one is 99, you could end up seeing "990").  Just use enough spaces between the "\r"s to make sure you overwrite all old values.

-j
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

'\r' works when I use "screen" as a terminal. But I would have preferred the serial monitor.
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

hi

I just meant a proprietary command that would clear the screen in the Arduino serial monitor...
but perhaps that would not be such a good idea, given what has been said above!

D
« Last Edit: March 30, 2007, 01:23:51 pm by Daniel » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I just meant a proprietary command that would clear the screen in the Arduino serial monitor...  
but perhaps that would not be such a good idea, given what has been said above!

Just in case you didn't understand: I meant the application "screen", the terminal window manager:
http://www.gnu.org/software/screen/
Logged

0
Offline Offline
Faraday Member
**
Karma: 6
Posts: 2504
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think screen would just pass it through to the terminal, so it falls back on whatever's physically (pr virtually, in the case of a window) attached.

-j
Logged

Pages: [1]   Go Up
Print
 
Jump to: