MATLAB: Using the function waitfor() properly

MATLABreadlineserial

I have a code that scans an incoming string from the COM3 serial port, and reads it into a variable. The serial port is constantly sending out this string:
Reader 1:
Reader 2:
Reader 1:
Reader 2:
and so on. there are 2 RFID scanners attached, and when a code is held up to one of them, serial will output soemthing like this:
Reader 1: 0000000f2d%

Reader 2:
Reader 1: 0000000f2d%
Reader 2:
as long as the tag is held by reader 1, this string is exactly 24 characters in length.
here is my code:
addpath('C:\Users\Administrator\Dropbox (********)\******** Team Folder\Matlab\RFID chip reader\RfidChipData');
filename = 'CorrectedRFIDValues.xlsx';
[~, sheets] = xlsfinfo(filename);
% decision = fscanf(tags{portidx});
% [decision, receivedcount] = fscanf(tags{portidx});
delete(instrfind());
deciding_port = serialport('COM3', 9600);
decision = waitfor(readline(deciding_port), strlength, 24));
% if receivedcount < 24
% error('Received less data than expected. Received data was: %s', decision)
% end
%now we know we've got at least 24 characters.
in = decision(11:24);
rows_found = [];
sheets_found = {};
for K = 1 : length(sheets)
this_sheet = sheets{K};
[~, ~, raw] = xlsread(filename, this_sheet);
[rowNum, colNum] = find( strcmp(in, raw));
if ~isempty(rowNum)
rows_found = [rows_found; rowNum];
sheets_found = [sheets_found; repmat({this_sheet}, length(rowNum), 1)];
end
end
I get an error
Error using strlength (line 39)
Not enough input arguments.
Error in Manual_auto_update2>Manual_auto_update2_OutputFcn (line 91)
decision = waitfor(readline(deciding_port), strlength, 24);
Error in gui_mainfcn (line 264)
feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
Error in Manual_auto_update2 (line 42)
gui_mainfcn(gui_State, varargin{:});
if I put that line as
decision = waitfor(readline(deciding_port), strlength(readline(deciding_port)), 24);
I get the error
Error using strlength
Too many input arguments.
Error in Manual_auto_update2>Manual_auto_update2_OutputFcn (line 91)
decision = waitfor(readline(deciding_port), strlength(readline(deciding_port), 24));
Error in gui_mainfcn (line 264)
feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
Error in Manual_auto_update2 (line 42)
gui_mainfcn(gui_State, varargin{:});
I cant define readline() as its own variable, as then it defeats the purpose of the waitfor().
any help is appreciated.

Best Answer

From the help:
Syntax
Note: no second input argument. What you did was
strlength(readline(deciding_port), 24)
or in other words
strlength(yourString, 24)
Why did you pass 24 into strlength()??? It doesn't want it, just like it said. It takes only one input - the string itself.
Related Question