User`s guide

108 Agilent VISA User’s Guide
4 Programming via GPIB and VXI
ViUInt16*addr16;
ViStatusstatus;
ViUInt16offset;
status = viOpenDefaultRM ( &drm );
checkError( 0, status, "viOpenDefaultRM",
EXIT );
/* Open a session to the VXI MEMACC Resource*/
status = viOpen( drm, "vxi0::memacc",
VI_NULL, VI_NULL,
&vi );
checkError (0, status, "viOpen", EXIT );
/* Calculate the A16 offset of the VXI
REgisters for
the device at VXI logical address 8. */
offset = 0xc000 + 64 * 8;
/* Open a map to all of A16 memory space. */
status =
viMapAddress(vi,VI_A16_SPACE,0,0x10000,
VI_FALSE,0,(ViPAddr)(&addr));
checkError( vi, status, "viMapAddress", EXIT
);
/* Offset the address pointer returned from
viMapAddress for use with viPeek16. */
addr16 = (ViUInt16 *) (addr + offset);
/* Peek the contents of the card’s ID register
(offset
0 from card’s base address. Note that
viPeek does
not return a status code. */
viPeek16( vi, addr16, &peekData16 );
/* Now use viIn16 and read the contents of the
same
register */
status = viIn16(vi, VI_A16_SPACE,
ViBusAddress)offset, &inData16 );
checkError(vi, status, "viIn16", NO_EXIT );