
Using MATLAB's Interface for External Libraries
1MA171_5e Rohde & Schwarz How to use Rohde & Schwarz Instruments in MATLAB
®
19
For more detailed examples of library calling conventions, see section 0 and 3.7, or
refer to the MATLAB
®
calllib documentation.
C
leaning before exiting the application
This is done using the following MATLAB
®
code:
%
% clean up before exit
unloadlibrary(vxipnpLib);
clear all;
3.5 General Rules for Passing Arguments to Libraries
Because data representation differs from the ANSI C representation for passing
arguments, some steps have to be performed before calling a library function, e.g.
creating a pointer to a variable storing array of characters. Please refer to the provided
MATLAB
®
documentation for "Calling Functions in Shared Libraries" and the examples
given following sections.
3.6 Application Example using the 32-bit rssmu
Instrument Driver
%% Rohde & Schwarz GmbH & Co. KG
% MATLAB calllib example for Signal Generator R&S SMU200A and R&S
% SMBV100A instrument driver (rssmu)
%
% Purpose: Test of loadlibrary/calllib for rssmu VXIplug&play instrument
% driver
% The example configures 3GPP on a Vector Signal Generator
% Author: Juergen Engelbrecht, customersupport@rohde-schwarz.com
%% setup up the mex compiler before the first run
%mex -setup
%% add library path
% check VXIPNPPATH environment variable on your system
% for the correct path or call instrhwinfo('vxipnp', 'rssmu') for DriverDllName
addpath 'c:\Program Files\IVI Foundation\VISA\WinNT\Include';
addpath 'c:\Program Files\IVI Foundation\VISA\WinNT\Bin';
%% load library of R&S driver
vxipnpLib = 'rssmu_32';
vxinpnLibDll = 'rssmu_32.dll';
vxipnpHeader = 'rssmu.h';
if ~libisloaded (vxipnpLib)
loadlibrary(vxinpnLibDll, vxipnpHeader);
end
%You can use these functions to get information on the functions available in a
library that you have loaded:
%libfunctions(vxipnpLib);
%libfunctionsview(vxipnpLib);
%% open VISA session
instr_session = -1;
instr_resource = 'TCPIP::rssmu200a123123::INSTR';
instr_presource = libpointer( 'int8Ptr', [int8( instr_resource ) 0] );
instr_idQuery = 1;
Komentarze do niniejszej Instrukcji