What is the serial monitor actually doing?

oh ok. I think I understand now. So the code goes to that function, and can potentially immediately evaluate false (or true), even though it may not actually be false (or true), and the program will then continue on.

I think I understand, but I am having difficulty coming up with the logic.

basically I want to loop until I get a handshake of "0x06"=good or a "0x15"=bad. so my response function needs to loop until it receives a response for each command transmitted. I have something written, but it's poor form. If the unit doesn't send a response, then the code goes into an infinite loop.....lol

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX
uint8_t arr[]={0x42, 0x10, 0xcc};
uint8_t new_arr[]={0x43,0x50,0x3F,0x22,0x00,0x1F};
uint8_t autobaud[]={0x55};

void setup()
{
  Serial.begin(9600);
    mySerial.begin(9600);
      delay(1000);
      dostuff(autobaud, sizeof(autobaud));
      dostuff(arr, sizeof(arr));
      dostuff(new_arr, sizeof(new_arr));
}

void loop()
{
}

void dostuff(uint8_t *buffer, int len)
{
  mySerial.write(buffer, len);  // Serial.write wants the array pointer and the number of elements
  Serial.print("Command: ");
  Serial.write(buffer, len);
  Serial.println("|");
  serial_response();
}

void  serial_response(){
  
int incomingByte=0;
    if (mySerial.available()>0){
       incomingByte = mySerial.read();
       Serial.print("Response: ");
       Serial.print(incomingByte, HEX);
       Serial.println("|");
     }
    else{
       serial_response(); 
    }
 }

the output is:

Command: U|
Response: 0|
Command: B Ì|
Response: 0|
Command: CP?" |
Response: 0|

I'm not sure why the code is printing zeros, because....the only response should be 0x06 or 0x15 as far as I know. The display is doing nothing.....it's just black. So if the display is not responding at all, I'm not sure why the code prints any response at all.

I'll have to look at the datasheet again when I get back. I'm still not sure if I'm supposed to get a response for every byte, or every command. It's every command.