I was wondering about gcode read ahead in Marlin(on RAMPS if that matters). I am trying to figure out a timing issue where I have the Tool change sent via I2c to a daughterboard that runs my extruders, and it seems to be about a second ahead of the printer. I am playing with putting a delay in, but I’m a little unclear of why it wants the tool change early. My assumption is that the Tcode is sent up the wire and changes the extruder before the printer is actually at the corresponding execution point.
I have a few ideas on how to offset this issue, but thought maybe someome would have a better explanation or conformation of my assumption.
@Scott_Lahteine , think you can help?
Insert a one millisecond pause one line ahead of the tool change and see if it changes anything.
I think M codes are executed asynchronously. Try to insert an M400 before your i2c mcode call to process the buffer first.
Hope it helps, just a best guess 
Oh wow that’s almost exactly my solution:
“Finishes all current moves and and thus clears the buffer. That’s identical to G4 P0.”
http://reprap.org/wiki/G-code#M400:_Wait_for_current_moves_to_finish
Thank you!!! M400 works great. Actually solved a 2nd problem I had that I was going to attack after this one was solved. On to more testing!!!