Reading 20hz GPS Data while processing other things

I am making a quadrocopter library that uses interrupts to run all of the essential processes (like IMU and motor updates) ‘in the background’. My current issue is that I need a way to reliably capture the incoming serial data from my GPS on Serial1. The GPS data comes in 20 times per second at 115200 bps, but I don’t have a place in my code where I can reliably read the code fast enough.

My first though was using avr usart interrupts, but the arduino serial library already uses them. I can’t modify the existing libraries because I want my code to be portable.

Any ideas would be great.

-Eric

Without seeing your code, ideas how to change it are diffcult. I would just read it in. I guess you don't need it 20 times a second, so you probably can throw away most of the stuff and just decode it perhaps 2 to 5 times a second. If you have the essential parts done through interrupts you can just use the main loop() to do that readings. If you don't waist time by using delay() you should be fine with this. If not, you must buy a faster microcontroller.

pylon: Without seeing your code, ideas how to change it are diffcult. I would just read it in. I guess you don't need it 20 times a second, so you probably can throw away most of the stuff and just decode it perhaps 2 to 5 times a second. If you have the essential parts done through interrupts you can just use the main loop() to do that readings. If you don't waist time by using delay() you should be fine with this. If not, you must buy a faster microcontroller.

Well, the problem with that idea is that I want all of the process to happen inside the library files so that the user is only required to initialize it, then forget about it. I could always use a timer interrupt to read the data, but that idea seems a bit inefficient. The problem with posting the code is that it's all over the place at the moment, and would probably make the problem harder to understand.

The problem with posting the code is that it's all over the place at the moment, and would probably make the problem harder to understand.

Harder than not posting the code? Impossible!