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.

rheodyne232objfastcomm(serialObject, command)
function output = rheodyne232objfastcomm(serialObject, command)
% RHEODYNE232OBJFASTCOMM Reads and writes data from Rheodyne valves
% rheodyne232objfastcomm( serialObject, command) reads or writes
% information from/to Rheodyne valves connected via serial port. serialObject
% is the serial port object, and command is the command (as a string). If
% reading a value, responds with the value or a horizontal array of values
% if successfully carried out.  This is the fast version, which means there
% is no error checking of the communications.

% Normal usage:

% e.g. rheodyne232objcomm(serialObject, 'S') for the current valve status.

% Range:

% serialObject = valid serial object
% command = string


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

% error handling
if ~isserial(serialObject) || (~isfield(serialObject.UserData, 'realTermHandle') && ~isrunning(serialObject))
    % the serial object must be valid and open to send or receive data
    % (unless there is a realterm handle available)
    error('serialObject must be a valid open serial object')
    
elseif ~isserial(serialObject) || (isfield(serialObject.UserData, 'realTermHandle') && ~isrunning(serialObject.UserData.realTermHandle))
    % if the handle is there, the object must be running (PortOpen is 1)
    error('If the Realterm handle is present, the object must be connected via Realterm.')
        
elseif isfield(serialObject.UserData, 'realTermHandle') && (~isfield(serialObject.UserData, 'captureFileID') || ~isfid(serialObject.UserData.captureFileID))
    % if using realterm, the capture file ID must be there
    error('If using Realterm, the capture file handle must be in the serial object''s UserData.')
    
elseif ~ischar(command) || (~isvector(command) && ~isscalar(command))
    % errors
    error('Command must be a string.')
end

% flushes out anything in the buffer - this is essential for repeated runs
serialflush(serialObject);

% sends command
serialprint(serialObject, command, 'async')

Contact us