My robot falls in that time delay.
Are you trying to control a balancing robot using MonoBrick communication library?
Creepy enough I tried the same task with Monobrick Firmware…and it has the same problem. The loop terminates anywhere in between.
What do you mean it terminates? Does the reading return zero?
I think that the if this is the case there might be an issue with the kernel modules – since they are used in both the firmware and the communication library.