I looked a bit at it, and maybe got a possibility, but that is only if your code can also be really busy with other stuff.
Lets assume you send two commands, one is A, other one is B. So you send from serial: "A\nB\n". After the first '\n' MODSERIAL probably calls your autodetect function, which sets sFlag = 1. However lets assume your code is meanwhile doing other stuff, such as calculating pi to 2 million digits, so meanwhile also 'B' is received, and is placed in the input buffer since interrupts are still enabled. Now pi is calculated, and it runs the routine you printed above. There it moves 3 bytes, and replaced the last one, so you get in your buffer: "A\n\0", and the next time you only receive '\n'.
So the problem would be you only disable RX interrupts when your function gets to it, not immediatly when the MODSERIAL interrupt is called. I can imagine several solutions, but easiest would be adding your autodetect char to your move command.
I've run across a problem in MODSERIAL, where there's a backlog of characters (I think they're stuck in the device fifo). My processing loop goes like this:
What I find is that eventually I send off a command (say "v\n") and it processes a character that was in the buffer earlier. After about 3 or 4 additional characters I finally receive my command.
I think the problem is caused by line 59 of getc.cpp
which isn't protected from the overwrite in line 46 of isrrx.cpp
Are ++ and
--
atomic?