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

1 view (last 30 days)
So my code looks as follows:
check = serialportlist; %all ports
checkAv = serialportlist('available');
if numel(checkAv)==1
%use it
COMc = checkAv{:};
else
choseComId = listdlg('Chose COM',checkAv);
COMc = checkAv{choseComId};
end
bc_obj = serialport(COMc, 115200);
flush(bc_obj);
configureTerminator(bc_obj,"CR/LF");
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.

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

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!