How do I get an array of serial readings if readout isn't working with my device?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2020-8-28
I recommend writing an empty lne before the mOn command, in case there happens to be some junk in the buffer.
回答(1 个)
Kiran Felix Robert
2020-8-28
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!