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.

tharbprobjreadmaxout(tharBPRObj, profile)
function maxOut = tharbprobjreadmaxout(tharBPRObj, profile)
% THARBPROBJREADMAXOUT reads MaxOut of a profile in Thar BPRs
% maxOut = tharbprobjmaxout(tharBPRObj, profile) reads the MaxOut (PID
% constant) of a particular profile of Thar BPRs. tharBPRObj is the BPR
% serial object (generated by tharbproj).  The profile is either 'A' or
% 'B', or omitted, in which case the name of the current profile is used.
% maxOut is a number.

% e.g. maxOut = tharbprobjreadmaxout(tharbprobj(5), 'A') - returns the
% maxOut for profile A of the Thar BPR on COM5, e.g. 4500.

% Range:

% tharBPRObj = valid serial port object

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

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

% if profile wasn't defined, fetch the current one, otherwise, error check
% the supplied profile
if nargin < 2
    % gets the current profile, and turns it into lower case for data input
    profile = tharbprobjreadcurrentprofile(tharBPRObj);
elseif ~istharbprobjprofile(profile)
    % errors
    error('Profile must be either A or B.')
% navigates to display menu

% presses F5 to get to the profile setup screen, then selects a profile
tharbprobjcomm('write', tharBPRObj, [21, uint8(profile), 13, 13, 13, 13])

% reads out the screen
response = tharbprobjcomm('readnoflush', tharBPRObj);

% pull out the numbers and convert them
maxOut = str2double(response{3}(isstrprop(response{3}, 'digit')));

% navigate back
tharbprobjcomm('write', tharBPRObj, 27)

Contact us