Data Acquisition Toolbox Support Package for Digilent Analog Discovery hardware (R2012a / R2012b)



02 Oct 2012 (Updated )

Analog Input/Output (foreground clocked/non-clocked) support for Digilent Analog Discovery.

daq.di.setup.daq_digilent_waveforms_installer(downloadDirectory, installerName)
function daq_digilent_waveforms_installer(downloadDirectory, installerName)
%DAQ_DIGILENT_WAVEFORMS_INSTALLER Digilent WaveForms Software and Driver
%installer helper. The installer will check the version of the digilent
%installer and any installed versions. Will only fire installation if below
%minimum requirements.

% Copyright 2012-2013 The MathWorks, Inc.

% The file is downloaded with a different name. Rename the file
% Get the list of files
dirInfo = dir(downloadDirectory);
fileInfoArray = dirInfo(arrayfun(@(x) ~x.isdir, dirInfo));

% Find the file that only has the installer-name embedded in it, and
% rename it
downloadedFile = fileInfoArray(arrayfun(@(x) ~isempty(strfind(, installerName)), fileInfoArray));

if isempty(downloadedFile)
    % The installer file was not downloaded correctly or the support
    % package registry lists the wrong installer file name
    % We don't have a resource string right now for this under hwconnectinstaller. The message
    % catalog for the support package won't get registered until it is
    % used. We'll switch this when hwconnectinstaller has an equivalent
    % resource.
    error(message('hwconnectinstaller:setup:Error', ...
        ['Could not download the requested installer, ', installerName]));

    oldFileName = fullfile(downloadDirectory,;
    installerFile = fullfile(downloadDirectory, installerName);

if ~exist(installerName, 'file')    
    % Rename the file

% Installer Flag
silentFlag = ' /S';
installerVersionFlag = ' /InstallerWaveFormsVersion';
installedVersionFlag = ' /InstalledWaveFormsVersion';

% Check the installer version. If the installer version doesn't meet
% minimum reqs, then abort
cmdstr = ['"' installerFile '"' silentFlag installerVersionFlag];
[ret, ~] = system(cmdstr, '-runAsAdmin');

minimumRequired = 2.3;
installerVersion = majorMinorHex2Dec(ret);

if installerVersion  < minimumRequired
    error(message('hwconnectinstaller:setup:Error', ...
        ['The Installer',installerName, ...
        'does not meet the minimum version requirement.' ...
        'The minimum required version is ' num2str(minimumRequired)]));

% Check the installed version. If the installed version does not meet
% minimum requirements, or if a newer version is available, go ahead and
% install
cmdstr = ['"' installerFile '"' silentFlag installedVersionFlag];
[ret, ~] = system(cmdstr, '-runAsAdmin');
installedVersion = majorMinorHex2Dec(ret);

if (installedVersion < minimumRequired) || (installerVersion > installedVersion)
    [~, ~] = system(['"' installerFile '"' silentFlag], '-runAsAdmin');

% Utility nested function

    function out = majorMinorHex2Dec(ret)
        % This function will convert the hex int32 return value that
        % encodes the version into a double number. This double number will
        % represent the version number. For instance, if the version is
        % returned as 2.1.2, the double number representing this will be
        % 2.1 + 2/(1e5).
        hexstr = dec2hex(ret,8);
        majorHex = hexstr(1:2);
        minorHex = hexstr(3:4);
        buildHex = hexstr(5:end);
        out = hex2dec(majorHex)+ hex2dec(minorHex)/10 + hex2dec(buildHex)/100000;


Contact us