% 11/14/2007 % ========== instrreset; % reset any open ports s1 = serial('COM6','Timeout',2); fopen(s1); % ********** ss1 section ********* cmd = 'o0w1'; cr = char(13);lf = char(10);crlf = strcat(cr,lf); cmd = strcat(cmd,crlf); % also works with only CR or only LF tic for i = 1:100, fprintf(s1, cmd); load = fscanf(s1,'%d') [eos,count,msg] = fread(s1,1,'char'); % end of string sentinel (null) % must be cleared from the read buffer pause(0.2); % delay 200 milliseconds, % try tweaking end toc % ********** fclose(s1); instrreset; % reset any open ports