Code covered by the BSD License  

Highlights from
Thar ABPR-20 RS232 communication via handheld emulation

Thar ABPR-20 RS232 communication via handheld emulation

by

 

20 May 2013 (Updated )

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

serialopen(serialObject)
function output = serialopen(serialObject)
% SERIALOPEN starts communication with a serial object.

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

% checks that a serial object has been passed
if ~isserial(serialObject)
    % errors
    error('Must supply a serial object.')
end

% finds if it should be realterm or not
if isfield(serialObject.UserData, 'realTermHandle')
    % checks the port is open
    if isrunning(serialObject.UserData.realTermHandle)
        % errors
        error('Realterm is already connected.')
    end
    
    % connects and stores the data
    [serialData.UserData.captureFileID, serialData.UserData.captureFile] = realtermfopen(serialObject.UserData.realTermHandle);
    
else
    % checks its connected
    if isrunning(serialObject)
        % errors
        error('Serial port is already open.')
    end
    
    % connects normally
    fopen(serialObject)
end

Contact us