Matlab & Arduino serial communication -Warning: Unsuccessful read: The input buffer was filled before the Terminator was reached.. "

조회 수: 10 (최근 30일)
I am receiving the following message in matlab when trying to read from the serial port's input buffer.
Warning: Unsuccessful read: The input buffer was filled before the Terminator was reached..
In matlab I am using the BytesAvailableFcn to asynchronously check the input buffer for an event which is set to 'terniminator' which should be set to a linefeed:
arduino = serial('COM8','BaudRate',115200);
arduino.InputBufferSize = 1000; % set input buffer size
arduino.ReadAsyncMode = 'continuous'; % asynchronously fills the input buffer
arduino.Terminator = 'LF';
arduino.BytesAvailableFcnMode = 'terminator';
arduino.BytesAvailableFcn = @myCallback;
fopen(arduino);
fprintf(arduino,'*IDN?')
out = fscanf(arduino);
and my callback function:
function frame = myCallback(obj,event)
frame = fread(obj, obj.BytesAvailable);
disp(frame);
end
Now, strangely this method seems to work if I'm using the 'bytes' mode set to 901 bytes, but I cannot get it to work when checking for the terminator. And when using the bytes method the terminator is displayed in matlab, i.e. I see a '10' printed to the screen within the buffer size of 1000.
Any help is greatly appreciated!!
Cheers
  댓글 수: 1
Sailesh Sidhwani
Sailesh Sidhwani 2017년 7월 28일
Hi Nicholas,
Try setting a breakpoint in your callback function when in 'terminator' mode and see if there the terminator 'LF' is actually present in the input buffer. This would help in debugging the issue further.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by