call and response code, I know it exists

because I played with it before and simply can't turn it up now. I am working on a project that will be using one-way serail comm with a compass, and I want to test my code for parsing the output by hand feeding it some code I expect thru the serial monitor, but I am an idiot and can't find the example code. All i need the code to do is capture the serial input from the monitor, which will be about 30 char long, turn it into a char array (probably easier than a string for what I am doing) and then i will play with it, and then spit some data back out to the monitor to prove i can find the info i want in it.

somewhere there was some exmple code that when you type something into the serial montior, the arduino types it back at you. can someone point me to that sketch? I think that's all i need to get my feet under me.

File menu -> Examples -> Communication -> SerialCallResponse

but that only captures the first byte sent in, i need it to take the whole array of letters. someone had some nice example code for this

PaulS has the most functional code for serial comms.

Take a look at this thread and scroll down. You will see his response which includes the code.,93899.0.html

that looks like exactly what I need, thanks! however it seems to be written in a different language (bool vs boolean, #define) i don’t forsee any issues translating it to what I need.

now whilest I have your attention, I need to configure the serial device I am connected to. in order to do this, I must send the following keystrokes, all contained within <> to avoid confusion
I could do

Serial.prinit(' ');

I want to clean that up a bit, but I am afraid i don;t know how to make it more succint. I worry "R1 " will include a null at the end, not sure if that would affect the reciever or not, but i don’t like doing things that I don’t know what they do, and I don’t have a logic analyzer to smell this stuff IRL

I worry "R1 " will include a null at the end

It will. But, the NULL won't be sent. It is a marker that tells the Serial.print() function that it is time to stop sending.

ah, makes sense. is there any way to incorporate the char into one line, so that it is cleaner? can I send htem all as ASCII codes, maybe as an array?

chars and bytes are the same size. You can use them nearly interchangeably. So, yes, you cam create an array of bytes that includes the ESC value, the character R, the character 1, the character space, and a terminating NULL. Then, use Serial.print() to send the array.

Serial.prinit(' ');

Try to get the spelling right. It's print not prinit.

All you have to do is this:

Serial.print ("\x1BR1 ");

The \x1B says "make a character with the hex code of 1B (decimal code of 27)".