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.

tharbprobjreadprofilename(tharBPRObj, profile)
function profileName = tharbprobjreadprofilename(tharBPRObj, profile)
% THARBPROBJREADPROFILENAME reads the profile name of Thar BPRs
% profileName = tharbprobjreadprofilename(tharBPRObj, profile) reads the
% profile name 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.

% e.g. profileName = tharbprobjreadprofilename(tharbprobj(5), 'A') -
% returns the profile name of profile A of the Thar BPR on COM5.

% 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
    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
tharbprobjcomm('write', tharBPRObj, 21)

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

% the line is: 'A-Name' starting at row 2, also remove any trailing white
% space
profileName = deblank(response{uint8(profile) - 63}(3:end));

% navigate back
tharbprobjcomm('write', tharBPRObj, [65, 27])

Contact us