MATLAB Language Reading from the serial port


Example

Assuming you created the serial port object s as in this example, then

% Read one byte
data = fread(s, 1);

% Read all the bytes, version 1
data = fread(s);

% Read all the bytes, version 2
data = fread(s, s.BytesAvailable);

% Close the serial port
fclose(s);