Serial.print() Cutting Off Phrases

Hello,

I'm using Serial.print() to debug my program (see where it runs and where it does not). Currently the program is supposed to print out the following:

"Starting...."
then
"IMU Started"
then
"MLB"
then
"Roll Loop Done"

However, in the Serial Consol, I'm getting these phrases cut off at random sections like this:

"Starting....IMU StartedMLBRollLo"

Why is this?

Thanks,
Zachary

It's not the while loop timer issue. I tried while(1) and it did the same thing. One thing to note is that "MLB" is always complete. I'll upload the files I'm working with. It isn't the complete package, so it won't compile, but it should be all that is necessary.

void Plane::Move(int roll, int pitch, int yaw, String velocity, int time) /// time in miliseconds
{
  desiredRoll = roll;
  desiredPitch = pitch;
  desiredYaw = yaw;
  desiredVelocity = velocity;
  unsigned long startTimer = micros();
  unsigned long endTimer   = micros();
  while ((endTimer - startTimer) < (time*1000)) {
    Serial.println("MLB");
    delay(15);
    rollPlane(roll);
    Serial.println("Roll Loop Done");
    delay(15);
    pitchPlane(pitch);
    Serial.println("Pitch Loop Done");
    yawPlane(yaw);
    Serial.println("Yaw Loop Done");
    velocityPlane(velocity);
    Serial.println("Velocity Loop Done");
    /// May need a function to check if there is a lost connection/regained conection to the IMU via Serial
    endTimer = micros();
  }
}

plane_v5.ino (670 Bytes)

AutoCorrect.cpp (7.44 KB)

MiniTasks.cpp (10.7 KB)

Plane.h (3.02 KB)

You are printing stuff out in a loop that looks as if it would run very quickly - you are probably producing output faster than the serial port can transfer it. Is it really useful to print stuff out that frequently?

Does the problem still show up if you reduce the baud rate from 115200 to 57600?