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.

serialopen(serialObject)
function output = serialopen(serialObject)
% SERIALOPEN starts communication with a serial object.

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

% checks that a serial object has been passed
if ~isserial(serialObject)
    % errors
    error('Must supply a serial object.')
end

% finds if it should be realterm or not
if isfield(serialObject.UserData, 'realTermHandle')
    % checks the port is open
    if isrunning(serialObject.UserData.realTermHandle)
        % errors
        error('Realterm is already connected.')
    end
    
    % connects and stores the data
    [serialData.UserData.captureFileID, serialData.UserData.captureFile] = realtermfopen(serialObject.UserData.realTermHandle);
    
else
    % checks its connected
    if isrunning(serialObject)
        % errors
        error('Serial port is already open.')
    end
    
    % connects normally
    fopen(serialObject)
end

Contact us