
Programming with VISA
3
Agilent VISA User’s Guide
77
/* Print results */
printf ("Instrument identification string:
%s\n", buf);
/* Close session */
viClose (vi);
viClose (defaultRM);}
Example: Shared Lock
This example shows a session gaining a
shared lock with the
accessKey
called
lockkey
. Other sessions can now
use this
accessKey
in the
requestedKey
parameter of the
viLock
function to share access on the locked resource. This example then
shows the original session acquiring an exclusive lock while
maintaining its shared lock.
When the session holding the exclusive lock unlocks the resource via
the
viUnlock
function, all the sessions sharing the lock again have all
the access privileges associated with the shared lock.
/* lockshr.c
This example program queries a GPIB device for
an identification string and prints the results.
Note that you must change the address. */
#include <visa.h>
#include <stdio.h>
void main () {
ViSession defaultRM, vi;
char buf [256] = {0};
char lockkey [256] = {0};
/* Open session to GPIB device at address 22 */
viOpenDefaultRM (&defaultRM);
viOpen (defaultRM, "GPIB0::22::INSTR",
VI_NULL,VI_NULL,&vi);
/* acquire a shared lock so only this process
and processes that we know about can access
this resource */
viLock (vi, VI_SHARED_LOCK, 2000, VI_NULL,
lockkey);
Summary of Contents for E2094S
Page 6: ...6 Agilent VISA User s Guide ...
Page 116: ...116 Agilent VISA User s Guide 4 Programming via GPIB and VXI ...
Page 126: ...126 Agilent VISA User s Guide 5 Programming via LAN ...
Page 143: ...Glossary Agilent VISA User s Guide 143 Windows notification area See notification area ...