Using SoftwareSerial Giving error

Something strange happen using SoftwareSerial

I will try to summary what I am doing and give only the relevant information.

Module2.listen();

incomingByte = Module.read();

      if (incomingRE == 19){    
  Serial.print(incomingByte, HEX);
  Serial.print(","); }

        if ((incomingByte == 0x22) && (incomingRE == 19)){
           Serial.println("");
  incomingRE = 20;  
   }    
       if (incomingRE == 20) {    
         Serial.print(incomingByte, HEX);
  Serial.print(","); 
  counter = 0;
}  
        if ((incomingByte == 0xFFFFFFFF) && (counter < 4)) {
  Serial.println("DONE");
 counter++; 
//  incomingRE = 21;  
   }

It should print a number of values received from de Module (serial transmission) but it print only one on the serial monitor at the PC the strange thing is if I start printing 0xFFFFFFFF to the PC it does print all the values.

Have you got any ideas why this is happening? Thanks

This is the reply to give you more idea

We have received a AT
We have received a + So far AT+
We have received a + So far AT+C
We have received a + So far AT+CPMR=2
We have received a + So far +CMGR:
22,52,52,45,41,44,22,2C,We have received a 
FFFFFFF2,FFFFFFFB,4,4,7,7,3,4,5,5,FFFFFFF2,FFFFFFFC,We have received a  , 
22,,32,34,2C,We have received a  , doble coma 
2C,31,36,33,36,2B,30,34,22,
20,22,20,D,DONE

have if I modify the code with: if ((incomingRE == 20) || (incomingByte > 0x00) ){

so it print anything coming from serial bigger then 0

2C,2C,31,31,36,36,3A,3A,34,34,30,30,3A,3A,33,33,36,36,2B,2B,72,72,DONE

which still does not make sense but at least its printing somethig

You really need to read up on SoftwareSerial::available(), so that you stop trying to read data that isn't there.

You should have a peek at an ASCII table, too, to learn what 2C, 31, 36, 3A, 34, 30, 3A, 33, 36, 2B, and 72 mean. It's not clear why you are printing each character twice.

Module2.listen();

incomingByte = Module.read();

Make one instance active. Then, read from another one. The listen() call wasn't too useful, was it?

You should use Tools + Auto Format to stop your code from wandering all over the page that way.

I think you have missed the point!

The point is about if you look at the first reply there is less values printed at the serial terminal.

I have king of done now by adding the value received at the serial terminal, its seen it cannot handle a long list of if statement, b ut there strange it does in some other way

P.D. When I said the thing dont make sense its because there HEX value does match to what they should, and yes I know there value are HEX as I make it print ",HEX" and I have a ASCII table ;-).

Peter2013: I have king of done now by adding the value received at the serial terminal, its seen it cannot handle a long list of if statement, b ut there strange it does in some other way

If your coding is as bad as your spelling then it's no wonder it doesn't work right. :)

Your description is a bit incoherent but guessing at what you're trying to say you have concluded that the if statements are not doing what you intended. If you think this means "it cannot handle a long list of if statement" then you are mistaken. It handles long lists of if statements just fine. The problem is that you have not coded the if statements correctly. This is almost inevitable given the chaotic way you have laid your code out, making it almost impossible to see what the structure is. Lay the code out sensibly as PaulS advised you and it will be obvious what it is doing. Most likely you will then see the problem. If you don't, then explain what it's supposed to do and what it actually does and I'm sure somebody will point out where the mistake is.

If you don't, then explain what it's supposed to do and what it actually does and I'm sure somebody will point out where the mistake is.

That assumes, of course, that you post ALL of your code.