  % type, and detailed information about the error.
        error(message('vnt:XCP:SlaveResponseError', ...
            command, ...
            xcp.Utility.MAP_ERROR_CODE_TO_NAME(response(2)), ...
            xcp.Utility.MAP_ERROR_CODE_TO_EXPLANATION(response(2))));
    end
    
    function response = transmitCommand(obj, cmdData, varargin)
    % transmitCommand Sends an XCP command message.
    % 
    %   cmdData - An array of bytes that are the command message code and
    %       data.
    %   varargin - An optional value indicating how many times the
    %       current command has been issued. On first transmit, this
    %       argument does not exist. It gets incremented for each
    %       subsequent transmit attempt.
        
        % Set initial return value as empty. This defaults the return value
        % to indicate no response was received for the command.
        response = [];
        
        % Construct the CAN message.
        cmdMsg = can.Message( ...
            obj.TransportLayerInfo.MasterID, ...
            obj.TransportLayerInfo.MasterIDIsExtended, ...
            8);
        % Set the message command data.
        cmdMsg.Data = cmdData;
        % Send the command according to the configured transport layer.
        obj.TransportLayerObject.transmit(cmdMsg);
        
        % Poll for a response until the T1 timeout is reached or a response
        % is received. We hard code this to one second as A2L file
        % information is not always reliable.
        tStart = tic;
        while toc(tStart) <= 1
            % Check for a response and break the loop if found.
            if obj.ResponseAvailable
                break;
            end
            % Pause for some time.
            pause(0.025);
        end
            
        % Check for a response or a timeout.
        if obj.ResponseAvailable
            % Set the response data from the shared property and clear it.
            response = obj.ResponseData;
            obj.ResponseData = [];
            % Reset the response available property.
            obj.ResponseAvailable = false;
        
        elseif nargin == 2
            % Some commands require special handling.
            switch obj.CurrentCommand
                case 'DISCONNECT'
                    % On a disconnect command, return immediately.
                    return;
                otherwise
                    % Retry the command for a second time via recursive call.
                    response = obj.transmitCommand(cmdData, 2);
            end
        