필터 지우기
필터 지우기

serial port usage

조회 수: 1 (최근 30일)
PK
PK 2012년 1월 11일
i just want to transmit and receive data from a terminal on another for that i made a small code as follows
global gnCount
serial_comA = serial('COM10');
serial_comA.Baudrate=9600;
% gnCount=0;
%set(serial_comA,'BaudRate',9600);
% serial_comA.terminator='LF'
serial_comA.BytesAvailableFcnMode='Terminator';
% serial_comA.BytesAvailableFcn=@fn_add_temp;
fopen(serial_comA);
while(gnCount<10)
disp(gnCount)
serial_comA.BytesAvailableFcn=@fn_add_temp;
end
disp('finished')
fclose(serial_comA);
% while(1)
% if strcmp(serial_comA.status,'closed')
% fopen(serial_comA);
% end
% end
and am getting as output when i run it but i want to receive ata from another pc
and in line 4 gnCount is commented if i dont comment it am getting a continuous data which is assigned to gnCount and MATLAB is struck pls help me in this ASAS

답변 (1개)

Walter Roberson
Walter Roberson 2012년 1월 11일
You have a "while" loop that depends upon gnCount, but you do not change gnCount in that loop.
Hint: you could use a "for" loop instead of a "while" loop.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by