Code covered by the BSD License  

Highlights from
Thar ABPR-20 RS232 communication via handheld emulation

Thar ABPR-20 RS232 communication via handheld emulation



20 May 2013 (Updated )

Controls and reads from a Thar ABPR-20, by emulating the handheld controller.

tharbprobjwriteprofilename(tharBPRObj, profileName, profile)
function tharbprobjwriteprofilename(tharBPRObj, profileName, profile)
% THARBPROBJWRITEPROFILENAME writes the profileName to a Thar BPR
% tharbprobjwriteprofilename(tharBPRObj, profileName, profile) writes the profileName to a profile in
% a Thar BPR. tharBPRObj is the BPR serial object (generated by tharbproj),
% and profile is either 'A' or 'B'.  If the profile is not supplied, the
% set pressure is applied to the current profile. profileName is a string
% using the 32-127 ASCII character set.  It can be no longer than 7
% characters and must be at least one character.

% e.g. tharbprobjwriteprofilename(tharbprobj(5), 'P1') - sets the
% profileName of the current profile to 'P1' on the Thar BPR attached to
% COM5

% Range:

% tharBPRObj = valid serial port object

% profileName = string (see above for details)

% profile = 'A', 'B' or omitted

% error handling
if nargin < 2
    % errors
    error('Insufficient arguments')
elseif ~ischar(profileName) || isempty(profileName) || length(profileName) > 7 || any(profileName > 126) || any(profileName < 32)
    % errors
    error('profileName must be a string no longer than 7 characters only using printable characters with ASCII codes less than 127.')

% more error handling
if nargin < 3
    % gets the current profile
    profile = tharbprobjreadcurrentprofile(tharBPRObj);
elseif numel(profile) ~= 1 || ~any(strcmp(profile, {'A', 'B'}))
    % errors
    error('Profile must be either A or B.')
    % navigates to the display menu

% presses F5 then the profile name to get to the correct screen, enters the
% name, presses enter five times, then 'y' to save the changes - it takes
% around 4 seconds before the BPR starts sending screen updates out again
% (no idea why)
tharbprobjcomm('writesave', tharBPRObj, [char(21), profile, profileName, char([13, 13, 13, 13, 13]), 'Y'])

Contact us