IMU seems to cut short data from my GPS

I am using an NS-RAW GPS and the icm-20948 with the sparkfun breakout. I use the sparkfun icm arduino library to grab data from the IMU. When I run a gps by itself, I get data like this:
0 0 E9 DD A7 A 1 2B 41 9F AB 5B CC C7 34 31 41 7A 24 A7 63 24 0 0 45 64 1E 60 7 8 33 41 9E DE B4 E9 B3 E0 B6 41 7B 75 CC 46 C4 0 0 C4 9B 7B 0 7 7 2F 41 9E EE D6 55 8 F 2E 41 7A B1 57 59 20 0 0 44 B9 C4 0 7 9 27 41 9F 85 5A 19 64 52 A6 41 7B FA 60 50 34 0 0 C5 3D 68 E0 7 B 2E 41 9F 16 80 D9 6B A1 4A 41 7A 81 E3 54 4 0 0 45 F C5 C0 7 12 2F 41 9F 5B 42 3E 9A 8B C2 41 7A 46 CD 2A A8 0 0 45 3F 5C 20 7 1B 2C 41 9F 54 5D 6E 76 AA 8C 41 7B FB 2D DA F0 0 0 C5 3F D C0 7 1E 2A 41 9F 60 FE 19 6D BD 99 41 7A 45 64 B0 14 0 0 45 37 94 0 7 4 27 41 9F E2 67 A 67 D4 F4 41 7C 9 F6 95 84 0 0 C5 5D 28 20 7 17 29 41 9F C5 29 15 81 92 DE 41 7A BF BE F2 AC 0 0 C5 53 F4 0 7 E7 D

The D at the end shows the beginning of the end of the message. When I also run the IMU I get data like this:
0 0 D2 DD 6F 9 4 2B 41 6E B6 6A 74 FE CC 5F 41 43 63 6A 8A E0 0 0 C4 C3 FC C0 7 7 2F 41 71 51 BF 9B 60 CA D8 41 42 63 4A 71 A0 0 0 45 5A A 60 7 9 2D 41 6E 8C 99 AB 86 61 99 41 42 FD FC D3 40 0 0 43 D7 88 0 7 B 2C 41 72 C1 B7 F5 1D 1F 80 41 42 17 A0 80 20 10 2B 81 2E 95 43 E2 0 FF 40 2E 41 AD C3 29 AD 64 0 C4 80 41 6D 6C 88 41 42 4 44 E 7 1A 71 5F DA 41 75 60 0 C 8 28 1F 75 0 67 A 0 2B 0 CE 7 0 1D 1F 2 0 2D 1 B 0 0 0 7 0 2B 0 30 17 6 0 1F 6 0 30 0 62 1A 0 16 1F A 0 0 74 8 6 0 37 1F A0

I actually have it stop when it sees the beginning prompt for a message, which starts with A0. I am not sure what in the IMU code is making the GPS read cut short. Any help would be appreciated.

uarttest.ino (15.7 KB)

I actually have it stop when it sees the beginning prompt for a message, which starts with A0. I am not sure what in the IMU code is making the GPS read cut short.

Reading the IMU needs some time. During this time the serial data from the GPS is still received but stored to a buffer. Once that buffer is full you get these problems.

Do you really need 3 GPS receivers?

As you have a Mega2560 (at least the code looks like that but you failed to tell us) you can try to increase the serial buffer to increase the probability to read all data from the GPS receiver.

Sorry I forgot to mention, I am using a teensy 3.2. I'll see what I can do to increase the buffer. I need 6 gps receivers, but the teensy can only up to 3, so I am using 2 of them.