How do I get an array of serial readings if readout isn't working with my device?
1 view (last 30 days)
Show older comments
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.
1 Comment
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.
Answers (1)
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,
Setting a longer timeout value, according to the length of the input data, resolve the issue.
Kiran Felix Robert
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!