Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation

by

 

06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

fibreobjstop(serialObject)
function fibreobjstop(serialObject)
% FIBREOBJSTOP stops data transmission from the FOR
% fibreobjstop(serialObject) stops data transmission from the FOR.  If its
% already not transmitting, this function will not send the command, but
% will not error either.


% checks the number of arguments
error(nargchk(1, 1, nargin))

% tries to get some data first to see if it is transmitting
try
    % defines an error flag
    errorFlag = false;
    
    % tries to fetch the data - it'll error if it isn't broadcasting
    fibreobjreadintensity(serialObject);

    % it didn't error, so we need to stop it (deliberately avoids the comms
    % protocols so that the buffer isn't flushed), and the FOR doesn't
    % acknowledge receipt of this when broadcasting
    serialwrite(serialObject, 170)
    
    % leave a short pause
    pause(0.5)
    
    % check how many bytes are left (DEBUG this will need to be changed for
    % Realterm operation)
    bytesRemaining = serialbytesavailable(serialObject);
    
    % leave a short pause again to ensure no more data has been sent
    pause(1.5)
    
    % if the bytes have changed, then its still broadcasting
    if bytesRemaining ~= serialbytesavailable(serialObject)
        % change the error flag
        errorFlag = true;
        
    else
        % purge the buffer
        serialflush(serialObject);
    end

catch
    % it errored, so its not broadcasting
    
    % if it didn't stop properly
    if errorFlag
        % error
        error('Could not stop the FOR broadcasting.')
        
    else
        % it didn't error, so simply give a warning - DEBUG sometimes gets
        % activated for an unknown reason, even if it works just fine
        %warning('fibreObjBroadcast:alreadyStopped', 'FOR broadcasting was already stopped.')
    end
end

Contact us