Why is parseInt blocking my teensy 3.5?

I was glad to discover a parse function for Arduino , finally a easy way to cut a string.
I used it and parses, but I discover that some other functions are on hold in my sketch while the serial is available....

The sketch is huge, it reads 6 encoders periodically , etc

So here is my parsing fun:

  while (Serial6.available() )
  { CommandSent = 0;
    LeapIncomingStr = Serial6.readStringUntil('\n');

    Serial.println (LeapIncomingStr);
    Serial.println (millis ());
    int H_X = Serial6.parseInt() - 400;
    H_X = constrain (H_X, -300, 300);

    int H_Y = Serial6.parseInt();
    H_Y = -H_Y * 10;
    H_Y = constrain (H_Y, -450, -200);

    int H_Z = Serial6.parseInt(); //400 low to 200 high
    H_Z = 600 - H_Z;
    H_Z = constrain (H_Z, 300, 550);

    int H_Roll = Serial6.parseInt();
    H_Roll = (H_Roll) + 180 ;
    H_Roll = constrain (H_Roll, 90, 270);
    int H_Pitch = Serial6.parseInt();
    H_Pitch = (H_Pitch - 28) * 300;
    H_Pitch = constrain (H_Pitch, -10000, 10000);
    int H_Yaw = Serial6.parseInt();
    int H_Pinch = Serial6.parseInt();

   // Serial.printf ( "GoToXYZ:  H_X:%d, H_Y:%d, H_Z:%d, H_Roll:%d, H_Pitch:%d, H_Yaw:%d H_Pinch:%d  \n"
    //                , H_X,  H_Y, H_Z, H_Roll, H_Pitch, H_Yaw, H_Pinch);

    if (Mode == 2)  // RUN
      GoToXYZ  (-H_X, H_Y, H_Z, H_Pitch, H_Roll, 0); //x y z , grip orientation

    else if (Mode == 1) // PAUSE
      StepNo = 1;

  } //end of if Serial6 available

Please help. Love this function , parseINT

IF you love that function, then write a program that just uses it and exercise the function until you fully understand it.
Then you can incorporate it into the main program.

If I would know why it blocks the processor while receiving.... I could make some progress.
If you're too busy to help I understand . Just let others...

I used it and parses, but I discover that some other functions are on hold in my sketch while the serial is available....

A while() loop will do that in a single-task, single-thread processing environment:

 while (Serial6.available() )

So what to do? Thanks

Look at the documentation for parseInt - it has a timeout.

Serial.parseInt() is a blocking function.

Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.


As a higher level alternative check out my SafeString library (from the Arduino library manager)
It has non-blocking alternatives for reading Serial Text. readUntilToken()
There are detailed examples with the library and a detailed tutorial at SafeString for Arduino
Serial Text I/O for the Real World has more i/o examples.

Basically get the text token (say space delimited) and call
SafeString.toInt( intResult)
which returns true if the SafeString contains a valid integer.
In contrast the Arduino atoi will return 0 for invalid numbers and considers 55a as a valid number
SafeString.toInt( intResult) is much stricter and will return false for "55a" and leave intResult unchanged
see the library example sketch SafeStringtoNum.ino for examples