MATLAB stops reading data
조회 수: 4 (최근 30일)
이전 댓글 표시
So, I want to read data of a STM32F103RBT6 development board. I am able to receive the data though the STM for 1-2 minutes after which the communication abrubtly ends and I need to restart MATLAB to reset the communication link before I can rerun the script. Please help
Matlab code:
clc
clear
try
s=serial('COM4','BAUD',115200);
fclose(s);
fopen(s);
l=256;
p=zeros(1,l);
q=ones(1,l);
tic;
for j=1:l
z=fgets(s);
string(z);
p(1,j)=hex2dec(strtrim(z));
end
toc;
plot([1:256l],p);xlim([0 l]);drawnow
while(1)
for i=l:-1:2
p(1,i)=p(1,i-1);
end
z=fgets(s);
string(z);
p(1,1)=hex2dec(strtrim(z));
plot([1:256l],p);xlim([0 l]);drawnow
end
catch me
fclose(s);
end
fclose(s);
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!