필터 지우기
필터 지우기

Serial port slows / freezes after a few sends.

조회 수: 1 (최근 30일)
Reuben
Reuben 2013년 10월 12일
편집: Reuben 2013년 10월 12일
After sending X iterations of data over a serial port via fwrite/fprintf code begins to execute very slowly, one fwrite() call per 3 to 10 seconds. (X being nearly a random number from 3 to 1000+)
I am unsure where the problem is. The serial device is receiving the data.
clear, clc
count = 0;
delete(instrfindall)
socket = serial('COM11','BAUD',57600);
fopen(socket);
pause(3);
for i = 1:10000
count = count + 1;
disp(count)
fwrite(socket,'A','uint8')
%fprintf(socket,'%s','A')
pause (.01)
end
EDIT
Adding "stopasync(socket)" before calling "fprintf()" results in working code. Does anyone know why without "stopasync(socket)" the code fails? I currently suspect an hardware issue as the COM port is a USB port emulating a COM port.

답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by