When the BattOrConnectionImpl does a serial read, it can result in a couple of states:
1) A complete message is read, and that message is returned.
2) Bytes are read, but they're wrong in some way that's irrecoverable. An example of this would be if the agent is expecting an ACK and it receives a BattOr data frame.
3) Bytes are read, and it's the start of a valid message, but more bytes are needed to complete that message. In this case, the connection should go back for more bytes until state 1) or 2) is reached.
Right now, 3) doesn't happen: instead the read just fails. This is masked by the fact that when a read fails, it retries up to three times. Because of this, we read more bytes up to three times. However, if a message is longer than 3 * MAX_READ_LENGTH, we're out of luck.
We should fix this so that we read more bytes up to MAX_MESSAGE_LENGTH when a message is incomplete.
Comment 1 by bugdroid1@chromium.org
, May 20 2016