Software serial blocking my code

Hi all,
I'm building a system that has to wait for a pin to change to read data from a chip (see code).
My arduino blocks after a few "loop" string prints.

If I comment the while loop it works fine but the data I get from the chip is wrong :frowning:
Can anyone please help?

int getData(void) {
 (...)
  while(digitalRead(SDAT) == HIGH) {}; 
(...)
}

loop (){
   data = getData()
   if (softserial.available() > 0){
        index = softserial.readBytesUntil('\r', inData, 5);
      inData[index] = '\0';
      Serial.println(inData);
    }
    Serial.println("loop");
}

you should not use the "readbytesuntil" function, you will be waiting a long time.

Each time through loop( ), you should only read the characters which are already available.

you will be waiting a long time.

If you consider 1 second a long time. I do.

OP: That stuff you posted won't even compiler. Post ALL of your code.

michinyon:
you should not use the "readbytesuntil" function, you will be waiting a long time.

Each time through loop( ), you should only read the characters which are already available.

The problem is that even without the print code it does not work. If I comment out the print to hardware serial and have:

SoftwareSerial softserial(8,9); // RX, TX
void setup() {                
  pinMode(8, INPUT);
  Serial.begin(115200);
  softserial.begin(9600);
}

void loop (){
   data = getData()
    Serial.println("loop");
}

It crashes after a few iterations of the loop.

Posting all the code will not help much because you don't have the chip and it is working fine without the software serial things.

Does anyone have an idea why the while loop in getData could after the software serial?

Posting all the code will not help much

Not posting it won't help at all.

Does anyone have an idea why the while loop in getData could after the software serial?

Likely because the serial buffer overflows while you're farting around waiting for the pin to go HIGH.

Thanks for the comments, but just realized that there is something wrong between my chip communication and arduino.
Sofware serial just triggers it. Since the chip and its communication protocol are not opensource can't show anything else.