I'm Trying to send (0x1B) and [2J (clear screen command) from the serial monitor to softserial.
With the program below:
Sending with a terminal program (Terra Term) works fine.
The commented out soft0.print also works.
I'm happy enough to use terra term but I would like to know what it, and the commented out print,
are doing that my byte c is not and what I should be looking at to fix it.
I'm Trying to send (0x1B) and [2J (clear screen command) from the serial monitor to softserial.
A screen shot of the Serial Monitor just before you press the Send button would be useful. Whatever text you type in the input field is sent one letter at a time to the serial port.
Whether what you type in the serial monitor looks like "\x1B[2J", or not, can not be determined from your post.
A screen shot of the Serial Monitor just before you press the Send button would be useful.
Whatever I type in, before Send, is what is sent out (one char at a time as you stated).
So,
\x1B[2J hit Send sends \x1B[2J
"\x1B[2J" --> "\x1B[2J"
1B[2J --> 1B[2J
In Tera Term the in/out is the same as above.
I am, however, able to hit the Esc key then [2J which clears the screen. ctrl-[ [2J also works.
The Esc key or Ctrl-[ have no effect in the serial monitor (they don't show up on in or out).
Why is the Serial.read() call in parentheses?
I only have a poor excuse for that. Rest assured it has been dealt with in a harsh way.
The soft0.print("\x1B[2J"); seems to be smart enough to convert 1B (hex) to the Esc symbol then just send the Ascii [2J.
Using soft0.print("\x1B" "[2J"); makes more sense to me but either works.
What about?
creating an array from serial.read
if statement to see if first two bytes are 1B (or whatever I choose to use)
if ==1B then soft0.print("\x1B" );
else just print whatevers there
The following seems to work.
Type *2J in the serial monitor, hit Send, it sends and 2J (which clears the screen) out the softserial.
Used with the Bob-4 osd from Decade Eng. (www.decadenet.com)