Firmata and the Mega do not play well together. Ditch Firmata and write your own protocol to get data from/to the Arduino.