MATLAB Answers

How do I get an array of serial readings if readout isn't working with my device?

1 view (last 30 days)
David Olaleye
David Olaleye on 24 Aug 2020
Commented: Walter Roberson on 28 Aug 2020
So my code looks as follows:
check = serialportlist; %all ports
checkAv = serialportlist('available');
if numel(checkAv)==1
%use it
COMc = checkAv{:};
choseComId = listdlg('Chose COM',checkAv);
COMc = checkAv{choseComId};
bc_obj = serialport(COMc, 115200);
writeline(bc_obj,"mOn 1000");
disp = readline(bc_obj);
And when I run it, I end up getting a timeout warning.
Warning: The specified amount of data was not returned within the Timeout period for 'readline'.
'serialport' unable to read any data. For more information on possible reasons, see serialport Read Warnings.
This doesn't seem to happen whenever I use read on my code, but I need to have more than the alotted characters being read.

  1 Comment

Walter Roberson
Walter Roberson on 28 Aug 2020
I recommend writing an empty lne before the mOn command, in case there happens to be some junk in the buffer.

Sign in to comment.

Answers (1)

Kiran Felix Robert
Kiran Felix Robert on 28 Aug 2020
Hi David,
The Warning is related to a timeout issue. For more information about this warning refer to the following documentations,
For resolving timeout issues refer to the timeout documentation.
Setting a longer timeout value, according to the length of the input data, resolve the issue.
Kiran Felix Robert


Sign in to comment.





Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!