1. In Arduino Platform, "Serial Port" and "Serial Buffer" are different things. Therefore, the concepts of "read from Serial Port" and "read from Serial Buffer" should also be different.
2. The following diagram (Fig-1) depicts the presence of "Serial Port" and "Serial Buffer" in the Arduino UNO at conceptual level.
Figure-1:
3. When a character (data byte/asynchronous frame) arrives to the UNO, the MCU of the UNO Board gets interrupted in the background; it (the MCU) goes to the ISR routine, reads the character from the "Serial Port" and saves it in location-0 of the FIFO-type (first-in first-out) "Serial Buffer".
4. The user checks that there is at least one data byte in the "Serial Buffer" by executing the following code in his sketch:
Serial.available();
if(n != 0)
{
//Serial Buffer contains at least one character/data byte
}
5. If n is non-zero in Step-4, the user includes the following code in his sketch to bring out the character/data byte from the "Serial Buffer' and keep it in a variable:
char x = Serial.read();
6. What is about the following command --
byte m = Serial.readBytes(myBuffer, bytesToRead);
==> byte m = Serial.readBytes(myBuffer, 2);
(1) We have seen in Step-3 that the data bytes (charcaters) coming to the Serial Port were being received and saved in Serial Buffer by interrupt process. In Fig-1, we observe that 3 data bytes have been accumulated in the Serial Buffer.
(2) Serial.readBytes() command keeps reading data bytes/charcaters from the "Serial Buffer" until the reading of two data bytes/charcaters are done. That means that the method readBytes() will terminate when the requested number of data bytes (here it is 2) are read from the Serial Buffer. The myBuffer[] will hold only A and B although there are 3 three charcaters (A, B, C) in the Serial Buffer. The variable m is equal to 2 which is number of data bytes read from Serial Buffer and stored in myBuffer[] array.
(3) Serial.readBytes() command will also terminate after reading only 1 character (though 2 bytes are desired) if the delay between successive arrivals/storage (into Serial Port/Serial Buffer) of charcaters is greater than the "timeout period (default 1-sec)". The "timeout period" could be changed by executing the following code.
Serial.setTimeout(milliSeconds);