フィルターのクリア

Serial port slows / freezes after a few sends.

5 ビュー (過去 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 Center および File ExchangeStartup and Shutdown についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by