MyPort.bytesAvailable()

Description

Returns the number of bytes available to be read from the ArCOM serial port buffer

  • Values returned by Arduino remain in a buffer until they are read with MyPort.read()

Syntax

BytesAvailable = MyPort.bytesAvailable()

Parameters

-None-

Returns

  • BytesAvailable: The number of bytes available to be read.

Example

This example assumes a port has been created with:

MyPort = ArCOMObject('COM3', 115200); % Use your actual port and baud rate


% 1. This loop spams the command window with a message until 10 characters are available in the serial port buffer. Then, the characters are read out and displayed.

while MyPort.bytesAvailable() < 10

disp('Waiting...');

end

disp(MyPort.read(10, 'char'));