I'm trying to communicate with a aftermarket car ECU via RS-232.
I can send a request packet to my ECU, and it replies with the requested data.
The amount of data differs from what I requested.
It can be about 30 Bytes of data sent by the ECU to my DUE.
So far so good...
But, how can I read all the data stored in the Serial Buffer? (It can store up to 64 Bytes, right?)
With the available method, I can only count the amount of data received. I found no method to read the whole Buffer.
Data over serial drops in one at the time.
You must build up the returned data piece by piece. Often there is a or at the end of an response. So read until the terminator and then you can analyze the response.
Actually, it returns an int. The data is in the low order byte. The error, if there was one, is in the high order byte.
If you KNOW that there will be no error, because you have used Serial.available() to make sure that there is something to read, then you can use byte or char, depending on whether you are receiving ASCII data or binary data.