Knauer pump RS232 communication

function pumpHeadSize = knauerpumpobjreadpumpheadsizefast(serialObject)
% KNAUERPUMPOBJREADPUMPHEADSIZE reads the pump head size of Knauer pumps
% pumpHeadSize = knauerpumpobjreadpumpheadsize(serialObject) returns the
% pump head size of Knauer pumps, where serialObject is a valid serial
% object generated by knauerpumpobj. Response is in mL. This command
% differs from the normal version in that it will attempt to retrieve the
% pumpHeadSize from the serialObject UserData first, so is more useful for
% routine use since it reduces the communications overhead.
% checks the number of arguments
error(nargchk(1, 1, nargin))
% need to know the pump head size to figure out which command to use - the
% isfield statement also checks for isstruct at the same time
if isfield(serialObject.UserData, 'pumpHeadSize')
% use that
pumpHeadSize = serialObject.UserData.pumpHeadSize;
else
% we need to ask it first, but don't assume we can save it to the
% UserData
pumpHeadSize = knauerpumpobjreadpumpheadsize(serialObject);
end