Code covered by the BSD License  

Highlights from
Matlab LibTiePie 0.4.3 instrument driver for Handyscope HS5

Matlab LibTiePie 0.4.3 instrument driver for Handyscope HS5

by

TiePie engineering

 

03 Oct 2013 (Updated )

MatlabLibTiePie : TiePie engineering's instrument library for Matlab 7.6 = 2008a and higher.

LibTiePie.Library
% LibTiePie is a library for controlling TiePie engineering's test and measurement equipment.
% The following device types are supported:
% - oscilloscopes
% - function generators / arbitrary waveform generators (AWG)
% - I2C hosts.
%
% For more information, see api.tiepie.com and www.tiepie.com/LibTiePie .
%
% (c) 2012-2013 TiePie engineering.

classdef Library < handle
  properties ( SetAccess = private )
    sLibrary = 'libtiepie';
    List;
    VersionString;
  end

  methods
    function obj = Library( sLibraryName )
      if ( nargin > 0 )
        obj.sLibrary = sLibraryName;
      end

      % Load library if that is not already done:
      if ~libisloaded( obj.sLibrary )
        if isunix()
          addpath( '/usr/include' ); % On Unix systems the LibTiePie headers are here.
        end
        [ notfound , warnings ] = loadlibrary( obj.sLibrary , 'libtiepiematlab.h' , 'addheader' , 'libtiepie' );
        pause( 0.2 );
        if libisloaded( obj.sLibrary )
          qwVersionMin =  hex2dec( [ '0000' '0004' '0003' '0000' ] );
          qwVersionMax =  hex2dec( [ '0000' '0004' 'FFFF' 'FFFF' ] );
          % Version check:
          if obj.Version < qwVersionMin
            warning( sprintf( 'To fully function, this version of MatlabLibTiePie needs LibTiePie %s or higher, but version %s was detected.' , LibTiePie.VersionNumber2String( qwVersionMin ) , LibTiePie.VersionNumber2String( obj.Version ) ) );
          elseif obj.Version > qwVersionMax
            warning( sprintf( 'This version of MatlabLibTiePie is designed to work with LibTiePie up to version %s, but version %s was detected. Not everything may work correctly.' , LibTiePie.VersionNumber2String( qwVersionMax ) , LibTiePie.VersionNumber2String( obj.Version ) ) );
          end
        else
          error( [ 'Could not load library ' , obj.sLibrary ] )
        end
      end

      obj.List = LibTiePie.List( obj );
    end

    function delete( self )
      unloadlibrary( self.sLibrary );
    end;

    function qwVersion = Version( self )
      qwVersion = calllib( self.sLibrary , 'LibGetVersion' );
    end

    function sVersion = get.VersionString( self )
      sVersion = LibTiePie.VersionNumber2String( Version( self ) );
    end

    function nLastStatus = LastStatus( self )
      nLastStatus = calllib( self.sLibrary , 'LibGetLastStatus' );
    end

    function sLastStatus = LastStatusStr( self )
      sLastStatus = calllib( self.sLibrary , 'LibGetLastStatusStr' );
    end

    function bSucces = CheckStatus( self )
      nLastStatus = self.LastStatus;
      bSucces = nLastStatus >= 0;
      if ( ~bSucces )
        error( self.LastStatusStr );
      else
        if nLastStatus > 0
          warning( self.LastStatusStr );
        end;
      end
    end;

  end
end

Contact us