ported serial.c, but vars in it still get corrupted
this bug is only after g-code command