Dealing with AT command respond terminator(Solved)

Look at the picture between the 10 and 13, I’m actualy printing the byte of the char, and there is that nothing that print along, what is it?

In case it can help…

void serialEvent1(){
  
  while (Serial1.available()) {
  
    char caractere_entrant = (char)Serial1.read(); 
    chaine_entrante += caractere_entrant;
    Serial.println((byte)caractere_entrant);
    longueur++;
    if ((dernier_caractere=='\n')&&(caractere_entrant=='\r')){Compte_retour++;}
    else{Compte_retour=0;}
    dernier_caractere=caractere_entrant;
    
  }
    
    if (Compte_retour=2){
      Serial.println("en affaire");  
      chaine_complete = true;
      Compte_retour=0;
   }
    
  Serial.print(chaine_entrante); 
  chaine_entrante="";
  
}

empty1.JPG

The 10 13 is the carriage return and line feed characters sent when Serial.println() is executed.

Yeah that I know

It’s suppose to return:

+OK

But it’s actualy returning
+OK
some blank line

What can I do? I was counting on the double to know that my string is in, but that blank line screw me up. lol

Try changing your line ending to Newline in your Serial Monitor. There are some other configuration options you can play with there also

I don't really care about what it display in the monitor, the problem is that my code does not recognize the character so the double series is not recognize eider.

I'm basically sending a AT command to a wifi module, and I'm working on getting the answer.

Never mind it send a double linefeed it seem according to Realterm

For testing send the bytes to the serial monitor as HEX characters all on one line with

Serial.print((byte)caractere_entrant, HEX);
Serial.print(" -- ");

This will rule out the possibility of the serial monitor doing funny things when it gets a Cr or Lf.

...R

    if (Compte_retour=2){

The result of this assignment will always be 2. Is an assignment what you really want?

Thank you PaulS, :wink:

Here is my latest update of that serialEvent1 thing. It’s actually working now, Although I had to totally change my finding end string Procedure.

void serialEvent1(){

  char caractere_entrant;  
  
  while (Serial1.available()) {
    
    longueur_de_ligne++;
    caractere_entrant = (char)Serial1.read(); 
    chaine_entrante += caractere_entrant;
    
    if ((caractere_entrant == '\n')&&(dernier_caractere == '\r')){

      Compte_retour++;
      if (longueur_de_ligne < 3){chaine_complete = true;}   
      longueur_de_reponse += longueur_de_ligne
      longueur_de_ligne = 0;
   
    }

    dernier_caractere=caractere_entrant;
    
  }

}

Now, it’s actually looking for a newline that has at most 2 characters, since the AT command has 3 characters minimum, “+OK” in his answer this settle the thing.

Hello, Well, you could try this, If you talk directly to the module you are connected to and it give you a response +OK, where does the cursor gets? right beneath the +OK or is there an empty line in between?

Personally, up till now, all GSM modem (old phones actually) I have tried, always leave an extra line after the +OK

Hope it helps, Nikos

Thank you Nikosk

Yeah, it actualy the AT standard. You say

AT+something

And the card will reply

+OK

Or

+OK=some_parameter

Or

+ERR=some_number

the empty line is the second