function s=cmd(spo,command,delayt) % SOSI-M2 V1.0 MATLAB M-file % % Send command, wait delay, print and return response % % Args: s=cmd(spo,command,delayt) % % spo: serial port object % command: text string, see SOSI manual % delayt: delay in milliseconds between sending command and reading reply % % s: reply string from SOSI s=''; fprintf(spo,command); pause(delayt) while spo.BytesAvailable > 5 s=fgetl(spo); % Print non-empty strings after removing ending terminator. if length(s) > 4 disp(s); end end % s=strtok(s1,sprintf('\r\n'));