Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation



06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

function tharbprobjconnect(serialObject)
% THARBPROBJCONNECT initialises communication with Thar BPRs
% tharbprobjconnect(serialObject) initialises communication with Thar BPRs,
% given serialObject as a valid serial object (generated by tharbprobj).

% e.g. tharbprobjconnect(tharbprobj(5)) - initialises communication with
% the Thar BPR attached to COM5

% Range:

% serialObject = valid serial port object

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

% error handling
if ~isserial(serialObject) || isrunning(serialObject)
    % errors
    error('serialObject must be a valid closed serial object.')
elseif isfield(serialObject.UserData, 'realTermHandle') && isrunning(serialObject.UserData.realTermHandle)
    % errors
    error('The realterm application must not be connected.')

% if the real term handle is there, do a different sequence of events
if isfield(serialObject.UserData, 'realTermHandle')
    % run the real term opener
    serialObject.UserData.captureFileID = realtermfopen(serialObject.UserData.realTermHandle);

    % opens communication

% sends initiating command - at the moment this MUST be sent within ~10
% seconds of the BPR being switched on - after this is done the first time,
% then as long as the BPR is not turned off, then this is not necessary
tharbprobjcomm('write', serialObject, [char(27), '[0n'])

% Notes (<ESC> is char(27)):

% first command is sent by the BPR: '<ESC>[4n' (~4.5 s after turning on)
% HOWEVER, have also seen: '<ESC>[1[4n' (suspected read error since this
% does not normally fit the BPR communications syntax and '<ESC>[1s'

% the hand-held appears to check its own memory (this message does not come
% from the BPR), before sending the initialisation command below:

% response by the hand-held: '<ESC>[0n' (~7.3 s after turning on)

% the BPR immediately responds by sending the first batch of screen content
% to self-test the BPR, then sends another command: '<ESC>[0q' - this also
% seems to mean "bad key press"

Contact us