Matlab & Arduino serial communication -Warning: Unsuccessful read: The input buffer was filled before the Terminator was reached.. "
7 views (last 30 days)
Show older comments
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 Comment
Sailesh Sidhwani
on 28 Jul 2017
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.
Answers (0)
See Also
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!